diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..cb3c971b --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,28 @@ +name: .NET + +on: + push: + branches: [ librelancer ] + pull_request: + branches: [ librelancer ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + working-directory: ./src + run: dotnet restore + - name: Build + working-directory: ./src + run: dotnet build --no-restore + - name: Test + working-directory: ./src + run: dotnet test --no-build --verbosity normal diff --git a/.gitignore b/.gitignore index c2fc1cd9..2e15013b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ *.suo *.user *.sln.docstates +*.idea +*.vs # Build results diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index de786af8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: csharp -solution: src/moonsharp.sln -sudo: required - -mono: - - 2.10.8 - -script: - - xbuild /p:TargetFrameworkProfile='' /p:Configuration=Release src/moonsharp_ci_net35.sln - - cd src/TestRunners/ConsoleTestRunner/bin/Release - - mono ConsoleTestRunner.exe -# - chmod 777 aotregen.sh -# - chmod 777 aottest.sh -# - sudo ./aotregen.sh -# - sudo ./aottest.sh - diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..e7c607de --- /dev/null +++ b/AUTHORS @@ -0,0 +1,17 @@ + +# This is the list of MoonSharp's significant contributors. +# +# This does not necessarily list everyone who has contributed code, +# especially since many employees of one corporation may be contributing. +# To see the full list of contributors, see the revision history in +# source control. + +Marco Mastropaolo +wledfor2 +NullShock78 +doritsugita +Pedro Fanha +Benjamin Dobell +Kevin Morgan +Callum McGing +Matěj Štágl diff --git a/LICENSE b/LICENSE index 33d21309..5b1726e3 100755 --- a/LICENSE +++ b/LICENSE @@ -1,16 +1,7 @@ -Copyright (c) 2014-2016, Marco Mastropaolo -All rights reserved. - -Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua) -Copyright (c) 2012 LoDC +BSD 3-Clause License -Visual Studio Code debugger code is based on code from Microsoft vscode-mono-debug project (https://github.com/Microsoft/vscode-mono-debug). -Copyright (c) Microsoft Corporation - released under MIT license. - -Remote Debugger icons are from the Eclipse project (https://www.eclipse.org/). -Copyright of The Eclipse Foundation - -The MoonSharp icon is (c) Isaac, 2014-2015 +Copyright (c) 2014-2022 The MoonSharp Authors, as shown by the AUTHORS file. +All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -22,7 +13,7 @@ modification, are permitted provided that the following conditions are met: this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of the {organization} nor the names of its +* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -36,3 +27,8 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua) +Copyright (c) 2012 LoDC + +The MoonSharp icon is (c) Isaac, 2014-2015 diff --git a/README.md b/README.md index 56246141..b9ccb335 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +MoonSharp: Librelancer Branch +* This only contains a subset of the MoonSharp project for .Net Core 3.1 +* See upstream at https://github.com/moonsharp-devs/moonsharp + + MoonSharp [![Build Status](https://travis-ci.org/xanathar/moonsharp.svg?branch=master)](https://travis-ci.org/xanathar/moonsharp) [![Build Status](https://img.shields.io/nuget/v/MoonSharp.svg)](https://www.nuget.org/packages/MoonSharp/) ========= http://www.moonsharp.org diff --git a/bfg.jar b/bfg.jar deleted file mode 100644 index e66f73c1..00000000 Binary files a/bfg.jar and /dev/null differ diff --git a/src/.vs/restore.dg b/src/.vs/restore.dg deleted file mode 100755 index 0a8c8d32..00000000 --- a/src/.vs/restore.dg +++ /dev/null @@ -1,7 +0,0 @@ -#:Z:\git\my\moonsharp\src\MoonSharp.VsCodeDebugger\_Projects\MoonSharp.VsCodeDebugger.netcore\MoonSharp.VsCodeDebugger.netcore.xproj -Z:\git\my\moonsharp\src\MoonSharp.VsCodeDebugger\_Projects\MoonSharp.VsCodeDebugger.netcore\MoonSharp.VsCodeDebugger.netcore.xproj|Z:\git\my\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.xproj -#:Z:\git\my\moonsharp\src\TestRunners\DotNetCoreTestRunner\DotNetCoreTestRunner.xproj -Z:\git\my\moonsharp\src\TestRunners\DotNetCoreTestRunner\DotNetCoreTestRunner.xproj|Z:\git\my\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.xproj -Z:\git\my\moonsharp\src\TestRunners\DotNetCoreTestRunner\DotNetCoreTestRunner.xproj|Z:\git\my\moonsharp\src\MoonSharp.VsCodeDebugger\_Projects\MoonSharp.VsCodeDebugger.netcore\MoonSharp.VsCodeDebugger.netcore.xproj -Z:\git\my\moonsharp\src\MoonSharp.VsCodeDebugger\_Projects\MoonSharp.VsCodeDebugger.netcore\MoonSharp.VsCodeDebugger.netcore.xproj|Z:\git\my\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.xproj -#:Z:\git\my\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.xproj diff --git a/src/DevTools/MoonSharp.VmDebugger/DoubleBufferedListView.cs b/src/DevTools/MoonSharp.VmDebugger/DoubleBufferedListView.cs deleted file mode 100644 index 7a95c0ee..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/DoubleBufferedListView.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Debugger -{ - class DoubleBufferedListView : System.Windows.Forms.ListView - { - public DoubleBufferedListView() - : base() - { - this.DoubleBuffered = true; - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/Ext_Methods.cs b/src/DevTools/MoonSharp.VmDebugger/Ext_Methods.cs deleted file mode 100644 index b038f2ed..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Ext_Methods.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace MoonSharp.Debugger -{ - static class Ext_Methods - { - public static ListViewItem Add(this ListView lv, params object[] texts) - { - ListViewItem lvi = new ListViewItem(); - lvi.Text = texts[0].ToString(); - - for (int i = 1; i < texts.Length; i++) - { - ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem(); - lvsi.Text = texts[i].ToString(); - lvi.SubItems.Add(lvsi); - } - - lv.Items.Add(lvi); - - return lvi; - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/MainForm.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/MainForm.Designer.cs deleted file mode 100644 index 39223e89..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/MainForm.Designer.cs +++ /dev/null @@ -1,1057 +0,0 @@ -namespace MoonSharp.Debugger -{ - partial class MainForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.connectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scriptCodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.bytecodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stepOverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stepInToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.toggleBreakpointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); - this.gOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.btnOpenFile = new System.Windows.Forms.ToolStripButton(); - this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.toolGO = new System.Windows.Forms.ToolStripButton(); - this.toolStepOver = new System.Windows.Forms.ToolStripButton(); - this.toolStepIN = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButton5 = new System.Windows.Forms.ToolStripButton(); - this.btnFollow = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.btnFastHack = new System.Windows.Forms.ToolStripButton(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.tabControl2 = new System.Windows.Forms.TabControl(); - this.tabPage3 = new System.Windows.Forms.TabPage(); - this.lvWatches = new MoonSharp.Debugger.DoubleBufferedListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.toolStrip2 = new System.Windows.Forms.ToolStrip(); - this.btnAddWatch = new System.Windows.Forms.ToolStripButton(); - this.btnRemoveWatch = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.btnViewWatch = new System.Windows.Forms.ToolStripButton(); - this.toolGoToCodeWatches = new System.Windows.Forms.ToolStripButton(); - this.label3 = new System.Windows.Forms.Label(); - this.tabPage4 = new System.Windows.Forms.TabPage(); - this.lvVStack = new MoonSharp.Debugger.DoubleBufferedListView(); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.toolStrip3 = new System.Windows.Forms.ToolStrip(); - this.btnViewVStk = new System.Windows.Forms.ToolStripButton(); - this.toolGoToCodeVStack = new System.Windows.Forms.ToolStripButton(); - this.label2 = new System.Windows.Forms.Label(); - this.imageList1 = new System.Windows.Forms.ImageList(this.components); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.lvCallStack = new MoonSharp.Debugger.DoubleBufferedListView(); - this.colAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colBP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.toolStrip4 = new System.Windows.Forms.ToolStrip(); - this.toolGoToCodeXStack = new System.Windows.Forms.ToolStripButton(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.label1 = new System.Windows.Forms.Label(); - this.splitContainer3 = new System.Windows.Forms.SplitContainer(); - this.codeView = new MoonSharp.Debugger.SourceCodeDebugControl(); - this.tabControl3 = new System.Windows.Forms.TabControl(); - this.tabPage5 = new System.Windows.Forms.TabPage(); - this.txtOutput = new System.Windows.Forms.TextBox(); - this.toolStrip5 = new System.Windows.Forms.ToolStrip(); - this.tabPage6 = new System.Windows.Forms.TabPage(); - this.txtCodeView = new System.Windows.Forms.TextBox(); - this.toolStrip6 = new System.Windows.Forms.ToolStrip(); - this.timerFollow = new System.Windows.Forms.Timer(this.components); - this.btnOpenTest = new System.Windows.Forms.ToolStripButton(); - this.menuStrip1.SuspendLayout(); - this.toolStrip1.SuspendLayout(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.splitContainer2.Panel1.SuspendLayout(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); - this.tabControl2.SuspendLayout(); - this.tabPage3.SuspendLayout(); - this.toolStrip2.SuspendLayout(); - this.tabPage4.SuspendLayout(); - this.toolStrip3.SuspendLayout(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); - this.toolStrip4.SuspendLayout(); - this.tabPage2.SuspendLayout(); - this.splitContainer3.Panel1.SuspendLayout(); - this.splitContainer3.Panel2.SuspendLayout(); - this.splitContainer3.SuspendLayout(); - this.tabControl3.SuspendLayout(); - this.tabPage5.SuspendLayout(); - this.tabPage6.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileToolStripMenuItem, - this.viewToolStripMenuItem, - this.debugToolStripMenuItem, - this.helpToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1094, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.openToolStripMenuItem, - this.connectToolStripMenuItem, - this.toolStripMenuItem1, - this.exitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileToolStripMenuItem.Text = "&File"; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.Open_6529; - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openToolStripMenuItem.Size = new System.Drawing.Size(155, 22); - this.openToolStripMenuItem.Text = "&Open..."; - this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); - // - // connectToolStripMenuItem - // - this.connectToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.AddConnection_477; - this.connectToolStripMenuItem.Name = "connectToolStripMenuItem"; - this.connectToolStripMenuItem.Size = new System.Drawing.Size(155, 22); - this.connectToolStripMenuItem.Text = "Connect..."; - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(152, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(155, 22); - this.exitToolStripMenuItem.Text = "&Exit"; - // - // viewToolStripMenuItem - // - this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.scriptCodeToolStripMenuItem, - this.bytecodeToolStripMenuItem}); - this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; - this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.viewToolStripMenuItem.Text = "&View"; - // - // scriptCodeToolStripMenuItem - // - this.scriptCodeToolStripMenuItem.Name = "scriptCodeToolStripMenuItem"; - this.scriptCodeToolStripMenuItem.Size = new System.Drawing.Size(133, 22); - this.scriptCodeToolStripMenuItem.Text = "Script code"; - // - // bytecodeToolStripMenuItem - // - this.bytecodeToolStripMenuItem.Checked = true; - this.bytecodeToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.bytecodeToolStripMenuItem.Name = "bytecodeToolStripMenuItem"; - this.bytecodeToolStripMenuItem.Size = new System.Drawing.Size(133, 22); - this.bytecodeToolStripMenuItem.Text = "Bytecode"; - // - // debugToolStripMenuItem - // - this.debugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.stepOverToolStripMenuItem, - this.stepInToolStripMenuItem, - this.toolStripMenuItem2, - this.toggleBreakpointToolStripMenuItem, - this.toolStripMenuItem3, - this.gOToolStripMenuItem}); - this.debugToolStripMenuItem.Name = "debugToolStripMenuItem"; - this.debugToolStripMenuItem.Size = new System.Drawing.Size(54, 20); - this.debugToolStripMenuItem.Text = "&Debug"; - // - // stepOverToolStripMenuItem - // - this.stepOverToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.StepOver_6328; - this.stepOverToolStripMenuItem.Name = "stepOverToolStripMenuItem"; - this.stepOverToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F10; - this.stepOverToolStripMenuItem.Size = new System.Drawing.Size(190, 22); - this.stepOverToolStripMenuItem.Text = "Step-Over"; - this.stepOverToolStripMenuItem.Click += new System.EventHandler(this.stepOverToolStripMenuItem_Click); - // - // stepInToolStripMenuItem - // - this.stepInToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.StepIn_6326; - this.stepInToolStripMenuItem.Name = "stepInToolStripMenuItem"; - this.stepInToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F11; - this.stepInToolStripMenuItem.Size = new System.Drawing.Size(190, 22); - this.stepInToolStripMenuItem.Text = "Step-In"; - this.stepInToolStripMenuItem.Click += new System.EventHandler(this.stepInToolStripMenuItem_Click); - // - // toolStripMenuItem2 - // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(187, 6); - // - // toggleBreakpointToolStripMenuItem - // - this.toggleBreakpointToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.BreakpointEnabled_6584_16x; - this.toggleBreakpointToolStripMenuItem.Name = "toggleBreakpointToolStripMenuItem"; - this.toggleBreakpointToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F9; - this.toggleBreakpointToolStripMenuItem.Size = new System.Drawing.Size(190, 22); - this.toggleBreakpointToolStripMenuItem.Text = "Toggle Breakpoint"; - // - // toolStripMenuItem3 - // - this.toolStripMenuItem3.Name = "toolStripMenuItem3"; - this.toolStripMenuItem3.Size = new System.Drawing.Size(187, 6); - // - // gOToolStripMenuItem - // - this.gOToolStripMenuItem.Image = global::MoonSharp.Debugger.Properties.Resources.startwithoutdebugging_6556; - this.gOToolStripMenuItem.Name = "gOToolStripMenuItem"; - this.gOToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5; - this.gOToolStripMenuItem.Size = new System.Drawing.Size(190, 22); - this.gOToolStripMenuItem.Text = "GO"; - this.gOToolStripMenuItem.Click += new System.EventHandler(this.gOToolStripMenuItem_Click); - // - // helpToolStripMenuItem - // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.aboutToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.helpToolStripMenuItem.Text = "&Help"; - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.aboutToolStripMenuItem.Text = "&About"; - // - // toolStrip1 - // - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.btnOpenFile, - this.toolStripButton2, - this.toolStripSeparator1, - this.toolStripButton3, - this.toolStripSeparator2, - this.toolGO, - this.toolStepOver, - this.toolStepIN, - this.toolStripSeparator3, - this.toolStripButton5, - this.btnFollow, - this.toolStripSeparator5, - this.btnFastHack, - this.btnOpenTest}); - this.toolStrip1.Location = new System.Drawing.Point(0, 24); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(1094, 25); - this.toolStrip1.TabIndex = 1; - this.toolStrip1.Text = "toolStrip1"; - // - // btnOpenFile - // - this.btnOpenFile.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnOpenFile.Image = global::MoonSharp.Debugger.Properties.Resources.Open_6529; - this.btnOpenFile.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnOpenFile.Name = "btnOpenFile"; - this.btnOpenFile.Size = new System.Drawing.Size(23, 22); - this.btnOpenFile.Text = "Open File"; - this.btnOpenFile.Click += new System.EventHandler(this.btnOpenFile_Click); - // - // toolStripButton2 - // - this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton2.Image = global::MoonSharp.Debugger.Properties.Resources.AddConnection_477; - this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton2.Name = "toolStripButton2"; - this.toolStripButton2.Size = new System.Drawing.Size(23, 22); - this.toolStripButton2.Text = "toolStripButton2"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); - // - // toolStripButton3 - // - this.toolStripButton3.Checked = true; - this.toolStripButton3.CheckState = System.Windows.Forms.CheckState.Checked; - this.toolStripButton3.Image = global::MoonSharp.Debugger.Properties.Resources.DisassemblyWindow_6536; - this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton3.Name = "toolStripButton3"; - this.toolStripButton3.Size = new System.Drawing.Size(76, 22); - this.toolStripButton3.Text = "Bytecode"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); - // - // toolGO - // - this.toolGO.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolGO.Image = global::MoonSharp.Debugger.Properties.Resources.startwithoutdebugging_6556; - this.toolGO.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolGO.Name = "toolGO"; - this.toolGO.Size = new System.Drawing.Size(23, 22); - this.toolGO.Text = "GO"; - this.toolGO.Click += new System.EventHandler(this.toolGO_Click); - // - // toolStepOver - // - this.toolStepOver.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStepOver.Image = global::MoonSharp.Debugger.Properties.Resources.StepOver_6328; - this.toolStepOver.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStepOver.Name = "toolStepOver"; - this.toolStepOver.Size = new System.Drawing.Size(23, 22); - this.toolStepOver.Text = "Step-Over"; - this.toolStepOver.Click += new System.EventHandler(this.toolStepOver_Click); - // - // toolStepIN - // - this.toolStepIN.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStepIN.Image = global::MoonSharp.Debugger.Properties.Resources.StepIn_6326; - this.toolStepIN.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStepIN.Name = "toolStepIN"; - this.toolStepIN.Size = new System.Drawing.Size(23, 22); - this.toolStepIN.Text = "Step-In"; - this.toolStepIN.Click += new System.EventHandler(this.toolStripButton1_Click); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); - // - // toolStripButton5 - // - this.toolStripButton5.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButton5.Image = global::MoonSharp.Debugger.Properties.Resources.BreakpointEnabled_6584_16x; - this.toolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton5.Name = "toolStripButton5"; - this.toolStripButton5.Size = new System.Drawing.Size(23, 22); - this.toolStripButton5.Text = "toolStripButton5"; - // - // btnFollow - // - this.btnFollow.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.btnFollow.Image = ((System.Drawing.Image)(resources.GetObject("btnFollow.Image"))); - this.btnFollow.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnFollow.Name = "btnFollow"; - this.btnFollow.Size = new System.Drawing.Size(46, 22); - this.btnFollow.Text = "Follow"; - this.btnFollow.Click += new System.EventHandler(this.btnFollow_Click); - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); - // - // btnFastHack - // - this.btnFastHack.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.btnFastHack.Image = ((System.Drawing.Image)(resources.GetObject("btnFastHack.Image"))); - this.btnFastHack.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnFastHack.Name = "btnFastHack"; - this.btnFastHack.Size = new System.Drawing.Size(130, 22); - this.btnFastHack.Text = "Open C:\\temp\\test.lua"; - this.btnFastHack.Click += new System.EventHandler(this.btnFastHack_Click); - // - // statusStrip1 - // - this.statusStrip1.Location = new System.Drawing.Point(0, 712); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(1094, 22); - this.statusStrip1.TabIndex = 2; - this.statusStrip1.Text = "statusStrip1"; - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 49); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.splitContainer3); - this.splitContainer1.Size = new System.Drawing.Size(1094, 663); - this.splitContainer1.SplitterDistance = 364; - this.splitContainer1.TabIndex = 3; - // - // splitContainer2 - // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer2.Panel1 - // - this.splitContainer2.Panel1.Controls.Add(this.tabControl2); - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.Controls.Add(this.tabControl1); - this.splitContainer2.Size = new System.Drawing.Size(364, 663); - this.splitContainer2.SplitterDistance = 307; - this.splitContainer2.TabIndex = 0; - // - // tabControl2 - // - this.tabControl2.Controls.Add(this.tabPage3); - this.tabControl2.Controls.Add(this.tabPage4); - this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl2.ImageList = this.imageList1; - this.tabControl2.Location = new System.Drawing.Point(0, 0); - this.tabControl2.Name = "tabControl2"; - this.tabControl2.SelectedIndex = 0; - this.tabControl2.Size = new System.Drawing.Size(364, 307); - this.tabControl2.TabIndex = 1; - // - // tabPage3 - // - this.tabPage3.Controls.Add(this.lvWatches); - this.tabPage3.Controls.Add(this.toolStrip2); - this.tabPage3.Controls.Add(this.label3); - this.tabPage3.ImageIndex = 3; - this.tabPage3.Location = new System.Drawing.Point(4, 23); - this.tabPage3.Name = "tabPage3"; - this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(356, 280); - this.tabPage3.TabIndex = 0; - this.tabPage3.Text = "Watches"; - this.tabPage3.UseVisualStyleBackColor = true; - // - // lvWatches - // - this.lvWatches.BackColor = System.Drawing.SystemColors.Window; - this.lvWatches.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3, - this.columnHeader4}); - this.lvWatches.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvWatches.FullRowSelect = true; - this.lvWatches.GridLines = true; - this.lvWatches.Location = new System.Drawing.Point(3, 28); - this.lvWatches.Name = "lvWatches"; - this.lvWatches.Size = new System.Drawing.Size(350, 249); - this.lvWatches.TabIndex = 4; - this.lvWatches.UseCompatibleStateImageBehavior = false; - this.lvWatches.View = System.Windows.Forms.View.Details; - this.lvWatches.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvWatches_MouseDoubleClick); - // - // columnHeader1 - // - this.columnHeader1.Text = "Name"; - this.columnHeader1.Width = 72; - // - // columnHeader2 - // - this.columnHeader2.Text = "Type"; - this.columnHeader2.Width = 57; - // - // columnHeader3 - // - this.columnHeader3.Text = "Value"; - this.columnHeader3.Width = 111; - // - // columnHeader4 - // - this.columnHeader4.Text = "Symbol loc."; - this.columnHeader4.Width = 72; - // - // toolStrip2 - // - this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.btnAddWatch, - this.btnRemoveWatch, - this.toolStripSeparator4, - this.btnViewWatch, - this.toolGoToCodeWatches}); - this.toolStrip2.Location = new System.Drawing.Point(3, 3); - this.toolStrip2.Name = "toolStrip2"; - this.toolStrip2.Size = new System.Drawing.Size(350, 25); - this.toolStrip2.TabIndex = 3; - this.toolStrip2.Text = "toolStrip2"; - // - // btnAddWatch - // - this.btnAddWatch.Image = global::MoonSharp.Debugger.Properties.Resources.AddMark_10580; - this.btnAddWatch.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnAddWatch.Name = "btnAddWatch"; - this.btnAddWatch.Size = new System.Drawing.Size(49, 22); - this.btnAddWatch.Text = "Add"; - this.btnAddWatch.Click += new System.EventHandler(this.btnAddWatch_Click); - // - // btnRemoveWatch - // - this.btnRemoveWatch.Image = global::MoonSharp.Debugger.Properties.Resources.Clearallrequests_8816; - this.btnRemoveWatch.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnRemoveWatch.Name = "btnRemoveWatch"; - this.btnRemoveWatch.Size = new System.Drawing.Size(70, 22); - this.btnRemoveWatch.Text = "Remove"; - this.btnRemoveWatch.Click += new System.EventHandler(this.btnRemoveWatch_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(6, 25); - // - // btnViewWatch - // - this.btnViewWatch.Image = global::MoonSharp.Debugger.Properties.Resources.FindSymbol_6263; - this.btnViewWatch.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnViewWatch.Name = "btnViewWatch"; - this.btnViewWatch.Size = new System.Drawing.Size(52, 22); - this.btnViewWatch.Text = "View"; - this.btnViewWatch.Click += new System.EventHandler(this.btnViewWatch_Click); - // - // toolGoToCodeWatches - // - this.toolGoToCodeWatches.Image = global::MoonSharp.Debugger.Properties.Resources.GoToDeclaration_5576; - this.toolGoToCodeWatches.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolGoToCodeWatches.Name = "toolGoToCodeWatches"; - this.toolGoToCodeWatches.Size = new System.Drawing.Size(87, 22); - this.toolGoToCodeWatches.Text = "Go to Code"; - this.toolGoToCodeWatches.ToolTipText = "Go to Code"; - this.toolGoToCodeWatches.Click += new System.EventHandler(this.toolGoToCodeWatches_Click); - // - // label3 - // - this.label3.Dock = System.Windows.Forms.DockStyle.Fill; - this.label3.Location = new System.Drawing.Point(3, 3); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(350, 274); - this.label3.TabIndex = 2; - this.label3.Text = "Not Implemented Yet"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // tabPage4 - // - this.tabPage4.Controls.Add(this.lvVStack); - this.tabPage4.Controls.Add(this.toolStrip3); - this.tabPage4.Controls.Add(this.label2); - this.tabPage4.ImageIndex = 1; - this.tabPage4.Location = new System.Drawing.Point(4, 23); - this.tabPage4.Name = "tabPage4"; - this.tabPage4.Padding = new System.Windows.Forms.Padding(3); - this.tabPage4.Size = new System.Drawing.Size(356, 280); - this.tabPage4.TabIndex = 1; - this.tabPage4.Text = "V-Stack"; - this.tabPage4.UseVisualStyleBackColor = true; - // - // lvVStack - // - this.lvVStack.BackColor = System.Drawing.SystemColors.Window; - this.lvVStack.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader5, - this.columnHeader6, - this.columnHeader7}); - this.lvVStack.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvVStack.FullRowSelect = true; - this.lvVStack.GridLines = true; - this.lvVStack.Location = new System.Drawing.Point(3, 28); - this.lvVStack.Name = "lvVStack"; - this.lvVStack.Size = new System.Drawing.Size(350, 249); - this.lvVStack.TabIndex = 7; - this.lvVStack.UseCompatibleStateImageBehavior = false; - this.lvVStack.View = System.Windows.Forms.View.Details; - this.lvVStack.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvVStack_MouseDoubleClick); - // - // columnHeader5 - // - this.columnHeader5.Text = "Stack ofs"; - this.columnHeader5.Width = 72; - // - // columnHeader6 - // - this.columnHeader6.Text = "Type"; - this.columnHeader6.Width = 94; - // - // columnHeader7 - // - this.columnHeader7.Text = "Value"; - this.columnHeader7.Width = 157; - // - // toolStrip3 - // - this.toolStrip3.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.btnViewVStk, - this.toolGoToCodeVStack}); - this.toolStrip3.Location = new System.Drawing.Point(3, 3); - this.toolStrip3.Name = "toolStrip3"; - this.toolStrip3.Size = new System.Drawing.Size(350, 25); - this.toolStrip3.TabIndex = 6; - this.toolStrip3.Text = "toolStrip3"; - // - // btnViewVStk - // - this.btnViewVStk.Image = global::MoonSharp.Debugger.Properties.Resources.FindSymbol_6263; - this.btnViewVStk.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnViewVStk.Name = "btnViewVStk"; - this.btnViewVStk.Size = new System.Drawing.Size(52, 22); - this.btnViewVStk.Text = "View"; - this.btnViewVStk.Click += new System.EventHandler(this.btnViewVStk_Click); - // - // toolGoToCodeVStack - // - this.toolGoToCodeVStack.Image = global::MoonSharp.Debugger.Properties.Resources.GoToDeclaration_5576; - this.toolGoToCodeVStack.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolGoToCodeVStack.Name = "toolGoToCodeVStack"; - this.toolGoToCodeVStack.Size = new System.Drawing.Size(87, 22); - this.toolGoToCodeVStack.Text = "Go to Code"; - this.toolGoToCodeVStack.ToolTipText = "Go to Code"; - this.toolGoToCodeVStack.Click += new System.EventHandler(this.toolGoToCodeVStack_Click); - // - // label2 - // - this.label2.Dock = System.Windows.Forms.DockStyle.Fill; - this.label2.Location = new System.Drawing.Point(3, 3); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(350, 274); - this.label2.TabIndex = 1; - this.label2.Text = "Not Implemented Yet"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // imageList1 - // - this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); - this.imageList1.TransparentColor = System.Drawing.Color.Transparent; - this.imageList1.Images.SetKeyName(0, "CallStackWindow_6561.png"); - this.imageList1.Images.SetKeyName(1, "Centered_11691.png"); - this.imageList1.Images.SetKeyName(2, "CodeCoverageResults_8592.png"); - this.imageList1.Images.SetKeyName(3, "LocalsWindow_6562.png"); - // - // tabControl1 - // - this.tabControl1.Controls.Add(this.tabPage1); - this.tabControl1.Controls.Add(this.tabPage2); - this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl1.ImageList = this.imageList1; - this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(364, 352); - this.tabControl1.TabIndex = 0; - // - // tabPage1 - // - this.tabPage1.Controls.Add(this.lvCallStack); - this.tabPage1.Controls.Add(this.toolStrip4); - this.tabPage1.ImageIndex = 0; - this.tabPage1.Location = new System.Drawing.Point(4, 23); - this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(356, 325); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "Call Stack"; - this.tabPage1.UseVisualStyleBackColor = true; - // - // lvCallStack - // - this.lvCallStack.BackColor = System.Drawing.SystemColors.Window; - this.lvCallStack.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colAddress, - this.colName, - this.colReturn, - this.colBP}); - this.lvCallStack.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvCallStack.FullRowSelect = true; - this.lvCallStack.GridLines = true; - this.lvCallStack.Location = new System.Drawing.Point(3, 28); - this.lvCallStack.Name = "lvCallStack"; - this.lvCallStack.Size = new System.Drawing.Size(350, 294); - this.lvCallStack.TabIndex = 8; - this.lvCallStack.UseCompatibleStateImageBehavior = false; - this.lvCallStack.View = System.Windows.Forms.View.Details; - // - // colAddress - // - this.colAddress.Text = "Address"; - this.colAddress.Width = 72; - // - // colName - // - this.colName.Text = "Name"; - this.colName.Width = 106; - // - // colReturn - // - this.colReturn.Text = "Return"; - this.colReturn.Width = 72; - // - // colBP - // - this.colBP.Text = "Base Ptr"; - this.colBP.Width = 72; - // - // toolStrip4 - // - this.toolStrip4.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolGoToCodeXStack}); - this.toolStrip4.Location = new System.Drawing.Point(3, 3); - this.toolStrip4.Name = "toolStrip4"; - this.toolStrip4.Size = new System.Drawing.Size(350, 25); - this.toolStrip4.TabIndex = 7; - this.toolStrip4.Text = "toolStrip4"; - // - // toolGoToCodeXStack - // - this.toolGoToCodeXStack.Image = global::MoonSharp.Debugger.Properties.Resources.GoToDeclaration_5576; - this.toolGoToCodeXStack.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolGoToCodeXStack.Name = "toolGoToCodeXStack"; - this.toolGoToCodeXStack.Size = new System.Drawing.Size(87, 22); - this.toolGoToCodeXStack.Text = "Go to Code"; - this.toolGoToCodeXStack.ToolTipText = "Go to Code"; - this.toolGoToCodeXStack.Click += new System.EventHandler(this.toolGoToCodeXStack_Click); - // - // tabPage2 - // - this.tabPage2.Controls.Add(this.label1); - this.tabPage2.ImageIndex = 2; - this.tabPage2.Location = new System.Drawing.Point(4, 23); - this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(356, 325); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Coroutines"; - this.tabPage2.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.Location = new System.Drawing.Point(3, 3); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(350, 319); - this.label1.TabIndex = 1; - this.label1.Text = "Not Implemented Yet"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // splitContainer3 - // - this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer3.Location = new System.Drawing.Point(0, 0); - this.splitContainer3.Name = "splitContainer3"; - this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer3.Panel1 - // - this.splitContainer3.Panel1.Controls.Add(this.codeView); - // - // splitContainer3.Panel2 - // - this.splitContainer3.Panel2.Controls.Add(this.tabControl3); - this.splitContainer3.Size = new System.Drawing.Size(726, 663); - this.splitContainer3.SplitterDistance = 446; - this.splitContainer3.TabIndex = 0; - // - // codeView - // - this.codeView.ActiveLine = -1; - this.codeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.codeView.CursorLine = 0; - this.codeView.Dock = System.Windows.Forms.DockStyle.Fill; - this.codeView.Font = new System.Drawing.Font("Consolas", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.codeView.ForeColor = System.Drawing.Color.Gainsboro; - this.codeView.Location = new System.Drawing.Point(0, 0); - this.codeView.Margin = new System.Windows.Forms.Padding(4); - this.codeView.Name = "codeView"; - this.codeView.Size = new System.Drawing.Size(726, 446); - this.codeView.SourceCode = null; - this.codeView.TabIndex = 1; - // - // tabControl3 - // - this.tabControl3.Controls.Add(this.tabPage5); - this.tabControl3.Controls.Add(this.tabPage6); - this.tabControl3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl3.Location = new System.Drawing.Point(0, 0); - this.tabControl3.Name = "tabControl3"; - this.tabControl3.SelectedIndex = 0; - this.tabControl3.Size = new System.Drawing.Size(726, 213); - this.tabControl3.TabIndex = 0; - // - // tabPage5 - // - this.tabPage5.Controls.Add(this.txtOutput); - this.tabPage5.Controls.Add(this.toolStrip5); - this.tabPage5.Location = new System.Drawing.Point(4, 22); - this.tabPage5.Name = "tabPage5"; - this.tabPage5.Padding = new System.Windows.Forms.Padding(3); - this.tabPage5.Size = new System.Drawing.Size(718, 187); - this.tabPage5.TabIndex = 0; - this.tabPage5.Text = "Output"; - this.tabPage5.UseVisualStyleBackColor = true; - // - // txtOutput - // - this.txtOutput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.txtOutput.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtOutput.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtOutput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); - this.txtOutput.Location = new System.Drawing.Point(3, 28); - this.txtOutput.Multiline = true; - this.txtOutput.Name = "txtOutput"; - this.txtOutput.ReadOnly = true; - this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtOutput.Size = new System.Drawing.Size(712, 156); - this.txtOutput.TabIndex = 3; - // - // toolStrip5 - // - this.toolStrip5.Location = new System.Drawing.Point(3, 3); - this.toolStrip5.Name = "toolStrip5"; - this.toolStrip5.Size = new System.Drawing.Size(712, 25); - this.toolStrip5.TabIndex = 2; - this.toolStrip5.Text = "toolStrip5"; - // - // tabPage6 - // - this.tabPage6.Controls.Add(this.txtCodeView); - this.tabPage6.Controls.Add(this.toolStrip6); - this.tabPage6.Location = new System.Drawing.Point(4, 22); - this.tabPage6.Name = "tabPage6"; - this.tabPage6.Padding = new System.Windows.Forms.Padding(3); - this.tabPage6.Size = new System.Drawing.Size(718, 187); - this.tabPage6.TabIndex = 1; - this.tabPage6.Text = "Code View"; - this.tabPage6.UseVisualStyleBackColor = true; - // - // txtCodeView - // - this.txtCodeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.txtCodeView.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtCodeView.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtCodeView.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); - this.txtCodeView.Location = new System.Drawing.Point(3, 28); - this.txtCodeView.Multiline = true; - this.txtCodeView.Name = "txtCodeView"; - this.txtCodeView.ReadOnly = true; - this.txtCodeView.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtCodeView.Size = new System.Drawing.Size(712, 156); - this.txtCodeView.TabIndex = 3; - // - // toolStrip6 - // - this.toolStrip6.Location = new System.Drawing.Point(3, 3); - this.toolStrip6.Name = "toolStrip6"; - this.toolStrip6.Size = new System.Drawing.Size(712, 25); - this.toolStrip6.TabIndex = 2; - this.toolStrip6.Text = "toolStrip6"; - // - // timerFollow - // - this.timerFollow.Interval = 15; - this.timerFollow.Tick += new System.EventHandler(this.timerFollow_Tick); - // - // btnOpenTest - // - this.btnOpenTest.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.btnOpenTest.Image = ((System.Drawing.Image)(resources.GetObject("btnOpenTest.Image"))); - this.btnOpenTest.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnOpenTest.Name = "btnOpenTest"; - this.btnOpenTest.Size = new System.Drawing.Size(106, 22); - this.btnOpenTest.Text = "Open Default Test"; - this.btnOpenTest.Click += new System.EventHandler(this.btnOpenTest_Click); - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1094, 734); - this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.toolStrip1); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "MainForm"; - this.Text = "MoonSharp Debugger"; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; - this.Load += new System.EventHandler(this.MainForm_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.ResumeLayout(false); - this.splitContainer2.Panel1.ResumeLayout(false); - this.splitContainer2.Panel2.ResumeLayout(false); - this.splitContainer2.ResumeLayout(false); - this.tabControl2.ResumeLayout(false); - this.tabPage3.ResumeLayout(false); - this.tabPage3.PerformLayout(); - this.toolStrip2.ResumeLayout(false); - this.toolStrip2.PerformLayout(); - this.tabPage4.ResumeLayout(false); - this.tabPage4.PerformLayout(); - this.toolStrip3.ResumeLayout(false); - this.toolStrip3.PerformLayout(); - this.tabControl1.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.tabPage1.PerformLayout(); - this.toolStrip4.ResumeLayout(false); - this.toolStrip4.PerformLayout(); - this.tabPage2.ResumeLayout(false); - this.splitContainer3.Panel1.ResumeLayout(false); - this.splitContainer3.Panel2.ResumeLayout(false); - this.splitContainer3.ResumeLayout(false); - this.tabControl3.ResumeLayout(false); - this.tabPage5.ResumeLayout(false); - this.tabPage5.PerformLayout(); - this.tabPage6.ResumeLayout(false); - this.tabPage6.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStrip toolStrip1; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.SplitContainer splitContainer2; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stepOverToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stepInToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; - private System.Windows.Forms.ToolStripMenuItem toggleBreakpointToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3; - private System.Windows.Forms.ToolStripMenuItem gOToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem scriptCodeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem bytecodeToolStripMenuItem; - private System.Windows.Forms.ToolStripButton toolStepIN; - private System.Windows.Forms.TabControl tabControl2; - private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.TabPage tabPage4; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ImageList imageList1; - private System.Windows.Forms.ToolStripButton btnOpenFile; - private System.Windows.Forms.ToolStripButton toolStripButton2; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripButton toolStripButton3; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripButton toolGO; - private System.Windows.Forms.ToolStripButton toolStepOver; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripButton toolStripButton5; - private System.Windows.Forms.ToolStripMenuItem connectToolStripMenuItem; - private DoubleBufferedListView lvWatches; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ToolStrip toolStrip2; - private System.Windows.Forms.ToolStripButton btnAddWatch; - private System.Windows.Forms.ToolStripButton btnRemoveWatch; - private System.Windows.Forms.ToolStripButton btnViewWatch; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.SplitContainer splitContainer3; - private SourceCodeDebugControl codeView; - private DoubleBufferedListView lvVStack; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ToolStrip toolStrip3; - private System.Windows.Forms.ToolStripButton btnViewVStk; - private System.Windows.Forms.ToolStripButton toolGoToCodeWatches; - private System.Windows.Forms.ToolStripButton toolGoToCodeVStack; - private DoubleBufferedListView lvCallStack; - private System.Windows.Forms.ColumnHeader colAddress; - private System.Windows.Forms.ColumnHeader colName; - private System.Windows.Forms.ColumnHeader colReturn; - private System.Windows.Forms.ColumnHeader colBP; - private System.Windows.Forms.ToolStrip toolStrip4; - private System.Windows.Forms.ToolStripButton toolGoToCodeXStack; - private System.Windows.Forms.ToolStripButton btnFollow; - private System.Windows.Forms.Timer timerFollow; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; - private System.Windows.Forms.ToolStripButton btnFastHack; - private System.Windows.Forms.TabControl tabControl3; - private System.Windows.Forms.TabPage tabPage5; - private System.Windows.Forms.TextBox txtOutput; - private System.Windows.Forms.ToolStrip toolStrip5; - private System.Windows.Forms.TabPage tabPage6; - private System.Windows.Forms.TextBox txtCodeView; - private System.Windows.Forms.ToolStrip toolStrip6; - private System.Windows.Forms.ToolStripButton btnOpenTest; - - - } -} - diff --git a/src/DevTools/MoonSharp.VmDebugger/MainForm.cs b/src/DevTools/MoonSharp.VmDebugger/MainForm.cs deleted file mode 100644 index fae87cab..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/MainForm.cs +++ /dev/null @@ -1,454 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Windows.Forms; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.CoreLib; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; -using MoonSharp.Interpreter.Loaders; - -namespace MoonSharp.Debugger -{ - public partial class MainForm : Form, IDebugger - { - List m_Watches = new List(); - - public MainForm() - { - InitializeComponent(); - } - - private void MainForm_Load(object sender, EventArgs e) - { - m_Ctx = SynchronizationContext.Current; - Script.WarmUp(); - //Script.DefaultOptions.TailCallOptimizationThreshold = 1; - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Title = "Load script"; - ofd.DefaultExt = "lua"; - ofd.Filter = "Lua files (*.lua)|*.lua|All files (*.*)|*.*"; - - if (ofd.ShowDialog() == DialogResult.OK) - { - DebugScript(ofd.FileName); - openToolStripMenuItem.Enabled = false; - } - } - - Script m_Script; - SynchronizationContext m_Ctx; - - private void Console_WriteLine(string fmt, params object[] args) - { - fmt = string.Format(fmt, args); - - m_Ctx.Post(str => - { - txtOutput.Text = txtOutput.Text + fmt.ToString().Replace("\n", "\r\n") + "\r\n"; - txtOutput.SelectionStart = txtOutput.Text.Length - 1; - txtOutput.SelectionLength = 0; - txtOutput.ScrollToCaret(); - }, fmt); - } - - - private void DebugScript(string filename) - { - m_Script = new Script(CoreModules.Basic | CoreModules.Table | CoreModules.TableIterators | CoreModules.Metatables); - // m_Script.Options.UseLuaErrorLocations = true; - m_Script.Options.DebugPrint = s => { Console_WriteLine("{0}", s); }; - - // ((ScriptLoaderBase)m_Script.Options.ScriptLoader).ModulePaths = ScriptLoaderBase.UnpackStringPaths("Modules/?;Modules/?.lua"); - - DynValue fn; - - try - { - fn = m_Script.LoadFile(filename, null, filename.Replace(':', '|')); - } - catch (Exception ex) - { - txtOutput.Text = ""; - Console_WriteLine("{0}", ex.Message); - return; - } - - m_Script.AttachDebugger(this); - - Thread m_Debugger = new Thread(() => DebugMain(fn)); - m_Debugger.Name = "MoonSharp Execution Thread"; - m_Debugger.IsBackground = true; - m_Debugger.Start(); - } - - - - public void SetSourceCode(SourceCode sourceCode) - { - } - - void IDebugger.SetByteCode(string[] byteCode) - { - string[] source = byteCode.Select((s, i) => string.Format("{0:X8} {1}", i, s)).ToArray(); - - m_Ctx.Send(o => - { - codeView.SourceCode = source; - }, null); - } - - DebuggerAction m_NextAction; - AutoResetEvent m_WaitLock = new AutoResetEvent(false); - AutoResetEvent m_WaitBack = new AutoResetEvent(false); - - DebuggerAction IDebugger.GetAction(int ip, SourceRef sourceCodeRef) - { - m_Ctx.Post(o => - { - codeView.ActiveLine = ip; - RefreshCodeView(sourceCodeRef); - }, null); - - m_WaitLock.WaitOne(); - - DebuggerAction action = m_NextAction; - m_NextAction = null; - - m_WaitBack.Set(); - - return action; - } - - SourceRef m_PrevRef = null; - - private void RefreshCodeView(SourceRef sourceCodeRef) - { - if (sourceCodeRef == m_PrevRef) - return; - - m_PrevRef = sourceCodeRef; - - if (sourceCodeRef == null) - { - txtCodeView.Text = "!! NULL !!"; - } - else - { - SourceCode sc = m_Script.GetSourceCode(sourceCodeRef.SourceIdx); - //txtCodeView.Text = sc.Lines[sourceCodeRef.FromLine + 1] + "\n" + - // sourceCodeRef.ToString(); - txtCodeView.Text = sc.GetCodeSnippet(sourceCodeRef) + "\r\n\r\n" + sourceCodeRef.ToString(); - } - } - - void DebugAction(DebuggerAction action) - { - bool savedState = timerFollow.Enabled; - timerFollow.Enabled = false; - - m_NextAction = action; - m_WaitLock.Set(); - - if (!m_WaitBack.WaitOne(1000)) - { - MessageBox.Show(this, "Operation timed out", "Timeout"); - } - else - { - timerFollow.Enabled = savedState; - } - } - - - void DebugMain(DynValue fn) - { - try - { - fn.Function.Call(); - } - catch (ScriptRuntimeException ex) - { - timerFollow.Enabled = false; - Console_WriteLine("Guest raised unhandled CLR exception: {0} -@{3:X8} {2}\n{1}\n", ex.GetType(), ex.ToString(), ex.DecoratedMessage, ex.InstructionPtr); - } - catch (Exception ex) - { - timerFollow.Enabled = false; - Console_WriteLine("Guest raised unhandled CLR exception: {0} \n{1}\n", ex.GetType(), ex.ToString()); - } - } - - private void StepIN() - { - DebugAction(new DebuggerAction() { Action = DebuggerAction.ActionType.ByteCodeStepIn }); - } - - private void StepOVER() - { - DebugAction(new DebuggerAction() { Action = DebuggerAction.ActionType.ByteCodeStepOver }); - } - - private void GO() - { - DebugAction(new DebuggerAction() { Action = DebuggerAction.ActionType.Run }); - } - - - void IDebugger.Update(WatchType watchType, IEnumerable items) - { - if (watchType == WatchType.CallStack) - m_Ctx.Post(UpdateCallStack, items); - if (watchType == WatchType.Watches) - m_Ctx.Post(UpdateWatches, items); - if (watchType == WatchType.VStack) - m_Ctx.Post(UpdateVStack, items); - } - void UpdateVStack(object o) - { - IEnumerable items = (IEnumerable)o; - - lvVStack.BeginUpdate(); - lvVStack.Items.Clear(); - - foreach (var item in items) - { - lvVStack.Add( - item.Address.ToString("X4"), - (item.Value != null) ? item.Value.Type.ToString() : "(undefined)", - (item.Value != null) ? item.Value.ToString() : "(undefined)" - ).Tag = item.Value; - } - - lvVStack.EndUpdate(); - - } - - - void UpdateWatches(object o) - { - IEnumerable items = (IEnumerable)o; - - lvWatches.BeginUpdate(); - lvWatches.Items.Clear(); - - foreach (var item in items) - { - lvWatches.Add( - item.Name ?? "(???)", - (item.Value != null) ? item.Value.Type.ToLuaTypeString() : "(undefined)", - (item.Value != null) ? item.Value.ToString() : "(undefined)", - (item.LValue != null) ? item.LValue.ToString() : "(undefined)" - ).Tag = item.Value; - } - - lvWatches.EndUpdate(); - - } - - void UpdateCallStack(object o) - { - IEnumerable items = (IEnumerable)o; - - lvCallStack.BeginUpdate(); - lvCallStack.Items.Clear(); - foreach (var item in items) - { - lvCallStack.Add( - item.Address.ToString("X8"), - item.Name ?? ((item.RetAddress < 0) ? "" : ""), - item.RetAddress.ToString("X8"), - item.BasePtr.ToString("X8") - ).Tag = item.Address; - } - - lvCallStack.Add("---", "", "---", "---"); - - lvCallStack.EndUpdate(); - } - - - - - List IDebugger.GetWatchItems() - { - return m_Watches; - } - - private void btnAddWatch_Click(object sender, EventArgs e) - { - string text = WatchInputDialog.GetNewWatchName(); - - if (!string.IsNullOrEmpty(text)) - { - string[] codeToAdd = text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - - m_Watches.AddRange(codeToAdd.Select(code => m_Script.CreateDynamicExpression(code))); - DebugAction(new DebuggerAction() { Action = DebuggerAction.ActionType.Refresh }); - } - } - - private void btnRemoveWatch_Click(object sender, EventArgs e) - { - HashSet itemsToRemove = new HashSet(lvWatches.SelectedItems.OfType().Select(lvi => lvi.Text)); - - int i = m_Watches.RemoveAll(w => itemsToRemove.Contains(w.ExpressionCode)); - - if (i != 0) - DebugAction(new DebuggerAction() { Action = DebuggerAction.ActionType.Refresh }); - } - private void stepInToolStripMenuItem_Click(object sender, EventArgs e) - { - StepIN(); - } - - private void btnOpenFile_Click(object sender, EventArgs e) - { - openToolStripMenuItem.PerformClick(); - } - - private void stepOverToolStripMenuItem_Click(object sender, EventArgs e) - { - StepOVER(); - } - - private void toolGO_Click(object sender, EventArgs e) - { - GO(); - } - - private void gOToolStripMenuItem_Click(object sender, EventArgs e) - { - GO(); - } - private void toolStripButton1_Click(object sender, EventArgs e) - { - StepIN(); - } - - private void toolStepOver_Click(object sender, EventArgs e) - { - StepOVER(); - } - - private void btnViewVStk_Click(object sender, EventArgs e) - { - ValueBrowser.StartBrowse(lvVStack.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault()); - } - - private void lvVStack_MouseDoubleClick(object sender, MouseEventArgs e) - { - ValueBrowser.StartBrowse(lvVStack.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault()); - } - - private void btnViewWatch_Click(object sender, EventArgs e) - { - ValueBrowser.StartBrowse(lvWatches.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault()); - } - - - private void lvWatches_MouseDoubleClick(object sender, MouseEventArgs e) - { - ValueBrowser.StartBrowse(lvWatches.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault()); - } - - private void toolGoToCodeVStack_Click(object sender, EventArgs e) - { - var v = lvVStack.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault(); - - if (v != null && v.Type == DataType.Function) - GotoBytecode(v.Function.EntryPointByteCodeLocation); - } - - private void toolGoToCodeWatches_Click(object sender, EventArgs e) - { - var v = lvWatches.SelectedItems.OfType().Select(lvi => lvi.Tag).Cast().FirstOrDefault(); - - if (v != null && v.Type == DataType.Function) - GotoBytecode(v.Function.EntryPointByteCodeLocation); - } - private void toolGoToCodeXStack_Click(object sender, EventArgs e) - { - var v = lvCallStack.SelectedItems.OfType().Select(lvi => lvi.Tag).OfType().FirstOrDefault(); - - if (v != 0) - GotoBytecode(v); - } - - private void GotoBytecode(int code) - { - codeView.CursorLine = code; - } - - private void timerFollow_Tick(object sender, EventArgs e) - { - toolStepIN.PerformClick(); - } - - private void btnFollow_Click(object sender, EventArgs e) - { - timerFollow.Start(); - } - - private void btnFastHack_Click(object sender, EventArgs e) - { - DebugScript(@"C:\temp\test.lua"); - } - - - - - void IDebugger.SetSourceCode(SourceCode sourceCode) - { - - } - - bool IDebugger.IsPauseRequested() - { - return false; - } - - - public void SignalExecutionEnded() - { - } - - - public void RefreshBreakpoints(IEnumerable refs) - { - } - - - public bool SignalRuntimeException(ScriptRuntimeException ex) - { - Console_WriteLine("Error: {0}", ex.DecoratedMessage); - return true; - } - - private void btnOpenTest_Click(object sender, EventArgs e) - { - - } - - public void SetDebugService(DebugService debugService) - { - } - - public DebuggerCaps GetDebuggerCaps() - { - return DebuggerCaps.CanDebugByteCode; - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/MainForm.resx b/src/DevTools/MoonSharp.VmDebugger/MainForm.resx deleted file mode 100644 index 210145a5..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/MainForm.resx +++ /dev/null @@ -1,277 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 132, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - - 237, 17 - - - 463, 17 - - - 568, 17 - - - 353, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACe - DQAAAk1TRnQBSQFMAgEBBAEAAXABAQFwAQEBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABIAMAAQEBAAEgBgABIP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AIgADDAEQA1kBvwP2 - Af8D9gH/A1kBvwMqAUADKgFAAyoBQAMqAUADKgFAAyoBQAMqAUADKgFAAyoBQAMqAUADKgFAEAAD9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/5AAA1kBvwOcAf8DFAH/AxQB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/xAAA/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wP2Af+QAAP2Af8DFAH/AxQB/wMUAf8D9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMU - Af8DFAH/AxQB/wP2Af8QAAP2Af8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/FAAD9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8cAAP2Af8D9gH/A/YB/wP2Af8D9gH/CAADIQEwAyEBMAQA - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/AxQB/wMUAf8DFAH/A/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/EAAD9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/xQA - A/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/HAAD9gH/AxQB/wMUAf8DFAH/A/YB/wQA - AyEBMANiAe8DYgHvAyEBMAP2Af8DFAH/AxQB/wMUAf8D9gH/A/YB/wMUAf8D9gH/A/YB/wP2Af8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wgAA/YB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/DAAD9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wP2Af8cAAP2Af8DFAH/A/YB/wP2Af8D9gH/AyEBMANiAe8DhgH/AzYB/wNiAe8D9gH/A/YB/wP2 - Af8DFAH/A/YB/wP2Af8DFAH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8IAAP2Af8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - A/YB/wwAA/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8UAAP2Af8DFAH/ - A/YB/wQAAyEBMAM6AWADYgHvA4YB/wMUAf8DNgH/A2IB7wMhATAD9gH/AxQB/wP2Af8D9gH/AxQB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/CAAD9gH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wP2Af8UAAP2Af8DFAH/AxQB/wMU - Af8DFAH/AxQB/wMUAf8DFAH/A/YB/xQAA/YB/wMUAf8D9gH/AyEBMANiAe8DYgHvAzoBYANiAe8DhgH/ - AzYB/wNiAe8DIQEwA/YB/wMUAf8D9gH/A/YB/wMUAf8D9gH/A/YB/wP2Af8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wgAA/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/FAAD9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wP2Af8UAAP2 - Af8DFAH/A/YB/wNiAe8DhgH/AzYB/wNiAe8DOgFgA2IB7wP2Af8DYgHvAyEBMAP2Af8DFAH/A/YB/wP2 - Af8DFAH/AxQB/wMUAf8D9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wP2 - Af8MAAP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8YAAP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wgAA/YB/wMUAf8D9gH/A4YB/wMUAf8DFAH/ - AzYB/wNiAe8DYgHvA4YB/wM2Af8DYgHvA/YB/wMUAf8D9gH/A/YB/wMUAf8DFAH/AxQB/wP2Af8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wwAA/YB/wMUAf8DFAH/AxQB/wMU - Af8DFAH/AxQB/wMUAf8DFAH/A/YB/xgAA/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wMUAf8DFAH/ - AxQB/wMUAf8D9gH/CAAD9gH/AxQB/wP2Af8DhgH/AxQB/wMUAf8DFAH/AzYB/wPrAf8DhgH/AxQB/wM2 - Af8D9gH/AxQB/wP2Af8DWQG/A5wB/wMUAf8DFAH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/DAAD9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/ - GAAD9gH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/AxQB/wMUAf8DFAH/AxQB/wP2Af8IAAP2Af8DFAH/ - A/YB/wNiAe8DhgH/AxQB/wMUAf8DNgH/A2IB7wNiAe8DhgH/AzYB/wP2Af8DFAH/A/YB/wMMARAD9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8MAAP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8QAAP2Af8D9gH/A/YB/wP2Af8D9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/CAAD9gH/AxQB/wP2Af8DIQEwA2IB7wOG - Af8DNgH/A2IB7wMhATADIQEwA2IB7wNcAd8D9gH/AxQB/wP2Af8EAAP2Af8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8EAAP2Af8DFAH/AxQB/wMU - Af8DFAH/AxQB/wP2Af8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/CAAD9gH/AxQB/wP2Af8D9gH/ - A/YB/wNiAe8DYgHvAyEBMAgAA/YB/wP2Af8D9gH/AxQB/wP2Af8EAAP2Af8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wP2Af8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wP2Af8EAAP2Af8DFAH/AxQB/wMU - Af8DFAH/AxQB/wP2Af8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/CAAD9gH/AxQB/wMUAf8DFAH/ - A/YB/wMhATADIQEwDAAD9gH/AxQB/wMUAf8DFAH/A/YB/wQAA/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8D9gH/A/YB/wMUAf8DFAH/AxQB/wMUAf8DFAH/ - AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/AxQB/wMUAf8DFAH/A/YB/wQAA/YB/wP2Af8D9gH/A/YB/wP2 - Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8IAAP2Af8D9gH/A/YB/wP2Af8D9gH/ - FAAD9gH/A/YB/wP2Af8D9gH/A/YB/wQAA/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/ - A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/4AAAUIBTQE+BwABPgMAASgDAAFAAwABIAMAAQEBAAEB - BgABARYAA/+DAAHwAQ8E/wIAAfABDwT/AgAB8AEPAYABPwGDASACAAHwAQ8BgAE/AYIDAAHAAQMBgAE/ - AYADAAHAAQMBgAEPAYgDAAHAAQMB4AEPAYADAAHAAQMB4AEPAYADAAHgAQcB4AEBAYADAAHgAQcB4AEB - AYADAAHgAQcB4AEBAYADAAHgAQcBgAEBAYABAAGAAwABgAEBAYABYAGAAwABgAEBAYAB4AGAAwABgAEB - AYMB4AGAAwAE/ws= - - - - 673, 17 - - - 463, 17 - - - 568, 17 - - - 673, 17 - - - 999, 17 - - - 999, 17 - - - 1104, 17 - - - 1104, 17 - - - 778, 17 - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/MoonSharp.VmDebugger.csproj b/src/DevTools/MoonSharp.VmDebugger/MoonSharp.VmDebugger.csproj deleted file mode 100644 index fb709571..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/MoonSharp.VmDebugger.csproj +++ /dev/null @@ -1,244 +0,0 @@ - - - - - Debug - AnyCPU - {F4F82CCE-2E13-441B-939C-63CF2343B1C9} - WinExe - Properties - MoonSharp.Debugger - MoonSharp.VmDebugger - v3.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Dev\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Dev\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Devp4\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - - - - - - - - - - - - Component - - - - Form - - - MainForm.cs - - - - - UserControl - - - SourceCodeDebugControl.cs - - - Form - - - ValueBrowser.cs - - - Form - - - WatchInputDialog.cs - - - MainForm.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SourceCodeDebugControl.cs - - - ValueBrowser.cs - - - WatchInputDialog.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - Always - - - Always - - - - - {4ad350e6-e296-43ef-9fea-cb70358467e4} - MoonSharp.Interpreter.Tests.net35-client - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/Program.cs b/src/DevTools/MoonSharp.VmDebugger/Program.cs deleted file mode 100644 index 8ce4efce..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; - -namespace MoonSharp.Debugger -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MainForm()); - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/Properties/AssemblyInfo.cs b/src/DevTools/MoonSharp.VmDebugger/Properties/AssemblyInfo.cs deleted file mode 100644 index bca4376d..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Debugger")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Debugger")] -[assembly: AssemblyCopyright("Copyright © 2014-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("43c6203a-fd70-44f6-bdd9-30588e7c9733")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.Designer.cs deleted file mode 100644 index 307264ab..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.Designer.cs +++ /dev/null @@ -1,243 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace MoonSharp.Debugger.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MoonSharp.Debugger.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap AddConnection_477 { - get { - object obj = ResourceManager.GetObject("AddConnection_477", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap AddMark_10580 { - get { - object obj = ResourceManager.GetObject("AddMark_10580", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Breakall_6323 { - get { - object obj = ResourceManager.GetObject("Breakall_6323", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap BreakpointEnabled_6584_16x { - get { - object obj = ResourceManager.GetObject("BreakpointEnabled_6584_16x", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Clearallrequests_8816 { - get { - object obj = ResourceManager.GetObject("Clearallrequests_8816", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DisassemblyWindow_6536 { - get { - object obj = ResourceManager.GetObject("DisassemblyWindow_6536", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap FindSymbol_6263 { - get { - object obj = ResourceManager.GetObject("FindSymbol_6263", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap GoToDeclaration_5576 { - get { - object obj = ResourceManager.GetObject("GoToDeclaration_5576", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Help_6522 { - get { - object obj = ResourceManager.GetObject("Help_6522", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap NavigateBackwards_6270 { - get { - object obj = ResourceManager.GetObject("NavigateBackwards_6270", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap NavigateForward_6271 { - get { - object obj = ResourceManager.GetObject("NavigateForward_6271", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Open_6529 { - get { - object obj = ResourceManager.GetObject("Open_6529", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Restart_6322 { - get { - object obj = ResourceManager.GetObject("Restart_6322", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap RPCThread_10388 { - get { - object obj = ResourceManager.GetObject("RPCThread_10388", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap startwithoutdebugging_6556 { - get { - object obj = ResourceManager.GetObject("startwithoutdebugging_6556", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap StepIn_6326 { - get { - object obj = ResourceManager.GetObject("StepIn_6326", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap Stepout_6327 { - get { - object obj = ResourceManager.GetObject("Stepout_6327", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap StepOver_6328 { - get { - object obj = ResourceManager.GetObject("StepOver_6328", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.resx b/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.resx deleted file mode 100644 index ad9d9d28..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Properties/Resources.resx +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\FindSymbol_6263.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\StepIn_6326.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Stepout_6327.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Restart_6322.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\StepOver_6328.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\NavigateForward_6271.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Open_6529.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\DisassemblyWindow_6536.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\AddMark_10580.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\RPCThread_10388.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\AddConnection_477.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\NavigateBackwards_6270.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\startwithoutdebugging_6556.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Help_6522.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\BreakpointEnabled_6584_16x.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Clearallrequests_8816.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\Breakall_6323.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - - ..\Resources\GoToDeclaration_5576.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.Designer.cs deleted file mode 100644 index e681535f..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace MoonSharp.Debugger.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.settings b/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.settings deleted file mode 100644 index 39645652..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/AddConnection_477.png b/src/DevTools/MoonSharp.VmDebugger/Resources/AddConnection_477.png deleted file mode 100644 index 3157b1ac..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/AddConnection_477.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/AddMark_10580.png b/src/DevTools/MoonSharp.VmDebugger/Resources/AddMark_10580.png deleted file mode 100644 index 8c41031c..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/AddMark_10580.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Breakall_6323.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Breakall_6323.png deleted file mode 100644 index 0fac7df8..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Breakall_6323.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/BreakpointEnabled_6584_16x.png b/src/DevTools/MoonSharp.VmDebugger/Resources/BreakpointEnabled_6584_16x.png deleted file mode 100644 index ecbaa45c..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/BreakpointEnabled_6584_16x.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Clearallrequests_8816.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Clearallrequests_8816.png deleted file mode 100644 index 4b6d6d4d..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Clearallrequests_8816.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/DisassemblyWindow_6536.png b/src/DevTools/MoonSharp.VmDebugger/Resources/DisassemblyWindow_6536.png deleted file mode 100644 index 0c26ff1e..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/DisassemblyWindow_6536.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/FindSymbol_6263.png b/src/DevTools/MoonSharp.VmDebugger/Resources/FindSymbol_6263.png deleted file mode 100644 index 89c98f79..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/FindSymbol_6263.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/GoToDeclaration_5576.png b/src/DevTools/MoonSharp.VmDebugger/Resources/GoToDeclaration_5576.png deleted file mode 100644 index fb5bcd2b..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/GoToDeclaration_5576.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Help_6522.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Help_6522.png deleted file mode 100644 index a9596992..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Help_6522.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateBackwards_6270.png b/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateBackwards_6270.png deleted file mode 100644 index bf879318..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateBackwards_6270.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateForward_6271.png b/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateForward_6271.png deleted file mode 100644 index 52ceb0df..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/NavigateForward_6271.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Open_6529.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Open_6529.png deleted file mode 100644 index 74822865..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Open_6529.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/RPCThread_10388.png b/src/DevTools/MoonSharp.VmDebugger/Resources/RPCThread_10388.png deleted file mode 100644 index 651ed08c..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/RPCThread_10388.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Restart_6322.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Restart_6322.png deleted file mode 100644 index d5a06ce7..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Restart_6322.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/StepIn_6326.png b/src/DevTools/MoonSharp.VmDebugger/Resources/StepIn_6326.png deleted file mode 100644 index 87fdcf9d..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/StepIn_6326.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/StepOver_6328.png b/src/DevTools/MoonSharp.VmDebugger/Resources/StepOver_6328.png deleted file mode 100644 index 7ff64259..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/StepOver_6328.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/Stepout_6327.png b/src/DevTools/MoonSharp.VmDebugger/Resources/Stepout_6327.png deleted file mode 100644 index 8ef5a65a..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/Stepout_6327.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/Resources/startwithoutdebugging_6556.png b/src/DevTools/MoonSharp.VmDebugger/Resources/startwithoutdebugging_6556.png deleted file mode 100644 index ed280eba..00000000 Binary files a/src/DevTools/MoonSharp.VmDebugger/Resources/startwithoutdebugging_6556.png and /dev/null differ diff --git a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.Designer.cs deleted file mode 100644 index 6d86e256..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.Designer.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace MoonSharp.Debugger -{ - partial class SourceCodeDebugControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.vertScroll = new System.Windows.Forms.VScrollBar(); - this.horizScroll = new System.Windows.Forms.HScrollBar(); - this.SuspendLayout(); - // - // vertScroll - // - this.vertScroll.Dock = System.Windows.Forms.DockStyle.Right; - this.vertScroll.Location = new System.Drawing.Point(939, 0); - this.vertScroll.Name = "vertScroll"; - this.vertScroll.Size = new System.Drawing.Size(17, 656); - this.vertScroll.TabIndex = 0; - this.vertScroll.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vertScroll_Scroll); - this.vertScroll.ValueChanged += new System.EventHandler(this.vertScroll_ValueChanged); - // - // horizScroll - // - this.horizScroll.Dock = System.Windows.Forms.DockStyle.Bottom; - this.horizScroll.Location = new System.Drawing.Point(0, 639); - this.horizScroll.Name = "horizScroll"; - this.horizScroll.Size = new System.Drawing.Size(939, 17); - this.horizScroll.TabIndex = 1; - this.horizScroll.Scroll += new System.Windows.Forms.ScrollEventHandler(this.horizScroll_Scroll); - this.horizScroll.ValueChanged += new System.EventHandler(this.horizScroll_ValueChanged); - // - // SourceCodeDebugControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.Controls.Add(this.horizScroll); - this.Controls.Add(this.vertScroll); - this.DoubleBuffered = true; - this.Font = new System.Drawing.Font("Consolas", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.ForeColor = System.Drawing.Color.Gainsboro; - this.Margin = new System.Windows.Forms.Padding(4); - this.Name = "SourceCodeDebugControl"; - this.Size = new System.Drawing.Size(956, 656); - this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.SourceCodeDebugControl_MouseClick); - this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.SourceCodeDebugControl_PreviewKeyDown); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.VScrollBar vertScroll; - private System.Windows.Forms.HScrollBar horizScroll; - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.cs b/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.cs deleted file mode 100644 index 987e2c3e..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace MoonSharp.Debugger -{ - public partial class SourceCodeDebugControl : UserControl - { - private string[] m_SourceCode; - private bool[] m_BreakPoints; - int m_Line = 0; - int m_XOffs = 0; - int m_ActiveLine = -1; - int m_CursorLine = 0; - Brush m_CursorBrush = new SolidBrush(Color.FromArgb(64, Color.White)); - - public int ActiveLine - { - get { return m_ActiveLine; } - set - { - m_CursorLine = m_ActiveLine = value; - ScrollToIncludeLine(m_ActiveLine); - Invalidate(); - } - } - - private void ScrollToIncludeLine(int line) - { - if (line == m_Line) - return; - - if (line < m_Line) - m_Line = line; - - if (line > m_Line + (this.GetHeight() / this.Font.Height)) - m_Line = line; - } - - private int GetHeight() - { - return this.Height - horizScroll.Height; - } - - public int CursorLine - { - get { return m_CursorLine; } - set { m_CursorLine = value; ScrollToIncludeLine(m_CursorLine); Invalidate(); } - } - - public SourceCodeDebugControl() - { - InitializeComponent(); - } - - public string[] SourceCode - { - get { return m_SourceCode; } - set - { - if (value == null) - { - m_SourceCode = null; - m_BreakPoints = null; - } - else - { - m_SourceCode = value.Select(s => s.Replace("\t", " ")).ToArray(); - m_BreakPoints = new bool[m_SourceCode.Length]; - } - - OnSourceCodeChanged(); - } - } - - private void OnSourceCodeChanged() - { - m_Line = 0; - - if (vertScroll != null) - { - vertScroll.Value = 0; - vertScroll.Maximum = (m_SourceCode != null) ? m_SourceCode.Length : 10; - horizScroll.Maximum = 300; - horizScroll.Value = 0; - m_CursorLine = 0; - m_ActiveLine = -1; - } - - Invalidate(); - } - - protected override bool DoubleBuffered - { - get { return true; } - set { base.DoubleBuffered = true; } - } - - protected override void OnPaintBackground(PaintEventArgs e) - { - } - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaintBackground(e); - - if (m_SourceCode == null) - return; - - int H = this.Font.Height; - int W = (int)e.Graphics.MeasureString("X", this.Font).Width; - int Y = 0; - - for (int i = m_Line; i < m_SourceCode.Length && H < this.GetHeight(); i++, Y += H) - { - if (m_ActiveLine == i) - { - e.Graphics.FillRectangle(Brushes.DarkCyan, 0, Y, Width, H); - } - - if (m_BreakPoints[i]) - { - e.Graphics.FillEllipse(Brushes.Red, 5, Y + 5, 10, 10); - e.Graphics.DrawEllipse(Pens.DarkRed, 5, Y + 5, 10, 10); -// e.Graphics.FillRectangle(Brushes.DarkRed, 0, Y, Width, H); - } - - if (i == m_CursorLine) - e.Graphics.FillRectangle(m_CursorBrush, -1, Y, Width + 1, H); - - if (m_ActiveLine == i) - { - e.Graphics.FillRectangle(Brushes.Aqua, 3, Y + 8, 14, 6); - e.Graphics.DrawRectangle(Pens.DarkBlue, 3, Y + 8, 14, 6); - } - - string str = m_SourceCode[i]; - - if (m_XOffs != 0) - { - if (m_XOffs >= str.Length) - continue; - else - str = str.Substring(m_XOffs); - } - - e.Graphics.DrawString(str, this.Font, Brushes.Gainsboro, 20, Y); - } - } - - private void vertScroll_Scroll(object sender, ScrollEventArgs e) - { - m_Line = Math.Min(m_SourceCode.Length - 1, Math.Max(0, e.NewValue)); - Invalidate(); - } - - private void vertScroll_ValueChanged(object sender, EventArgs e) - { - m_Line = Math.Min(m_SourceCode.Length - 1, Math.Max(0, vertScroll.Value)); - Invalidate(); - } - - private void horizScroll_Scroll(object sender, ScrollEventArgs e) - { - m_XOffs = horizScroll.Value; - Invalidate(); - } - - private void horizScroll_ValueChanged(object sender, EventArgs e) - { - m_XOffs = horizScroll.Value; - Invalidate(); - } - - public void SetBreakpoint(int i, bool val) - { - m_BreakPoints[i] = val; - } - - private void SourceCodeDebugControl_MouseClick(object sender, MouseEventArgs e) - { - int Y = e.Y / this.Font.Height; - - Y += m_Line; - - m_CursorLine = Y; - - Invalidate(); - } - - - private void SourceCodeDebugControl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Up) - m_CursorLine = Math.Max(0, m_CursorLine - 1); - if (e.KeyCode == Keys.Down) - m_CursorLine = Math.Min(m_SourceCode.Length - 1, m_CursorLine + 1); - if (e.KeyCode == Keys.F9) - m_BreakPoints[m_CursorLine] = !m_BreakPoints[m_CursorLine]; - - } - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.resx b/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.resx deleted file mode 100644 index 7080a7d1..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.Designer.cs deleted file mode 100644 index b3ff83d6..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.Designer.cs +++ /dev/null @@ -1,329 +0,0 @@ -namespace MoonSharp.Debugger -{ - partial class ValueBrowser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.toolBack = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.toolDigData = new System.Windows.Forms.ToolStripButton(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.lvProps = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.lvTableData = new System.Windows.Forms.ListView(); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.txtString = new System.Windows.Forms.TextBox(); - this.lblData = new System.Windows.Forms.Label(); - this.lvMetaTable = new System.Windows.Forms.ListView(); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.label4 = new System.Windows.Forms.Label(); - this.toolStrip1.SuspendLayout(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.splitContainer2.Panel1.SuspendLayout(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); - this.SuspendLayout(); - // - // toolStrip1 - // - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolBack, - this.toolStripSeparator1, - this.toolDigData}); - this.toolStrip1.Location = new System.Drawing.Point(0, 0); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(963, 25); - this.toolStrip1.TabIndex = 0; - this.toolStrip1.Text = "toolStrip1"; - // - // toolBack - // - this.toolBack.Enabled = false; - this.toolBack.Image = global::MoonSharp.Debugger.Properties.Resources.NavigateBackwards_6270; - this.toolBack.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolBack.Name = "toolBack"; - this.toolBack.Size = new System.Drawing.Size(52, 22); - this.toolBack.Text = "Back"; - this.toolBack.Click += new System.EventHandler(this.toolBack_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); - // - // toolDigData - // - this.toolDigData.Image = global::MoonSharp.Debugger.Properties.Resources.FindSymbol_6263; - this.toolDigData.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolDigData.Name = "toolDigData"; - this.toolDigData.Size = new System.Drawing.Size(79, 22); - this.toolDigData.Text = "View Data"; - this.toolDigData.Click += new System.EventHandler(this.toolDigData_Click); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 25); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.lvProps); - this.splitContainer1.Panel1.Controls.Add(this.label2); - this.splitContainer1.Panel1.Controls.Add(this.label1); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Size = new System.Drawing.Size(963, 647); - this.splitContainer1.SplitterDistance = 321; - this.splitContainer1.TabIndex = 1; - // - // lvProps - // - this.lvProps.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.lvProps.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvProps.FullRowSelect = true; - this.lvProps.GridLines = true; - this.lvProps.Location = new System.Drawing.Point(0, 17); - this.lvProps.MultiSelect = false; - this.lvProps.Name = "lvProps"; - this.lvProps.Size = new System.Drawing.Size(321, 630); - this.lvProps.TabIndex = 3; - this.lvProps.UseCompatibleStateImageBehavior = false; - this.lvProps.View = System.Windows.Forms.View.Details; - this.lvProps.SelectedIndexChanged += new System.EventHandler(this.lvProps_SelectedIndexChanged); - this.lvProps.DoubleClick += new System.EventHandler(this.lvAnyTable_DoubleClick); - // - // columnHeader1 - // - this.columnHeader1.Text = "Key"; - this.columnHeader1.Width = 122; - // - // columnHeader2 - // - this.columnHeader2.Text = "Value"; - this.columnHeader2.Width = 175; - // - // label2 - // - this.label2.BackColor = System.Drawing.SystemColors.ActiveCaption; - this.label2.Dock = System.Windows.Forms.DockStyle.Top; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.label2.Location = new System.Drawing.Point(0, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(321, 17); - this.label2.TabIndex = 1; - this.label2.Text = "PROPERTIES"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(48, 90); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(0, 13); - this.label1.TabIndex = 0; - // - // splitContainer2 - // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer2.Panel1 - // - this.splitContainer2.Panel1.Controls.Add(this.lvTableData); - this.splitContainer2.Panel1.Controls.Add(this.txtString); - this.splitContainer2.Panel1.Controls.Add(this.lblData); - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.Controls.Add(this.lvMetaTable); - this.splitContainer2.Panel2.Controls.Add(this.label4); - this.splitContainer2.Size = new System.Drawing.Size(638, 647); - this.splitContainer2.SplitterDistance = 290; - this.splitContainer2.TabIndex = 0; - // - // lvTableData - // - this.lvTableData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader3, - this.columnHeader4}); - this.lvTableData.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvTableData.FullRowSelect = true; - this.lvTableData.GridLines = true; - this.lvTableData.Location = new System.Drawing.Point(0, 17); - this.lvTableData.MultiSelect = false; - this.lvTableData.Name = "lvTableData"; - this.lvTableData.Size = new System.Drawing.Size(638, 273); - this.lvTableData.TabIndex = 6; - this.lvTableData.UseCompatibleStateImageBehavior = false; - this.lvTableData.View = System.Windows.Forms.View.Details; - this.lvTableData.SelectedIndexChanged += new System.EventHandler(this.lvTableData_SelectedIndexChanged); - this.lvTableData.DoubleClick += new System.EventHandler(this.lvAnyTable_DoubleClick); - // - // columnHeader3 - // - this.columnHeader3.Text = "Key"; - this.columnHeader3.Width = 260; - // - // columnHeader4 - // - this.columnHeader4.Text = "Value"; - this.columnHeader4.Width = 260; - // - // txtString - // - this.txtString.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtString.Location = new System.Drawing.Point(0, 17); - this.txtString.Multiline = true; - this.txtString.Name = "txtString"; - this.txtString.ReadOnly = true; - this.txtString.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtString.Size = new System.Drawing.Size(638, 273); - this.txtString.TabIndex = 5; - // - // lblData - // - this.lblData.BackColor = System.Drawing.SystemColors.ActiveCaption; - this.lblData.Dock = System.Windows.Forms.DockStyle.Top; - this.lblData.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblData.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.lblData.Location = new System.Drawing.Point(0, 0); - this.lblData.Name = "lblData"; - this.lblData.Size = new System.Drawing.Size(638, 17); - this.lblData.TabIndex = 2; - this.lblData.Text = "DATA"; - this.lblData.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lvMetaTable - // - this.lvMetaTable.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader5, - this.columnHeader6}); - this.lvMetaTable.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvMetaTable.FullRowSelect = true; - this.lvMetaTable.GridLines = true; - this.lvMetaTable.Location = new System.Drawing.Point(0, 17); - this.lvMetaTable.MultiSelect = false; - this.lvMetaTable.Name = "lvMetaTable"; - this.lvMetaTable.Size = new System.Drawing.Size(638, 336); - this.lvMetaTable.TabIndex = 4; - this.lvMetaTable.UseCompatibleStateImageBehavior = false; - this.lvMetaTable.View = System.Windows.Forms.View.Details; - this.lvMetaTable.SelectedIndexChanged += new System.EventHandler(this.lvMetaTable_SelectedIndexChanged); - this.lvMetaTable.DoubleClick += new System.EventHandler(this.lvAnyTable_DoubleClick); - // - // columnHeader5 - // - this.columnHeader5.Text = "Key"; - this.columnHeader5.Width = 260; - // - // columnHeader6 - // - this.columnHeader6.Text = "Value"; - this.columnHeader6.Width = 260; - // - // label4 - // - this.label4.BackColor = System.Drawing.SystemColors.ActiveCaption; - this.label4.Dock = System.Windows.Forms.DockStyle.Top; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.label4.Location = new System.Drawing.Point(0, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(638, 17); - this.label4.TabIndex = 2; - this.label4.Text = "METATABLE"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // ValueBrowser - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(963, 672); - this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.toolStrip1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ValueBrowser"; - this.Text = "MoonSharp Value Browser"; - this.Load += new System.EventHandler(this.ValueBrowser_Load); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel1.PerformLayout(); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.ResumeLayout(false); - this.splitContainer2.Panel1.ResumeLayout(false); - this.splitContainer2.Panel1.PerformLayout(); - this.splitContainer2.Panel2.ResumeLayout(false); - this.splitContainer2.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ToolStrip toolStrip1; - private System.Windows.Forms.ToolStripButton toolBack; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripButton toolDigData; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ListView lvProps; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.SplitContainer splitContainer2; - private System.Windows.Forms.Label lblData; - private System.Windows.Forms.ListView lvMetaTable; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox txtString; - private System.Windows.Forms.ListView lvTableData; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader4; - } -} \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.cs b/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.cs deleted file mode 100644 index 5e47cc5c..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.cs +++ /dev/null @@ -1,226 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using MoonSharp.Interpreter; - -namespace MoonSharp.Debugger -{ - public partial class ValueBrowser : Form - { - Stack m_ValueStack = new Stack(); - public static void StartBrowse(DynValue v) - { - if (v == null) - return; - - ValueBrowser b = new ValueBrowser(); - b.m_ValueStack.Push(v); - b.ShowDialog(); - } - - public ValueBrowser() - { - InitializeComponent(); - } - - private void ValueBrowser_Load(object sender, EventArgs e) - { - InvalidateData(); - } - - private void InvalidateData() - { - DynValue V = m_ValueStack.Peek(); - toolBack.Enabled = (m_ValueStack.Count > 1); - - lvMetaTable.BeginUpdate(); - lvProps.BeginUpdate(); - lvTableData.BeginUpdate(); - - lvMetaTable.Items.Clear(); - lvProps.Items.Clear(); - txtString.Text = ""; - lvTableData.Items.Clear(); - lblData.Text = "VALUE"; - lvTableData.Visible = false; - txtString.Visible = false; - - AddProperty("Ref ID#", V.ReferenceID.ToString("X8")); - AddProperty("Read Only", V.ReadOnly); - AddProperty("VM Type", V.Type); - - switch (V.Type) - { - case DataType.Nil: - txtString.Visible = true; - txtString.Text = "Value is nil"; - break; - case DataType.Boolean: - txtString.Visible = true; - txtString.Text = V.Boolean.ToString(); - break; - case DataType.Number: - txtString.Visible = true; - txtString.Text = V.Boolean.ToString(); - break; - case DataType.String: - txtString.Visible = true; - txtString.Text = V.String.ToString(); - AddProperty("Raw Length", V.GetLength()); - break; - case DataType.Function: - lvTableData.Visible = true; - lblData.Text = "CLOSURE SCOPE"; - BuildFunctionTable(V); - break; - case DataType.Table: - lvTableData.Visible = true; - lblData.Text = "TABLE CONTENTS"; - AddProperty("Raw Length", V.GetLength()); - BuildTableTable(lvTableData, V); - break; - case DataType.Tuple: - lvTableData.Visible = true; - lblData.Text = "TUPLE"; - AddProperty("Count", V.Tuple.Length); - BuildTupleTable(V); - break; - case DataType.ClrFunction: - txtString.Visible = true; - txtString.Text = "Value is a CLR function."; - break; - case DataType.UserData: - txtString.Visible = true; - txtString.Text = "Value is a CLR object (userdata)."; - break; - case DataType.Thread: - txtString.Visible = true; - txtString.Text = "Value is a coroutine."; - break; - default: - break; - } - - Colorize(lvMetaTable); - Colorize(lvProps); - Colorize(lvTableData); - - lvMetaTable.EndUpdate(); - lvProps.EndUpdate(); - lvTableData.EndUpdate(); - } - - private void Colorize(ListView lv) - { - foreach (ListViewItem lvi in lv.Items) - { - if (lvi.Tag is DynValue) - { - lvi.ForeColor = Color.Blue; - } - } - } - - - - private void BuildFunctionTable(DynValue V) - { - var F = V.Function; - lvProps.Add("Bytecode Location", F.EntryPointByteCodeLocation.ToString("X8")); - - for (int i = 0; i < F.GetUpvaluesCount(); i++) - { - lvTableData.Add(F.GetUpvalueName(i), F.GetUpvalue(i)).Tag = F.GetUpvalue(i); - } - } - - private void BuildTupleTable(DynValue V) - { - var T = V.Tuple; - - for (int i = 0; i < T.Length; i++) - { - lvTableData.Add(i.ToString(), T[i]).Tag = T[i]; - } - } - - private void BuildTableTable(ListView listView, DynValue V) - { - var T = V.Table; - - foreach (var kvp in T.Pairs) - { - listView.Add(kvp.Key, kvp.Value).Tag = kvp.Value; - } - } - - private void AddProperty(string p1, object p2) - { - lvProps.Add(p1, p2.ToString()); - } - - private void lvTableData_SelectedIndexChanged(object sender, EventArgs e) - { - lvMetaTable.SelectedIndices.Clear(); - lvProps.SelectedIndices.Clear(); - } - - private void lvMetaTable_SelectedIndexChanged(object sender, EventArgs e) - { - lvTableData.SelectedIndices.Clear(); - lvProps.SelectedIndices.Clear(); - } - - private void lvProps_SelectedIndexChanged(object sender, EventArgs e) - { - lvTableData.SelectedIndices.Clear(); - lvMetaTable.SelectedIndices.Clear(); - } - - private void lvAnyTable_DoubleClick(object sender, EventArgs e) - { - DigData(sender as ListView); - } - - private void DigData(ListView listView) - { - if (listView == null) return; - ListViewItem lvi = listView.SelectedItems.OfType().FirstOrDefault(); - if (lvi == null) return; - - DynValue v = lvi.Tag as DynValue; - - if (v != null) - { - m_ValueStack.Push(v); - InvalidateData(); - } - } - - private void toolDigData_Click(object sender, EventArgs e) - { - ListView[] lvs = new ListView[] { lvMetaTable, lvTableData, lvProps }; - DigData(lvs.FirstOrDefault(lv => lv.SelectedItems.Count > 0)); - } - - private void toolBack_Click(object sender, EventArgs e) - { - m_ValueStack.Pop(); - InvalidateData(); - } - - - - - - - - - - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.resx b/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.resx deleted file mode 100644 index 061f9e8d..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/ValueBrowser.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.Designer.cs b/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.Designer.cs deleted file mode 100644 index fad85d33..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.Designer.cs +++ /dev/null @@ -1,102 +0,0 @@ -namespace MoonSharp.Debugger -{ - partial class WatchInputDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.txtWatch = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.btnOK = new System.Windows.Forms.Button(); - this.btnCancel = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // txtWatch - // - this.txtWatch.Location = new System.Drawing.Point(79, 15); - this.txtWatch.Name = "txtWatch"; - this.txtWatch.Size = new System.Drawing.Size(238, 20); - this.txtWatch.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 18); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(61, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Add watch:"; - // - // btnOK - // - this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOK.Location = new System.Drawing.Point(183, 51); - this.btnOK.Name = "btnOK"; - this.btnOK.Size = new System.Drawing.Size(64, 31); - this.btnOK.TabIndex = 2; - this.btnOK.Text = "OK"; - this.btnOK.UseVisualStyleBackColor = true; - // - // btnCancel - // - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(253, 51); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(64, 31); - this.btnCancel.TabIndex = 3; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - // - // WatchInputDialog - // - this.AcceptButton = this.btnOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(338, 98); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.btnOK); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtWatch); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "WatchInputDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Add new watch.."; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox txtWatch; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button btnOK; - private System.Windows.Forms.Button btnCancel; - } -} \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.cs b/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.cs deleted file mode 100644 index 3923ef84..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace MoonSharp.Debugger -{ - public partial class WatchInputDialog : Form - { - public WatchInputDialog() - { - InitializeComponent(); - } - - public static string GetNewWatchName() - { - WatchInputDialog dlg = new WatchInputDialog(); - var res = dlg.ShowDialog(); - - if (res == DialogResult.OK) - return dlg.txtWatch.Text; - - return null; - } - - - } -} diff --git a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.resx b/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.resx deleted file mode 100644 index 7080a7d1..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/MoonSharp.VmDebugger/packages.config b/src/DevTools/MoonSharp.VmDebugger/packages.config deleted file mode 100644 index 0816f446..00000000 --- a/src/DevTools/MoonSharp.VmDebugger/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/DevTools/MoonSharpSL5ReplDemo/App.xaml b/src/DevTools/MoonSharpSL5ReplDemo/App.xaml deleted file mode 100644 index 4e67d384..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/src/DevTools/MoonSharpSL5ReplDemo/App.xaml.cs b/src/DevTools/MoonSharpSL5ReplDemo/App.xaml.cs deleted file mode 100644 index aa145e71..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/App.xaml.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; - -namespace MoonSharpSL5ReplDemo -{ - public partial class App : Application - { - - public App() - { - this.Startup += this.Application_Startup; - this.Exit += this.Application_Exit; - this.UnhandledException += this.Application_UnhandledException; - - InitializeComponent(); - } - - private void Application_Startup(object sender, StartupEventArgs e) - { - this.RootVisual = new MainPage(); - } - - private void Application_Exit(object sender, EventArgs e) - { - - } - - private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - // If the app is running outside of the debugger then report the exception using - // the browser's exception mechanism. On IE this will display it a yellow alert - // icon in the status bar and Firefox will display a script error. - if (!System.Diagnostics.Debugger.IsAttached) - { - - // NOTE: This will allow the application to continue running after an exception has been thrown - // but not handled. - // For production applications this error handling should be replaced with something that will - // report the error to the website and stop the application. - e.Handled = true; - Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); - } - } - - private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) - { - try - { - string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; - errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); - - System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");"); - } - catch (Exception) - { - } - } - } -} diff --git a/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml b/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml deleted file mode 100644 index 954bf370..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml.cs b/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml.cs deleted file mode 100644 index 27dfba15..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/MainPage.xaml.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.REPL; - -namespace MoonSharpSL5ReplDemo -{ - public partial class MainPage : UserControl - { - Script script; - ReplHistoryInterpreter interpreter; - - public MainPage() - { - InitializeComponent(); - } - - private void UserControl_Loaded(object sender, RoutedEventArgs e) - { - Console_WriteLine("MoonSharp REPL {0} [{1}]", Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName()); - Console_WriteLine("Copyright (C) 2014-2015 Marco Mastropaolo"); - Console_WriteLine("http://www.moonsharp.org"); - Console_WriteLine(); - - Console_WriteLine("Type Lua code in the text box below to execute it."); - Console_WriteLine("The 'io', 'file' and parts of the 'os' modules are not available due to Silverlight restrictions."); - Console_WriteLine("Type list() or list() to see which globals are available."); - Console_WriteLine(); - Console_WriteLine("Welcome."); - Console_WriteLine(); - - script = new Script(CoreModules.Preset_Complete); - - script.DoString(@" -local function pad(str, len) - str = str .. ' ' .. string.rep('.', len); - str = string.sub(str, 1, len); - return str; -end - -function list(lib) - if (lib == nil) then lib = _G; end - - if (type(lib) ~= 'table') then - print('A table was expected to list command.'); - return - end - - for k, v in pairs(lib) do - print(pad(type(v), 12) .. ' ' .. k) - end -end"); - - script.Options.DebugPrint = s => Console_WriteLine(s); - - interpreter = new ReplHistoryInterpreter(script, 100) - { - HandleDynamicExprs = true, - HandleClassicExprsSyntax = true - }; - - - DoPrompt(); - } - - private void Console_WriteLine(string str = null) - { - txtOutput.Text += (str ?? "") + "\n"; - scroller.ScrollToVerticalOffset(scroller.ScrollableHeight); - scroller.UpdateLayout(); - } - - private void Console_WriteLine(string format, params object[] args) - { - string str = string.Format(format, args); - Console_WriteLine(str); - } - - private void DoPrompt() - { - lblPrompt.Text = interpreter.ClassicPrompt; - txtInput.Text = ""; - txtInput.Focus(); - } - - private void txtInput_KeyDown(object sender, KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - Console_WriteLine(lblPrompt.Text + " " + txtInput.Text); - - try - { - DynValue dv = interpreter.Evaluate(txtInput.Text); - - if (dv != null) - { - if (dv.Type == DataType.Void) - Console_WriteLine("ok"); - else - Console_WriteLine("{0}", dv); - } - } - catch (InterpreterException ex) - { - Console_WriteLine("{0}", ex.DecoratedMessage ?? ex.Message); - } - catch (Exception ex) - { - Console_WriteLine("Unexpected error: {0}", ex.Message); - } - - DoPrompt(); - } - else if (e.Key == Key.Up) - { - string v = interpreter.HistoryPrev(); - if (v != null) - { - txtInput.Text = v; - txtInput.Select(txtInput.Text.Length, 0); - } - } - else if (e.Key == Key.Down) - { - string v = interpreter.HistoryNext(); - if (v != null) - { - txtInput.Text = v; - txtInput.Select(txtInput.Text.Length, 0); - } - } - - } - - - - - } -} diff --git a/src/DevTools/MoonSharpSL5ReplDemo/MoonSharpSL5ReplDemo.csproj b/src/DevTools/MoonSharpSL5ReplDemo/MoonSharpSL5ReplDemo.csproj deleted file mode 100644 index 65ac061e..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/MoonSharpSL5ReplDemo.csproj +++ /dev/null @@ -1,151 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {69B110B4-E578-4854-8F63-D80E4E14E1B6} - {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - MoonSharpSL5ReplDemo - MoonSharpSL5ReplDemo - Silverlight - v5.0 - $(TargetFrameworkVersion) - true - - - true - true - MoonSharpSL5ReplDemo.xap - Properties\AppManifest.xml - MoonSharpSL5ReplDemo.App - MoonSharpSL5ReplDemoTestPage.html - true - true - false - Properties\OutOfBrowserSettings.xml - false - true - - - - - - v3.5 - - - true - full - false - Bin\Debug - DEBUG;TRACE;SILVERLIGHT - true - true - prompt - 4 - - - pdbonly - true - Bin\Release - TRACE;SILVERLIGHT - true - true - prompt - 4 - - - true - bin\Devp4\ - DEBUG;TRACE;SILVERLIGHT - true - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - true - - - - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\sl4\Microsoft.Threading.Tasks.dll - - - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\sl4\Microsoft.Threading.Tasks.Extensions.dll - - - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\sl4\Microsoft.Threading.Tasks.Extensions.Silverlight.dll - - - - ..\..\packages\Microsoft.Bcl.1.1.8\lib\sl5\System.IO.dll - - - ..\..\packages\Microsoft.Bcl.1.1.8\lib\sl5\System.Runtime.dll - - - ..\..\packages\Microsoft.Bcl.1.1.8\lib\sl5\System.Threading.Tasks.dll - - - - - $(TargetFrameworkDirectory)System.Core.dll - - - - - - - - App.xaml - - - MainPage.xaml - - - - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - - - - - {49f32476-fca0-45fd-8f89-0c7c0d15e409} - MoonSharp.Interpreter.portable40 - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/MoonSharpSL5ReplDemo/Properties/AppManifest.xml b/src/DevTools/MoonSharpSL5ReplDemo/Properties/AppManifest.xml deleted file mode 100644 index 6712a117..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/Properties/AppManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/src/DevTools/MoonSharpSL5ReplDemo/Properties/AssemblyInfo.cs b/src/DevTools/MoonSharpSL5ReplDemo/Properties/AssemblyInfo.cs deleted file mode 100644 index 4365a53b..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharpSL5ReplDemo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharpSL5ReplDemo")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("69b110b4-e578-4854-8f63-d80e4e14e1b6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/MoonSharpSL5ReplDemo/packages.config b/src/DevTools/MoonSharpSL5ReplDemo/packages.config deleted file mode 100644 index 445f1878..00000000 --- a/src/DevTools/MoonSharpSL5ReplDemo/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/.gitignore b/src/DevTools/Nuget_Tests/NugetTests_net35/.gitignore deleted file mode 100644 index 645266dd..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/.gitignore +++ /dev/null @@ -1,170 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ -bin-debug/ - - -# Remove generated docs - -src/MoonSharp.Documentation/Help/html/ -src/MoonSharp.Documentation/Help/toc/ -src/MoonSharp.Documentation/Help/fti/ -src/MoonSharp.Documentation/Help/styles/ -src/MoonSharp.Documentation/Help/icons/ -src/MoonSharp.Documentation/Help/ - -# - -# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets -!packages/*/build/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc -*.dll - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - - -#LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml - -# ========================= -# Windows detritus -# ========================= - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac desktop service store files -.DS_Store diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35.sln b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35.sln deleted file mode 100644 index b64445c4..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35.sln +++ /dev/null @@ -1,84 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetTests_net35", "NugetTests_net35\NugetTests_net35.csproj", "{E6D28865-5094-46C1-8816-9640623B26E4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetTests_net40", "NugetTests_net40\NugetTests_net40.csproj", "{5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetTests_net45", "NugetTests_net45\NugetTests_net45.csproj", "{AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetTests_wsa", "NugetTests_wsa\NugetTests_wsa.csproj", "{2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E6D28865-5094-46C1-8816-9640623B26E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Debug|ARM.ActiveCfg = Debug|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Debug|x64.ActiveCfg = Debug|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Debug|x86.ActiveCfg = Debug|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Release|Any CPU.Build.0 = Release|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Release|ARM.ActiveCfg = Release|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Release|x64.ActiveCfg = Release|Any CPU - {E6D28865-5094-46C1-8816-9640623B26E4}.Release|x86.ActiveCfg = Release|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Debug|ARM.ActiveCfg = Debug|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Debug|x64.ActiveCfg = Debug|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Debug|x86.ActiveCfg = Debug|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Release|Any CPU.Build.0 = Release|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Release|ARM.ActiveCfg = Release|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Release|x64.ActiveCfg = Release|Any CPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD}.Release|x86.ActiveCfg = Release|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Debug|ARM.ActiveCfg = Debug|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Debug|x64.ActiveCfg = Debug|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Debug|x86.ActiveCfg = Debug|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Release|Any CPU.Build.0 = Release|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Release|ARM.ActiveCfg = Release|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Release|x64.ActiveCfg = Release|Any CPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2}.Release|x86.ActiveCfg = Release|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|ARM.ActiveCfg = Debug|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|ARM.Build.0 = Debug|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|ARM.Deploy.0 = Debug|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x64.ActiveCfg = Debug|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x64.Build.0 = Debug|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x64.Deploy.0 = Debug|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x86.ActiveCfg = Debug|x86 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x86.Build.0 = Debug|x86 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Debug|x86.Deploy.0 = Debug|x86 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|Any CPU.Build.0 = Release|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|Any CPU.Deploy.0 = Release|Any CPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|ARM.ActiveCfg = Release|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|ARM.Build.0 = Release|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|ARM.Deploy.0 = Release|ARM - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x64.ActiveCfg = Release|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x64.Build.0 = Release|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x64.Deploy.0 = Release|x64 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x86.ActiveCfg = Release|x86 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x86.Build.0 = Release|x86 - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA}.Release|x86.Deploy.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.Designer.cs deleted file mode 100644 index 341235e4..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.Designer.cs +++ /dev/null @@ -1,143 +0,0 @@ -namespace NugetTests_net35 -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.lblVersion = new System.Windows.Forms.Label(); - this.lblTestResult = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.lblPlatform = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(34, 33); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(96, 16); - this.label1.TabIndex = 0; - this.label1.Text = "Version check :"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(48, 146); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 16); - this.label2.TabIndex = 0; - this.label2.Text = "Simple test :"; - this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblVersion - // - this.lblVersion.AutoSize = true; - this.lblVersion.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblVersion.Location = new System.Drawing.Point(136, 33); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(71, 16); - this.lblVersion.TabIndex = 1; - this.lblVersion.Text = "lblVersion"; - // - // lblTestResult - // - this.lblTestResult.AutoSize = true; - this.lblTestResult.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblTestResult.Location = new System.Drawing.Point(136, 146); - this.lblTestResult.Name = "lblTestResult"; - this.lblTestResult.Size = new System.Drawing.Size(91, 16); - this.lblTestResult.TabIndex = 2; - this.lblTestResult.Text = "lblTestResult"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(52, 234); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(205, 59); - this.button1.TabIndex = 3; - this.button1.Text = "TryDebugger"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(32, 90); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(97, 16); - this.label5.TabIndex = 0; - this.label5.Text = "Platform check:"; - this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblPlatform - // - this.lblPlatform.AutoSize = true; - this.lblPlatform.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblPlatform.Location = new System.Drawing.Point(136, 90); - this.lblPlatform.Name = "lblPlatform"; - this.lblPlatform.Size = new System.Drawing.Size(71, 16); - this.lblPlatform.TabIndex = 1; - this.lblPlatform.Text = "lblVersion"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(311, 330); - this.Controls.Add(this.button1); - this.Controls.Add(this.lblTestResult); - this.Controls.Add(this.lblPlatform); - this.Controls.Add(this.lblVersion); - this.Controls.Add(this.label5); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "Form1"; - this.Text = "Nuget on .NET 3.5"; - this.Load += new System.EventHandler(this.Form1_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label lblVersion; - private System.Windows.Forms.Label lblTestResult; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label lblPlatform; - } -} - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.cs deleted file mode 100644 index 360017cf..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using MoonSharp.Interpreter; -using MoonSharp.RemoteDebugger; - -namespace NugetTests_net35 -{ - public partial class Form1 : Form - { - string EXPECTEDVERSION = VERSION.NUMB; - string EXPECTEDPLATF = "std.dotnet.clr2"; - - string BASICSCRIPT = @" -function dodo(x, y, z) - return tostring((x + y) * z); -end - -return dodo; -"; - - public Form1() - { - InitializeComponent(); - } - - private void Form1_Load(object sender, EventArgs e) - { - CheckString(lblVersion, EXPECTEDVERSION, Script.VERSION); - CheckString(lblPlatform, EXPECTEDPLATF, Script.GlobalOptions.Platform.GetPlatformName()); - - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - } - - private void CheckString(Label label, string expected, string actual) - { - label.Text = actual; - - if (actual != expected) - label.ForeColor = Color.Red; - else - label.ForeColor = Color.Green; - } - - private void button1_Click(object sender, EventArgs e) - { - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - - ActivateRemoteDebugger(S); - - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - - } - - RemoteDebuggerService remoteDebugger; - - private void ActivateRemoteDebugger(Script script) - { - if (remoteDebugger == null) - { - remoteDebugger = new RemoteDebuggerService(); - - // the last boolean is to specify if the script is free to run - // after attachment, defaults to false - remoteDebugger.Attach(script, "Description of the script", false); - } - - // start the web-browser at the correct url. Replace this or just - // pass the url to the user in some way. - Process.Start(remoteDebugger.HttpUrlStringLocalHost); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.resx deleted file mode 100644 index 7080a7d1..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/NugetTests_net35.csproj b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/NugetTests_net35.csproj deleted file mode 100644 index 6766c9c7..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/NugetTests_net35.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - Debug - AnyCPU - {E6D28865-5094-46C1-8816-9640623B26E4} - WinExe - Properties - NugetTests_net35 - NugetTests_net35 - v3.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\MoonSharp.0.9.4.0\lib\net35-client\MoonSharp.Interpreter.dll - - - False - ..\packages\MoonSharp.Debugger.0.9.4.0\lib\net35-client\MoonSharp.RemoteDebugger.dll - - - - - - - - - - - - - - Form - - - Form1.cs - - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Program.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Program.cs deleted file mode 100644 index 745d8923..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; - -namespace NugetTests_net35 -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/AssemblyInfo.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/AssemblyInfo.cs deleted file mode 100644 index 84f86f73..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NugetTests_net35")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NugetTests_net35")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("53b58219-038b-4850-9d66-4f92d39ee130")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.Designer.cs deleted file mode 100644 index 4085453e..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net35.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NugetTests_net35.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.resx deleted file mode 100644 index af7dbebb..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.Designer.cs deleted file mode 100644 index b1768ba2..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net35.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.settings b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.settings deleted file mode 100644 index 39645652..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/VERSION.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/VERSION.cs deleted file mode 100644 index 8b0ffef1..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/VERSION.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System -{ - public static class VERSION - { - public const string NUMB = "0.9.2.0"; - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/packages.config b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/packages.config deleted file mode 100644 index 10e4edcc..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net35/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.Designer.cs deleted file mode 100644 index f480231a..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.Designer.cs +++ /dev/null @@ -1,143 +0,0 @@ -namespace NugetTests_net35 -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.lblVersion = new System.Windows.Forms.Label(); - this.lblTestResult = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.lblPlatform = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(34, 33); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(96, 16); - this.label1.TabIndex = 0; - this.label1.Text = "Version check :"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(48, 146); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 16); - this.label2.TabIndex = 0; - this.label2.Text = "Simple test :"; - this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblVersion - // - this.lblVersion.AutoSize = true; - this.lblVersion.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblVersion.Location = new System.Drawing.Point(136, 33); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(71, 16); - this.lblVersion.TabIndex = 1; - this.lblVersion.Text = "lblVersion"; - // - // lblTestResult - // - this.lblTestResult.AutoSize = true; - this.lblTestResult.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblTestResult.Location = new System.Drawing.Point(136, 146); - this.lblTestResult.Name = "lblTestResult"; - this.lblTestResult.Size = new System.Drawing.Size(91, 16); - this.lblTestResult.TabIndex = 2; - this.lblTestResult.Text = "lblTestResult"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(52, 234); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(205, 59); - this.button1.TabIndex = 3; - this.button1.Text = "TryDebugger"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(32, 90); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(97, 16); - this.label5.TabIndex = 0; - this.label5.Text = "Platform check:"; - this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblPlatform - // - this.lblPlatform.AutoSize = true; - this.lblPlatform.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblPlatform.Location = new System.Drawing.Point(136, 90); - this.lblPlatform.Name = "lblPlatform"; - this.lblPlatform.Size = new System.Drawing.Size(71, 16); - this.lblPlatform.TabIndex = 1; - this.lblPlatform.Text = "lblVersion"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(311, 330); - this.Controls.Add(this.button1); - this.Controls.Add(this.lblTestResult); - this.Controls.Add(this.lblPlatform); - this.Controls.Add(this.lblVersion); - this.Controls.Add(this.label5); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "Form1"; - this.Text = "Nuget on .NET 4.0"; - this.Load += new System.EventHandler(this.Form1_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label lblVersion; - private System.Windows.Forms.Label lblTestResult; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label lblPlatform; - } -} - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.cs deleted file mode 100644 index 36b8f6a0..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using MoonSharp.Interpreter; -using MoonSharp.RemoteDebugger; - -namespace NugetTests_net35 -{ - public partial class Form1 : Form - { - string EXPECTEDVERSION = VERSION.NUMB; - string EXPECTEDPLATF = "std.dotnet.clr4"; - - string BASICSCRIPT = @" -function dodo(x, y, z) - return tostring((x + y) * z); -end - -return dodo; -"; - - public Form1() - { - InitializeComponent(); - } - - private void Form1_Load(object sender, EventArgs e) - { - CheckString(lblVersion, EXPECTEDVERSION, Script.VERSION); - CheckString(lblPlatform, EXPECTEDPLATF, Script.GlobalOptions.Platform.GetPlatformName()); - - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - } - - private void CheckString(Label label, string expected, string actual) - { - label.Text = actual; - - if (actual != expected) - label.ForeColor = Color.Red; - else - label.ForeColor = Color.Green; - } - - private void button1_Click(object sender, EventArgs e) - { - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - - ActivateRemoteDebugger(S); - - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - - } - - RemoteDebuggerService remoteDebugger; - - private void ActivateRemoteDebugger(Script script) - { - if (remoteDebugger == null) - { - remoteDebugger = new RemoteDebuggerService(); - - // the last boolean is to specify if the script is free to run - // after attachment, defaults to false - remoteDebugger.Attach(script, "Description of the script", false); - } - - // start the web-browser at the correct url. Replace this or just - // pass the url to the user in some way. - Process.Start(remoteDebugger.HttpUrlStringLocalHost); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.resx deleted file mode 100644 index 1af7de15..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/NugetTests_net40.csproj b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/NugetTests_net40.csproj deleted file mode 100644 index 3a3f4741..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/NugetTests_net40.csproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - AnyCPU - {5CBA5DC0-AF86-4FC0-8D13-C3324EC51DDD} - WinExe - Properties - NugetTests_net40 - NugetTests_net40 - v4.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\MoonSharp.0.9.4.0\lib\net40-client\MoonSharp.Interpreter.dll - - - False - ..\packages\MoonSharp.Debugger.0.9.4.0\lib\net40-client\MoonSharp.RemoteDebugger.dll - - - - - - - - - - - - - - - VERSION.cs - - - Form - - - Form1.cs - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Program.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Program.cs deleted file mode 100644 index d440e991..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; -using NugetTests_net35; - -namespace NugetTests_net40 -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/AssemblyInfo.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/AssemblyInfo.cs deleted file mode 100644 index 87fda41c..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NugetTests_net40")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NugetTests_net40")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("29618db6-3979-4617-a55f-d7e27f641f22")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.Designer.cs deleted file mode 100644 index 37df8f5a..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net40.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NugetTests_net40.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.resx deleted file mode 100644 index af7dbebb..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.Designer.cs deleted file mode 100644 index 2f48db11..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net40.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.settings b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.settings deleted file mode 100644 index 39645652..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/packages.config b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/packages.config deleted file mode 100644 index eb1b1497..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net40/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/App.config b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/App.config deleted file mode 100644 index 8e156463..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.Designer.cs deleted file mode 100644 index 735c64e9..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.Designer.cs +++ /dev/null @@ -1,143 +0,0 @@ -namespace NugetTests_net35 -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.lblVersion = new System.Windows.Forms.Label(); - this.lblTestResult = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.lblPlatform = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(34, 33); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(96, 16); - this.label1.TabIndex = 0; - this.label1.Text = "Version check :"; - this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(48, 146); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 16); - this.label2.TabIndex = 0; - this.label2.Text = "Simple test :"; - this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblVersion - // - this.lblVersion.AutoSize = true; - this.lblVersion.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblVersion.Location = new System.Drawing.Point(136, 33); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(71, 16); - this.lblVersion.TabIndex = 1; - this.lblVersion.Text = "lblVersion"; - // - // lblTestResult - // - this.lblTestResult.AutoSize = true; - this.lblTestResult.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblTestResult.Location = new System.Drawing.Point(136, 146); - this.lblTestResult.Name = "lblTestResult"; - this.lblTestResult.Size = new System.Drawing.Size(91, 16); - this.lblTestResult.TabIndex = 2; - this.lblTestResult.Text = "lblTestResult"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(52, 234); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(205, 59); - this.button1.TabIndex = 3; - this.button1.Text = "TryDebugger"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(32, 90); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(97, 16); - this.label5.TabIndex = 0; - this.label5.Text = "Platform check:"; - this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // lblPlatform - // - this.lblPlatform.AutoSize = true; - this.lblPlatform.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblPlatform.Location = new System.Drawing.Point(136, 90); - this.lblPlatform.Name = "lblPlatform"; - this.lblPlatform.Size = new System.Drawing.Size(71, 16); - this.lblPlatform.TabIndex = 1; - this.lblPlatform.Text = "lblVersion"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(311, 330); - this.Controls.Add(this.button1); - this.Controls.Add(this.lblTestResult); - this.Controls.Add(this.lblPlatform); - this.Controls.Add(this.lblVersion); - this.Controls.Add(this.label5); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "Form1"; - this.Text = "Nuget on .NET 4.5"; - this.Load += new System.EventHandler(this.Form1_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label lblVersion; - private System.Windows.Forms.Label lblTestResult; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label lblPlatform; - } -} - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.cs deleted file mode 100644 index 36b8f6a0..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using MoonSharp.Interpreter; -using MoonSharp.RemoteDebugger; - -namespace NugetTests_net35 -{ - public partial class Form1 : Form - { - string EXPECTEDVERSION = VERSION.NUMB; - string EXPECTEDPLATF = "std.dotnet.clr4"; - - string BASICSCRIPT = @" -function dodo(x, y, z) - return tostring((x + y) * z); -end - -return dodo; -"; - - public Form1() - { - InitializeComponent(); - } - - private void Form1_Load(object sender, EventArgs e) - { - CheckString(lblVersion, EXPECTEDVERSION, Script.VERSION); - CheckString(lblPlatform, EXPECTEDPLATF, Script.GlobalOptions.Platform.GetPlatformName()); - - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - } - - private void CheckString(Label label, string expected, string actual) - { - label.Text = actual; - - if (actual != expected) - label.ForeColor = Color.Red; - else - label.ForeColor = Color.Green; - } - - private void button1_Click(object sender, EventArgs e) - { - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - - ActivateRemoteDebugger(S); - - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - - } - - RemoteDebuggerService remoteDebugger; - - private void ActivateRemoteDebugger(Script script) - { - if (remoteDebugger == null) - { - remoteDebugger = new RemoteDebuggerService(); - - // the last boolean is to specify if the script is free to run - // after attachment, defaults to false - remoteDebugger.Attach(script, "Description of the script", false); - } - - // start the web-browser at the correct url. Replace this or just - // pass the url to the user in some way. - Process.Start(remoteDebugger.HttpUrlStringLocalHost); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.resx deleted file mode 100644 index 1af7de15..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/NugetTests_net45.csproj b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/NugetTests_net45.csproj deleted file mode 100644 index 8d2388da..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/NugetTests_net45.csproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - AnyCPU - {AA376A70-0C4E-4777-B1A8-0107F8D6BFB2} - WinExe - Properties - NugetTests_net45 - NugetTests_net45 - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\MoonSharp.0.9.4.0\lib\net40-client\MoonSharp.Interpreter.dll - - - False - ..\packages\MoonSharp.Debugger.0.9.4.0\lib\net40-client\MoonSharp.RemoteDebugger.dll - - - - - - - - - - - - - - - VERSION.cs - - - Form - - - Form1.cs - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Program.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Program.cs deleted file mode 100644 index 8f55d765..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace NugetTests_net45 -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new NugetTests_net35.Form1()); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/AssemblyInfo.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/AssemblyInfo.cs deleted file mode 100644 index 86366b6a..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NugetTests_net45")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NugetTests_net45")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("21b69915-4abf-48d6-b0d8-047b6a7b4cb2")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.Designer.cs deleted file mode 100644 index 8952926c..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net45.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NugetTests_net45.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.resx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.resx deleted file mode 100644 index af7dbebb..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.Designer.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.Designer.cs deleted file mode 100644 index e0c3b832..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.34014 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NugetTests_net45.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.settings b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.settings deleted file mode 100644 index 39645652..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/packages.config b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/packages.config deleted file mode 100644 index 987703a1..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_net45/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml deleted file mode 100644 index 6a54fe8d..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml.cs deleted file mode 100644 index ff5402a4..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/App.xaml.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 - -namespace NugetTests_wsa -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - -#if DEBUG - //if (System.Diagnostics.Debugger.IsAttached) - //{ - // this.DebugSettings.EnableFrameRateCounter = true; - //} -#endif - - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - // Set the default language - rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/Logo.scale-100.png b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/Logo.scale-100.png deleted file mode 100644 index e26771cb..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/Logo.scale-100.png and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SmallLogo.scale-100.png b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SmallLogo.scale-100.png deleted file mode 100644 index 1eb0d9d5..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SmallLogo.scale-100.png and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SplashScreen.scale-100.png b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SplashScreen.scale-100.png deleted file mode 100644 index c951e031..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/SplashScreen.scale-100.png and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/StoreLogo.scale-100.png b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/StoreLogo.scale-100.png deleted file mode 100644 index dcb67271..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Assets/StoreLogo.scale-100.png and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml deleted file mode 100644 index 092b2d4d..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml.cs deleted file mode 100644 index ccac7b92..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/MainPage.xaml.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using MoonSharp.Interpreter; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 - -namespace NugetTests_wsa -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class MainPage : Page - { - string EXPECTEDVERSION = VERSION.NUMB; - string EXPECTEDPLATF = "limited.dotnet.portable.clr4"; - - string BASICSCRIPT = @" -function dodo(x, y, z) - return tostring((x + y) * z); -end - -return dodo; -"; - - public MainPage() - { - this.InitializeComponent(); - } - - private void Page_Loaded(object sender, RoutedEventArgs e) - { - CheckString(lblVersion, EXPECTEDVERSION, Script.VERSION); - CheckString(lblPlatform, EXPECTEDPLATF, Script.GlobalOptions.Platform.GetPlatformName()); - - Script S = new Script(); - DynValue fn = S.DoString(BASICSCRIPT); - string res = fn.Function.Call(2, 3, 4).String; - - CheckString(lblTestResult, "20", res); - } - - private void CheckString(TextBlock label, string expected, string actual) - { - label.Text = actual; - - if (actual != expected) - label.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)); - else - label.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 200, 0)); - } - } -} diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa.csproj b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa.csproj deleted file mode 100644 index 58a39393..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa.csproj +++ /dev/null @@ -1,156 +0,0 @@ - - - - - Debug - AnyCPU - {2611D4FB-FAB2-4723-9E0A-1D1285F40CCA} - AppContainerExe - Properties - NugetTests_wsa - NugetTests_wsa - en-US - 8.1 - 12 - 512 - {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - NugetTests_wsa_TemporaryKey.pfx - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_APP - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE;NETFX_CORE;WINDOWS_APP - prompt - 4 - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_APP - ;2008 - full - ARM - false - prompt - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE;WINDOWS_APP - true - ;2008 - pdbonly - ARM - false - prompt - true - - - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_APP - ;2008 - full - x64 - false - prompt - true - - - bin\x64\Release\ - TRACE;NETFX_CORE;WINDOWS_APP - true - ;2008 - pdbonly - x64 - false - prompt - true - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_APP - ;2008 - full - x86 - false - prompt - true - - - bin\x86\Release\ - TRACE;NETFX_CORE;WINDOWS_APP - true - ;2008 - pdbonly - x86 - false - prompt - true - - - - VERSION.cs - - - App.xaml - - - MainPage.xaml - - - - - - Designer - - - - - - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - False - ..\packages\MoonSharp.0.9.4.0\lib\portable-net4+sl5+wp8+win8\MoonSharp.Interpreter.dll - - - - 12.0 - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa_TemporaryKey.pfx b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa_TemporaryKey.pfx deleted file mode 100644 index 6731cd7b..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/NugetTests_wsa_TemporaryKey.pfx and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Package.appxmanifest b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Package.appxmanifest deleted file mode 100644 index 37c3a026..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Package.appxmanifest +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - NugetTests_wsa - Marco.Mastropaolo - Assets\StoreLogo.png - - - - 6.3.0 - 6.3.0 - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Properties/AssemblyInfo.cs b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Properties/AssemblyInfo.cs deleted file mode 100644 index 1ea4871b..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NugetTests_wsa")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NugetTests_wsa")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/packages.config b/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/packages.config deleted file mode 100644 index 31fbe9f3..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/NugetTests_wsa/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/MoonSharp.0.9.4.0.nupkg b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/MoonSharp.0.9.4.0.nupkg deleted file mode 100644 index d5c95117..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/MoonSharp.0.9.4.0.nupkg and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net35-client/MoonSharp.Interpreter.xml b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net35-client/MoonSharp.Interpreter.xml deleted file mode 100644 index 51902bef..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net35-client/MoonSharp.Interpreter.xml +++ /dev/null @@ -1,6529 +0,0 @@ - - - - MoonSharp.Interpreter - - - - - Class implementing coroutine Lua functions - - - - - Class implementing basic Lua functions (print, type, tostring, etc) as a MoonSharp module. - - - - - Class implementing debug Lua functions. Support for the debug module is partial. - - - - - Class implementing dynamic expression evaluations at runtime (a MoonSharp addition). - - - - - Class implementing error handling Lua functions (pcall and xpcall) - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - A base class for many MoonSharp objects. - Helds a ReferenceID property which gets a different value for every object instance, for debugging - purposes. Note that the ID is not assigned in a thread safe manner for speed reason, so the IDs - are guaranteed to be unique only if everything is running on one thread at a time. - - - - - Formats a string with a type name and a ref-id - - The type name. - - - - - Gets the reference identifier. - - - The reference identifier. - - - - - Class implementing io Lua functions. Proper support requires a compatible IPlatformAccessor - - - - - Abstract class implementing an unclosable file Lua userdata. Methods are meant to be called by Lua code. - - - - - Class implementing loading Lua functions like 'require', 'load', etc. - - - - - Class implementing bit32 Lua functions - - - - - Class implementing math Lua functions - - - - - Class implementing metatable related Lua functions (xxxmetatable and rawxxx). - - - - - Class implementing system related Lua functions from the 'os' module. - Proper support requires a compatible IPlatformAccessor - - - - - Class implementing time related Lua functions from the 'os' module. - - - - - Classes using the classic interface should inherit from this class. - This class defines only static methods and is really meant to be used only - from C# and not other .NET languages. - - For easier operation they should also define: - using ptrdiff_t = System.Int32; - using lua_Integer = System.Int32; - using LUA_INTFRM_T = System.Int64; - using UNSIGNED_LUA_INTFRM_T = System.UInt64; - - - - - Calls a function. - To call a function you must use the following protocol: first, the function to be called is pushed onto the stack; then, - the arguments to the function are pushed in direct order; that is, the first argument is pushed first. Finally you call - lua_call; nargs is the number of arguments that you pushed onto the stack. All arguments and the function value are - popped from the stack when the function is called. The function results are pushed onto the stack when the function - returns. The number of results is adjusted to nresults, unless nresults is LUA_MULTRET. In this case, all results from - the function are pushed. Lua takes care that the returned values fit into the stack space. The function results are - pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is on - the top of the stack. - - The LuaState - The number of arguments. - The number of expected results. - - - - - A Dictionary where multiple values can be associated to the same key - - The key type - The value type - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The equality comparer to use in the underlying dictionary. - - - - Adds the specified key. Returns true if this is the first value for a given key - - The key. - The value. - - - - - Finds all the values associated with the specified key. - An empty collection is returned if not found. - - The key. - - - - Determines whether this contains the specified key - - The key. - - - - Clears this instance. - - - - - Removes the specified key and all its associated values from the multidictionary - - The key. - - - - Removes the value. Returns true if the removed value was the last of a given key - - The key. - The value. - - - - - Gets the keys. - - - - - Implementation of IEqualityComparer enforcing reference equality - - - - - Marks a method as the handler of metamethods of a userdata type - - - - - Initializes a new instance of the class. - - The metamethod name (like '__div', '__ipairs', etc.) - - - - The metamethod name (like '__div', '__ipairs', etc.) - - - - - Base interface to describe access to members of a given type. - While it's not infrastructural to implement custom type descriptors, it's needed for - classes extending . - - - - - Gets the value of this member as a to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value of this member as a . - - - - Sets the value of this member from a . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Extension methods for and . - - - - - Determines whether the specified MemberDescriptorAccess has ALL the specified flags. - - The access. - The flag. - - - - - Determines whether this instance can be read - - The descriptor instance. - - - - - Determines whether this instance can be written to - - The descriptor instance. - - - - - Determines whether this instance can be executed (called as a function) - - The descriptor instance. - - - - - Gets the getter of the member as a DynValue containing a callback - - The descriptor instance. - The script. - The object. - - - - - Returns the specified descriptor if it supports all the specified access modes, otherwise returns null. - - The descriptor instance. - The access mode(s). - - - - - Raises an appropriate ScriptRuntimeException if the specified access is not supported. - Checks are made for the MemberDescriptorAccess permissions AND for the access of instance - members through static userdatas. - - The desc. - The access. - The object to be checked for access. - - - - Interface for descriptors of any kind which support optimizations of their implementation according to InteropAccessMode - modes. This should seldom - if ever - be implemented in user code. - - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Specialized for members supporting overloads resolution. - - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Permissions for members access - - - - - The member can be read from - - - - - The member can be written to - - - - - The can be invoked - - - - - Descriptor of parameters used in implementations. - - - - - If the type got restricted, the original type before the restriction. - - - - - Initializes a new instance of the class. - - The name. - The type. - if set to true the parameter has default value. - The default value. - if set to true, is an out param. - - - - Initializes a new instance of the class. - - A ParameterInfo taken from reflection. - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Restricts the type of this parameter to a tighter constraint. - Restrictions must be applied before the containing this - parameter is used in any way. - - The new type. - - Cannot restrict a ref/out param - or - Specified operation is not a restriction - - - - - Gets the name of the parameter - - - - - Gets the type of the parameter - - - - - Gets a value indicating whether this instance has a default value. - - - - - Gets the default value - - - - - Gets a value indicating whether this instance is an out parameter - - - - - Gets a value indicating whether this instance has been restricted. - - - - - Gets the original type of the parameter before any restriction has been applied. - - - - - Tries to convert a CLR object to a MoonSharp value, using "simple" logic. - Does NOT throw on failure. - - - - - Tries to convert a CLR object to a MoonSharp value, using more in-depth analysis - - - - - Converts an IEnumerable or IEnumerator to a DynValue - - The script. - The object. - - - - - Static functions to handle conversions of numeric types - - - - - HashSet of numeric types - - - - - Array of numeric types in order used for some conversions - - - - - Converts a double to another type - - - - - Converts a type to double - - - - - Converts a DynValue to a CLR object [simple conversion] - - - - - Converts a DynValue to a CLR object of a specific type - - - - - Gets a relative weight of how much the conversion is matching the given types. - Implementation must follow that of DynValueToObjectOfType.. it's not very DRY in that sense. - However here we are in perf-sensitive path.. TODO : double-check the gain and see if a DRY impl is better. - - - - - Converts an IList to a Lua table. - - - - - Converts an IDictionary to a Lua table. - - - - - Determines whether the specified table can be converted to the specified type - - The table. - The type. - - - - - Converts a table to a CLR object of a given type - - - - - Converts a table to a - - - - - Converts a table to a T[] - - - - - Converts a table to a - - - - - Converts a table to a , known in advance - - - - - Converts a table to a Dictionary, known in advance - - - - - A collection of custom converters between MoonSharp types and CLR types. - If a converter function is not specified or returns null, the standard conversion path applies. - - - - - Sets a custom converter from a script data type to a CLR data type. Set null to remove a previous custom converter. - - The script data type - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a script data type to a CLR data type, or null - - The script data type - The CLR data type. - The converter function, or null if not found - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a CLR data type, or null - - Type of the color data. - The converter function, or null if not found - - - - Removes all converters. - - - - - Helper extension methods used to simplify some parts of userdata descriptor implementations - - - - - Determines whether a - is changing visibility of a member - to scripts. - - The member to check. - - true if visibility is forced visible, - false if visibility is forced hidden or the specified MemberInfo is null, - if no attribute was found - - - - - Determines whether the specified PropertyInfo is visible publicly (either the getter or the setter is public). - - The PropertyInfo. - - - - - Gets the list of metamethod names from attributes - in practice the list of metamethods declared through - . - - The mi. - - - - - Gets the name of a conversion method to be exposed to Lua scripts - - The type. - - - - - An abstract user data descriptor which accepts members described by objects and - correctly dispatches to them. - Metamethods are also by default dispatched to operator overloads and other similar methods - see - . - - - - - Interface used by MoonSharp to access objects of a given type from scripts. - - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - The special name used by CLR for indexer getters - - - - - The special name used by CLR for indexer setters - - - - - The special name used by CLR for explicit cast conversions - - - - - The special name used by CLR for implicit cast conversions - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - A friendly name for the type, or null. - - - - Adds a member to the meta-members list. - - The name of the metamethod. - The desc. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Adds a DynValue as a member - - The name. - The value. - - - - Adds a property to the member list - - The name. - The descriptor. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Performs an "index" "get" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing operation by checking newly added extension methods for the given indexName. - - The script. - The object. - Member name to be indexed. - - - - - - Determines whether the descriptor contains the specified member (by exact name) - - Name of the member. - - - - - Determines whether the descriptor contains the specified member in the meta list (by exact name) - - Name of the meta-member. - - - - - Tries to perform an indexing operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - - - - - Performs an "index" "set" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing "set" operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - The value. - - - - - Converts the specified name from underscore_case to camelCase. - - The name. - - - - - Converts the specified name to one with an uppercase first letter (something to Something). - - The name. - - - - - Converts this userdata to string - - The object. - - - - - Executes the specified indexer method. - - The method descriptor - The script. - The object. - The indexer parameter - The dynvalue to set on a setter, or null. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - See for further details. - - If a method exists marked with for the specific - metamethod requested, that method is returned. - - If the above fails, the following dispatching occur: - - __add, __sub, __mul, __div, __mod and __unm are dispatched to C# operator overloads (if they exist) - __eq is dispatched to System.Object.Equals. - __lt and __le are dispatched IComparable.Compare, if the type implements IComparable or IComparable{object} - __len is dispatched to Length and Count properties, if those exist. - __iterator is handled if the object implements IEnumerable or IEnumerator. - __tonumber is dispatched to implicit or explicit conversion operators to standard numeric types. - __tobool is dispatched to an implicit or explicit conversion operator to bool. If that fails, operator true is used. - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Gets a human readable friendly name of the descriptor - - - - - Standard descriptor for Enum values - - - - - Initializes a new instance of the class. - - Type of the enum. - Name of the friendly. - enumType must be an enum! - - - - Fills the member list. - - - - - Adds an enum method to the object - - The name. - The dyn value. - - - - Gets the value of the enum as a long - - - - - Gets the value of the enum as a ulong - - - - - Creates an enum value from a long - - - - - Creates an enum value from a ulong - - - - - Creates conversion functions for signed enums - - - - - Creates conversion functions for unsigned enums - - - - - Determines whether the specified object is compatible with the specified type. - - The type. - The object. - - - - - Gets a "meta" operation on this userdata. - In this specific case, only the concat operator is supported, only on flags enums and it implements the - 'or' operator. - - - - - - - - - Gets the underlying type of the enum. - - - - - Gets a value indicating whether underlying type of the enum is unsigned. - - - - - Gets a value indicating whether this instance describes a flags enumeration. - - - - - Class providing a simple descriptor for constant DynValues in userdata - - - - - Initializes a new instance of the class. - - The name. - The value. - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - userdata '{0}' cannot be written to. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Gets the value wrapped by this descriptor - - - - - Class providing easier marshalling of CLR events. Handling is limited to a narrow range of handler signatures, which, - however, covers in practice most of all available events. - - - - - The maximum number of arguments supported in an event handler delegate - - - - - Tries to create a new StandardUserDataEventDescriptor, returning null in case the method is not - visible to script code. - - The EventInfo. - The - A new StandardUserDataEventDescriptor or null. - - - - Checks if the event is compatible with a standard descriptor - - The EventInfo. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The event is declared in a value type - or - The event does not have both add and remove methods - or - The event handler type doesn't implement a public Invoke method - or - The event handler has a return type which is not System.Void - or - The event handler has more than MAX_ARGS_IN_DELEGATE parameters - or - The event handler has a value type parameter or a by ref parameter - or - The event handler signature is not a valid method according to - - - - - Initializes a new instance of the class. - - The ei. - The access mode. - - - - Gets a dynvalue which is a facade supporting add/remove methods which is callable from scripts - - The script. - The object for which the facade should be written. - - - - - Sets the value. - - The script. - The object. - The v. - - - - Gets the EventInfo object of the event described by this descriptor - - - - - Gets a value indicating whether the event described by this descriptor is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - As a convenience, every type deriving from IUserDataType is "self-described". That is, no descriptor is needed/generated - and the object itself is used to describe the type for interop. See also , - and . - - - - - Performs an "index" "get" operation. - - The script originating the request - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The name of the metamember. - - - - - Class providing easier marshalling of overloaded CLR functions - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptor of the first overloaded method. - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptors of the overloaded methods. - - - - Sets the extension methods snapshot. - - The version. - The ext methods. - - - - Adds an overload. - - The overload. - - - - Performs the overloaded call. - - The script. - The object. - The context. - The arguments. - - function call doesn't match any overload - - - - Calculates the score for the overload. - - The context. - The arguments. - The method. - if set to true, is an extension method. - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - - - - - Gets or sets a value indicating whether this instance ignores extension methods. - - - - - Gets the name of the first described overload - - - - - Gets the name of the first described overload - - - - - Gets the number of overloaded methods contained in this collection - - - The overload count. - - - - - Gets a value indicating whether there is at least one static method in the resolution list - - - - - - Gets the types of access supported by this member - - - - - Comparer class for IOverloadableMemberDescriptor - - - - - Class providing easier marshalling of CLR fields - - - - - Tries to create a new StandardUserDataFieldDescriptor, returning null in case the field is not - visible to script code. - - The FieldInfo. - The - A new StandardUserDataFieldDescriptor or null. - - - - Initializes a new instance of the class. - - The FieldInfo. - The - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Gets the FieldInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance is a constant - - - - - Gets a value indicating whether this instance is readonly - - - - - Gets the types of access supported by this member - - - - - Member descriptor for the default constructor of value types. - - - - - Initializes a new instance of the - class - representing the default empty ctor for a value type. - - Type of the value. - valueType is not a value type - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a - to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a - . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - This property is equal to the value type to be constructed. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the types of access supported by this member - - - - - "Optimized" BinaryReader which shares strings and use a dumb compression for integers - - - - - "Optimized" BinaryWriter which shares strings and use a dumb compression for integers - - - - - An adapter over Stream which bypasses the Dispose and Close methods. - Used to work around the pesky wrappers .NET has over Stream (BinaryReader, StreamWriter, etc.) which think they - own the Stream and close them when they shouldn't. Damn. - - - - - Enumerations of the possible policies to handle UserData type registrations - See also : . - - - - - Types must be explicitly registered. If a base type or interface is registered, that is used. - - - - - Types are automatically registered if not found in the registry. This is easier to use but potentially unsafe. - - - - - A Delegate type which can wrap a script function - - The arguments. - The return value of the script function - - - - A Delegate type which can wrap a script function with a generic typed return value - - - The arguments. - The return value of the script function - - - - Flags to alter the way the DynValue.CheckType and other related functions operate on data types for - validation. - - - - - No type validation specific behaviour - - - - - Nil and Void values are allowed (and returned by the call) - - - - - Simple autoconversions are attempted: - 1) Numbers are convertible to strings - 2) Strings are convertible to numbers if they contain a number - 3) Everything is convertible to boolean (with void and nil converting to 'false', everything else converting to 'true') - Note: if both AutoConvert and AllowNil are specified, nils will NOT be converted to false booleans. - - - - - The default : Autoconverting values, no nils. - - - - - Exception thrown when a dynamic expression is invalid - - - - - Exception for all runtime errors. In addition to constructors, it offers a lot of static methods - generating more "standard" Lua errors. - - - - - Base type of all exceptions thrown in MoonSharp - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Gets the instruction pointer of the execution (if it makes sense) - - - - - Gets the interpreter call stack. - - - - - Gets the decorated message (error message plus error location in script) if possible. - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an arithmetic operation was attempted on non-numbers - - The left operand. - The right operand (or null). - The exception to be raised. - If both are numbers - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a concat operation was attempted on non-strings - - The left operand. - The right operand. - The exception to be raised. - If both are numbers or strings - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a len operator was applied on an invalid operand - - The operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a comparison operator was applied on an invalid combination of operand types - - The left operand. - The right operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The error message. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad userdata argument - - The argument number (0-based). - Name of the function generating this error. - The expected System.Type. - The object which was used. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - The data type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected type description. - The description of the type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - - This function creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - while creates a message like "bad argument #xxx to 'yyy' (value expected)" - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an out of range index was specified - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a negative number when a positive one was expected. - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - This function creates a message like "bad argument #xxx to 'yyy' (value expected)" - while creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an invalid attempt to index the specified object was made - - The object. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __index over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __newindex over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __call over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used nil as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used a NaN as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion to number failed. - - - Selects the correct error message: - 0 - "value must be a number" - 1 - "'for' initial value must be a number" - 2 - "'for' step must be a number" - 3 - "'for' limit must be a number" - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a CLR type to a Lua type has failed. - - The object which could not be converted. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a Lua type to a CLR type has failed. - - The Lua type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a constrained conversion of a Lua type to a CLR type has failed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a userdata of a specific CLR type was expected and a non-userdata type was passed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to index an invalid member of a userdata was done. - - The name of the userdata type. - The field name. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt resume a coroutine in an invalid state was done. - - The state of the coroutine. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield across a CLR boundary was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield from the main coroutine was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to call a non-function was made - - The lua non-function data type. - The debug text to aid location (appears as "near 'xxx'"). - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The member descriptor. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The type descriptor. - The member descriptor. - - - - - Gets or sets a value indicating whether the message should not be decorated - - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Initializes a new instance of the class. - - The message. - - - - Represents a dynamic expression in the script - - - - - Common interface for all resources which are uniquely bound to a script. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - The code which generated this expression - - - - - Evaluates the expression - - The context. - - - - - Finds a symbol in the expression - - The context. - - - - - Determines whether this instance is a constant expression - - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - Internal type used by for registration - - - - - Wrapper which allows for easier management of userdata without registering a new userdata type - useful - if a type which is not exposed to scripts but can be managed as a "black box" by scripts is desired. - - The type to wrap - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The o. - - - - Gets or sets the value this instance wraps. - - - - - Determines whether the specified value is of numeric type. - - The object to check. - - true if o is a numeric type; otherwise, false. - - - - - Determines whether the specified value is positive. - - The value. - if set to true treats 0 as positive. - - true if the specified value is positive; otherwise, false. - - - - - Converts the specified values boxed type to its correpsonding unsigned - type. - - The value. - A boxed numeric object whos type is unsigned. - - - - Converts the specified values boxed type to its correpsonding integer - type. - - The value. - if set to true [round]. - - A boxed numeric object whos type is an integer type. - - - - - Replaces the string representations of meta chars with their corresponding - character values. - - The input. - A string with all string meta chars are replaced - - - - Class implementing string Lua functions - - - - - Class implementing table Lua iterators (pairs, ipairs, next) - - - - - Class implementing table Lua functions - - - - - Class exposing table.unpack and table.pack in the global namespace (to work around the most common Lua 5.1 compatibility issue). - - - - - Extension methods used in the whole project. - - - - - Gets a value from the dictionary or returns the default value - - The type of the key. - The type of the value. - The dictionary. - The key. - - - - - Gets a value from the dictionary or creates it - - The type of the key. - The type of the value. - The dictionary. - The key. - A function which will create the value if it doesn't exist. - - - - - A non preallocated, non_fixed size stack - - - - - - An index to accelerate operations on a LinkedList using a single key of type - More than one LinkedListIndex can index the same linked list, but every node in the linked list must be indexed by one and only one - LinkedListIndex object. - - The type of the key. Must implement Equals and GetHashCode appropriately. - The type of the values contained in the linked list. - - - - Initializes a new instance of the class. - - The linked list to be indexed. - - - - Finds the node indexed by the specified key, or null. - - The key. - - - - Updates or creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - The previous value of the element - - - - Creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - - - - Removes the specified key from the index, and the node indexed by the key from the linked list. - - The key. - - - - Determines whether the index contains the specified key. - - The key. - - - - Clears this instance (removes all elements) - - - - - Provides facility to create a "sliced" view over an existing IList - - The type of the items contained in the collection - - - - Initializes a new instance of the class. - - The list to apply the Slice view on - From which index - The length of the slice - if set to true the view is in reversed order. - - - - Calculates the real index in the underlying collection - - - - - Returns an enumerator that iterates through the collection. - - - A that can be used to iterate through the collection. - - - - - Returns an enumerator that iterates through a collection. - - - An object that can be used to iterate through the collection. - - - - - Converts to an array. - - - - - Converts to an list. - - - - - Determines the index of a specific item in the . - - The object to locate in the . - - The index of if found in the list; otherwise, -1. - - - - - Inserts an item to the at the specified index. - - The zero-based index at which should be inserted. - The object to insert into the . - Slices are readonly - - - - Removes the item at the specified index. - - The zero-based index of the item to remove. - Slices are readonly - - - - Adds an item to the . - - The object to add to the . - Slices are readonly - - - - Removes all items from the . - - Slices are readonly - - - - Determines whether the contains a specific value. - - The object to locate in the . - - true if is found in the ; otherwise, false. - - - - - Copies to. - - The array. - Index of the array. - - - - Removes the first occurrence of a specific object from the . - - The object to remove from the . - - true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original . - - Slices are readonly - - - - Gets or sets the element at the specified index. - - The index. - - - - - Gets the index from which the slice starts - - - - - Gets the number of elements contained in the . - - The number of elements contained in the . - - - - Gets a value indicating whether this operates in a reversed direction. - - - true if this operates in a reversed direction; otherwise, false. - - - - - Gets a value indicating whether the is read-only. - - true if the is read-only; otherwise, false. - - - - A class representing a script coroutine - - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as DynValue(s) - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as System.Object. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as the specified type. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - The purpose of this method is to convert a MoonSharp/Lua coroutine to a Unity3D coroutine. - This loops over the coroutine, discarding returned values, and returning null for each invocation. - This means however that the coroutine will be invoked each frame. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - The arguments. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - - Resumes the coroutine - - The ScriptExecutionContext. - The arguments. - - - - - Gets the coroutine stack trace for debug purposes - - The skip. - The entry source reference. - - - - - Gets the type of coroutine - - - - - Gets the coroutine state. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - - Possible types of coroutine - - - - - A valid coroutine - - - - - A CLR callback assigned to a coroutine. - - - - - A CLR callback assigned to a coroutine and already executed. - - - - - Class used to support "tail" continuations - a way for C# / Lua interaction which supports - coroutine yielding (at the expense of a LOT of added complexity in calling code). - - - - - Gets or sets the function to call - - - - - Gets or sets the arguments to the function - - - - - Gets or sets the callback to be used as a continuation. - - - - - Gets or sets the callback to be used in case of errors. - - - - - Gets or sets the error handler to be called before stack unwinding - - - - - Class exposing C# objects as Lua userdata. - For efficiency, a global registry of types is maintained, instead of a per-script one. - - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. - - The assembly. - if set to true extension types are registered to the appropriate registry. - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The type to be unregistered - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The The type to be unregistered - - - - Creates a userdata DynValue from the specified object, using a specific descriptor - - The object - The descriptor. - - - - - Creates a userdata DynValue from the specified object - - The object - - - - - Creates a static userdata DynValue from the specified IUserDataDescriptor - - The IUserDataDescriptor - - - - - Creates a static userdata DynValue from the specified Type - - The type - - - - - Creates a static userdata DynValue from the specified Type - - The Type - - - - - Registers an extension Type (that is a type containing extension methods) - - The type. - The InteropAccessMode. - - - - Gets all the extension methods which can match a given name - - The name. - - - - - Gets a number which gets incremented everytime the extension methods registry changes. - Use this to invalidate caches based on extension methods - - - - - - Gets or sets the "uservalue". See debug.getuservalue and debug.setuservalue. - http://www.lua.org/manual/5.2/manual.html#pdf-debug.setuservalue - - - - - Gets the object associated to this userdata (null for statics) - - - - - Gets the type descriptor of this userdata - - - - - Gets or sets the registration policy to be used in the whole application - - - - - Gets or sets the default access mode to be used in the whole application - - - The default access mode. - - InteropAccessMode is InteropAccessMode.Default - - - - Constants of well known "symbols" in the MoonSharp grammar - - - - - The variadic argument symbol ("...") - - - - - The environment symbol ("_ENV") - - - - - Class wrapping a request to yield a coroutine - - - - - The return values of the coroutine - - - - - Wrapper for a debugger initiated action - - - - - Initializes a new instance of the class. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - The type of action - - - - - Gets the time stamp UTC of this action - - - - - Gets or sets the source identifier this action refers to. - - - - - Gets or sets the source line this action refers to. - - - - - Gets or sets the source column this action refers to. - - - - - Gets the age of this debugger action - - - - - Type of the action - - - - - Step-in at the bytecode level - - - - - Step-over at the bytecode level - - - - - Step-out at the bytecode level - - - - - Step-in at the source level - - - - - Step-over at the source level - - - - - Step-out at the source level - - - - - Continue execution "freely" - - - - - Toggles breakpoint - - - - - Sets a breakpoint - - - - - Clears a breakpoint - - - - - Refresh the data - - - - - Hard refresh of data - - - - - No action - - - - - Interface for debuggers to implement, in order to provide debugging facilities to Scripts. - - - - - Called by the script engine when a source code is added or changed. - - The source code object. - - - - Called by the script engine when the bytecode changes. - - The bytecode source - - - - Called by the script engine at execution time to check if a break has - been requested. Should return pretty fast as it's called A LOT. - - - - - Called by the script engine when a runtime error occurs. - The debugger can return true to signal the engine that it wants to break - into the source of the error. If it does so, it should also return true - to subsequent calls to IsPauseRequested(). - - The runtime exception. - True if this error should break execution. - - - - Called by the script engine to get what action to do next. - - The instruction pointer in bytecode. - The source reference. - T - - - - Called by the script engine when the execution ends. - - - - - Called by the script engine to update watches of a given type. Note - that this method is not called only for watches in the strictest term, - but also for the stack, etc. - - Type of the watch. - The items. - - - - Called by the script engine to get which expressions are active - watches in the debugger. - - A list of watches - - - - Called by the script engine to refresh the breakpoint list. - - - - - Class representing a reference to source code interval - - - - - Gets a value indicating whether this instance is a breakpoint - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets whether the source ref includes the specified location - - Index of the source. - The line. - The column. - - - - - Sets the CannotBreakpoint flag. - - - - - - Formats the location according to script preferences - - The script. - if set to true the classic Lua format is forced. - - - - - Gets a value indicating whether this location is inside CLR . - - - - - Gets the index of the source. - - - - - Gets from which column the source code ref starts - - - - - Gets to which column the source code ref ends - - - - - Gets from which line the source code ref starts - - - - - Gets to which line the source code ref ends - - - - - Gets a value indicating whether this instance is a stop "step" in source mode - - - - - Gets a value indicating whether this instance cannot be set as a breakpoint - - - - - A watch item for the debugger to consume. - Most properties make or not sense depending on the WatchType. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets or sets the address of the item - - - - - Gets or sets the base pointer (base value of v-stack at entering the function). - Valid only for call-stack items - - - - - Gets or sets the return address. - Valid only for call-stack items - - - - - Gets or sets the name of the item - - - - - Gets or sets the value of the item - - - - - Gets or sets the symbol reference of the item - - - - - Gets or sets a value indicating whether this instance is generating an error. - - - - - Gets or sets the source location this item refers to. - - - - - Enumeration of the possible watch types - - - - - A real variable watch - - - - - The status of the v-stack - - - - - The call stack - - - - - The list of coroutines - - - - - The maximum value of this enum - - - - - Enumeration of the possible performance counters - - - - - Measures the time spent parsing the source creating the AST - - - - - Measures the time spent converting ASTs in bytecode - - - - - Measures the time spent in executing scripts - - - - - Measures the on the fly creation/compilation of functions in userdata descriptors - - - - - Sentinel value to get the enum size - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Enumeration of unit of measures of the performance counters - - - - - The performance counter is specified in bytes (of memory) - - - - - The performance counter is specified in milliseconds - - - - - A single object of this type exists for every script and gives access to performance statistics. - - - - - Gets the result of the specified performance counter . - - The PerformanceCounter. - - - - - Starts a stopwatch. - - - - - - Starts a stopwatch. - - - - - - Gets a string with a complete performance log. - - - - - - Gets or sets a value indicating whether this collection of performance stats is enabled. - - - true if enabled; otherwise, false. - - - - - The result of a performance counter - - - - - Returns a that represents this instance. - - - - - Converts a PerformanceCounterType to a string. - - The type. - - - - Gets the name of the performance counter which generated this result. - - - - - Gets the quantity monitored - see Type to understand what this field contains - - - - - Gets the number of instances which led to the specified counter being incremented - e.g. the times a specific - code is executed, or object instanced - - - - - Gets a value indicating whether this is global or relative to the resource - for which it's called. - - - - - Gets the unit of measure of the Counter field. - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Exception thrown when an inconsistent state is reached in the interpreter - - - - - Exception for all parsing/lexing errors. - - - - - Gets or sets a value indicating whether this exception was caused by premature stream termination (that is, unexpected EOF). - This can be used in REPL interfaces to tell between unrecoverable errors and those which can be recovered by extra input. - - - - - This class is a container for arguments received by a CallbackFunction - - - - - Initializes a new instance of the class. - - The arguments. - if set to true [is method call]. - - - - Gets the at the specified index, or null. - - The index. - if set to true all voids are translated to nils. - - - - - Converts the arguments to an array - - The number of elements to skip (default= 0). - - - - - Gets the specified argument as as an argument of the specified type. If not possible, - an exception is raised. - - The argument number. - Name of the function. - The type desired. - if set to true nil values are allowed. - - - - - Gets the specified argument as as an argument of the specified user data type. If not possible, - an exception is raised. - - The desired userdata type - The argument number. - Name of the function. - if set to true nil values are allowed. - - - - - Gets the specified argument as an integer - - The argument number. - Name of the function. - - - - - Gets the specified argument as a string, calling the __tostring metamethod if needed, in a NON - yield-compatible way. - - The execution context. - The argument number. - Name of the function. - - 'tostring' must return a string to '{0}' - - - - Returns a copy of CallbackArguments where the first ("self") argument is skipped if this was a method call, - otherwise returns itself. - - - - - - Gets the count of arguments - - - - - Gets or sets a value indicating whether this is a method call. - - - - - Gets the at the specified index, or Void if not found - - - - - A class representing a script function - - - - - Shortcut for an empty closure - - - - - Initializes a new instance of the class. - - The script. - The index. - The symbols. - The resolved locals. - - - - Calls this function with the specified args - - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Gets a delegate wrapping calls to this scripted function - - - - - - Gets a delegate wrapping calls to this scripted function - - The type of return value of the delegate. - - - - - Gets the number of upvalues in this closure - - The number of upvalues in this closure - - - - Gets the name of the specified upvalue. - - The index of the upvalue. - The upvalue name - - - - Gets the value of an upvalue - - The index of the upvalue. - The value of an upvalue - - - - Gets the type of the upvalues contained in this closure - - - - - - Gets the entry point location in bytecode . - - - - - Gets the script owning this function - - - - - The current closure context - - - - - Type of closure based on upvalues - - - - - The closure has no upvalues (thus, technically, it's a function and not a closure!) - - - - - The closure has _ENV as its only upvalue - - - - - The closure is a "real" closure, with multiple upvalues - - - - - This class wraps a CLR function - - - - - Initializes a new instance of the class. - - The callback function to be called. - The callback name, used in stacktraces, debugger, etc.. - - - - Invokes the callback function - - The execution context. - The arguments. - if set to true this is a method call. - - - - - Creates a CallbackFunction from a delegate. - - The script. - The delegate. - The access mode. - - - - - Creates a CallbackFunction from a MethodInfo relative to a function. - - The script. - The MethodInfo object. - The object to which the function applies, or null for static methods. - The access mode. - - The method is not static. - - - - Checks the callback signature of a method is compatible for callbacks - - - - - Gets the name of the function - - - - - Gets the call back. - - - The call back. - - - - - Gets or sets the default access mode used when marshalling delegates - - - The default access mode. Default, HideMembers and BackgroundOptimized are NOT supported. - - Default, HideMembers and BackgroundOptimized are NOT supported. - - - - Gets or sets an object used as additional data to the callback function (available in the execution context). - - - - - A class representing a value in a Lua/MoonSharp script. - - - - - Creates a new writable value initialized to Nil. - - - - - Creates a new writable value initialized to the specified boolean. - - - - - Creates a new writable value initialized to the specified number. - - - - - Creates a new writable value initialized to the specified string. - - - - - Creates a new writable value initialized to the specified StringBuilder. - - - - - Creates a new writable value initialized to the specified string using String.Format like syntax - - - - - Creates a new writable value initialized to the specified coroutine. - Internal use only, for external use, see Script.CoroutineCreate - - The coroutine object. - - - - - Creates a new writable value initialized to the specified closure (function). - - - - - Creates a new writable value initialized to the specified CLR callback. - - - - - Creates a new writable value initialized to the specified CLR callback. - See also CallbackFunction.FromDelegate and CallbackFunction.FromMethodInfo factory methods. - - - - - Creates a new writable value initialized to the specified table. - - - - - Creates a new writable value initialized to an empty table. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The function to be called. - The arguments. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The data for the tail call. - - - - - Creates a new request for a yield of the current coroutine. - - The yield argumenst. - - - - - Creates a new tuple initialized to the specified values. - - - - - Creates a new tuple initialized to the specified values - which can be potentially other tuples - - - - - Creates a new userdata value - - - - - Returns this value as readonly - eventually cloning it in the process if it isn't readonly to start with. - - - - - Clones this instance. - - - - - - Clones this instance, overriding the "readonly" status. - - if set to true the new instance is set as readonly, or writeable otherwise. - - - - - Clones this instance, returning a writable copy. - - Can't clone Symbol values - - - - Returns a string which is what it's expected to be output by the print function applied to this value. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Casts this DynValue to string, using coercion if the type is number. - - The string representation, or null if not number, not string. - - - - Casts this DynValue to a double, using coercion if the type is string. - - The string representation, or null if not number, not string or non-convertible-string. - - - - Casts this DynValue to a bool - - False if value is false or nil, true otherwise. - - - - Converts a tuple to a scalar value. If it's already a scalar value, this function returns "this". - - - - - Performs an assignment, overwriting the value with the specified one. - - The value. - If the value is readonly. - - - - Gets the length of a string or table value. - - - Value is not a table or string. - - - - Determines whether this instance is nil or void - - - - - Determines whether this instance is not nil or void - - - - - Determines whether this instance is void - - - - - Determines whether this instance is not void - - - - - Determines whether is nil, void or NaN (and thus unsuitable for using as a table key). - - - - - Changes the numeric value of a number DynValue. - - - - - Creates a new DynValue from a CLR object - - The script. - The object. - - - - - Converts this MoonSharp DynValue to a CLR object. - - - - - Converts this MoonSharp DynValue to a CLR object of the specified type. - - - - - Checks the type of this value corresponds to the desired type. A propert ScriptRuntimeException is thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - Name of the function requesting the value, for error message purposes. - The desired data type. - The argument number, for error message purposes. - The TypeValidationFlags. - - Thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - - - Checks if the type is a specific userdata type, and returns it or throws. - - - Name of the function. - The argument number. - The flags. - - - - - Gets a unique reference identifier. This is guaranteed to be unique only for dynvalues created in a single thread as it's not thread-safe. - - - - - Gets the type of the value. - - - - - Gets the function (valid only if the is ) - - - - - Gets the numeric value (valid only if the is ) - - - - - Gets the values in the tuple (valid only if the is Tuple). - This field is currently also used to hold arguments in values whose is . - - - - - Gets the coroutine handle. (valid only if the is Thread). - - - - - Gets the table (valid only if the is ) - - - - - Gets the boolean value (valid only if the is ) - - - - - Gets the string value (valid only if the is ) - - - - - Gets the CLR callback (valid only if the is ) - - - - - Gets the tail call data. - - - - - Gets the yield request data. - - - - - Gets the tail call data. - - - - - Returns true if this instance is write protected. - - - - - A preinitialized, readonly instance, equaling Void - - - - - A preinitialized, readonly instance, equaling Nil - - - - - A preinitialized, readonly instance, equaling True - - - - - A preinitialized, readonly instance, equaling False - - - - - A class representing a key/value pair for Table use - - - - - Initializes a new instance of the struct. - - The key. - The value. - - - - Gets the key. - - - - - Gets or sets the value. - - - - - Gets the nil pair - - - - - Class giving access to details of the environment where the script is executing - - - - - Gets the metatable associated with the given value. - - The value. - - - - - Gets the specified metamethod associated with the given value. - - The value. - The metamethod name. - - - - - prepares a tail call request for the specified metamethod, or null if no metamethod is found. - - - - - Gets the metamethod to be used for a binary operation using op1 and op2. - - - - - Gets the script object associated with this request - - - - - - Gets the coroutine which is performing the call - - - - - Calls a callback function implemented in "classic way". - Useful to port C code from Lua, or C# code from UniLua and KopiLua. - Lua : http://www.lua.org/ - UniLua : http://github.com/xebecnan/UniLua - KopiLua : http://github.com/NLua/KopiLua - - The arguments. - Name of the function - for error messages. - The callback. - - - - - Calls the specified function, supporting most cases. The called function must not yield. - - The function; it must be a Function or ClrFunction or have a call metamethod defined. - The arguments. - - If the function yields, returns a tail call request with continuations/handlers or, of course, if it encounters errors. - - - - Tries to get the reference of a symbol in the current execution state - - - - - Tries to get the value of a symbol in the current execution state - - - - - Finds a symbol by name in the current execution state - - - - - Performs a message decoration before unwinding after an error. To be used in the implementation of xpcall like functions. - - The message handler. - The exception. - - - - Gets a value indicating whether this instance is running a dynamic execution. - Under a dynamic execution, most methods of ScriptExecutionContext are not reliable as the - processing engine of the script is not "really" running or is not available. - - - - - Gets the location of the code calling back - - - - - Gets or sets the additional data associated to this CLR function call. - - - - - Gets the current global env, or null if not found. - - - - - Class representing the source code of a given script - - - - - Gets the code snippet represented by a source ref - - The source code reference. - - - - - Gets the name of the source code - - - - - Gets the source code as a string - - - - - Gets the source code lines. - - - - - Gets the script owning this resource. - - - - - Gets the source identifier inside a script - - - - - State of coroutines - - - - - This is the main coroutine - - - - - Coroutine has not started yet - - - - - Coroutine is suspended - - - - - Coroutine is running - - - - - Coroutine has terminated - - - - - Wrappers for enumerables as return types - - - - - LINQ helper methods - - - - - Converts the specified enumerable dynvalues of a given script type to objects of a given type - - The desired type - The enumerable. - The type. - - - - Filters an enumeration for items of the given script type - - The enumerable. - The script type. - - - - Converts the elements to CLR objects - - The enumerable. - - - - Converts the elements to CLR objects of the desired type - - The desired type - The enumerable. - - - - - - - - - Marks a type of automatic registration as userdata (which happens only if UserData.RegisterAssembly is called). - - - - - Initializes a new instance of the class. - - - - - The interop access mode - - - - - Forces a class member visibility to scripts. Can be used to hide public members or to expose non-public ones. - - - - - Initializes a new instance of the class. - - if set to true the member will be exposed to scripts, if false the member will be hidden. - - - - Gets a value indicating whether this is set to "visible". - - - - - Descriptor which acts as a non-containing adapter from IUserDataType to IUserDataDescriptor - - - - - Initializes a new instance of the class. - - The type. - Name of the friendly. - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Standard descriptor for userdata types. - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - The interop access mode this descriptor uses for members access - A human readable friendly name of the descriptor. - - - - Fills the member list. - - - - - Gets the interop access mode this descriptor uses for members access - - - - - Enumerations of the possible strategies to marshal CLR objects to MoonSharp userdata and functions - when using automatic descriptors. - Note that these are "hints" and MoonSharp is free to ignore the access mode specified (if different from - HideMembers) and downgrade the access mode to "Reflection". - This particularly happens when running on AOT platforms like iOS. - See also : and . - - - - - Optimization is not performed and reflection is used everytime to access members. - This is the slowest approach but saves a lot of memory if members are seldomly used. - - - - - Optimization is done on the fly the first time a member is accessed. - This saves memory for all members that are never accessed, at the cost of an increased script execution time. - - - - - Optimization is done at registration time. - - - - - Optimization is done in a background thread which starts at registration time. - If a member is accessed before optimization is completed, reflection is used. - - - - - No optimization is done, and members are not accessible at all. - - - - - No reflection is allowed, nor code generation. This is used as a safeguard when registering types which should not - use a standard reflection based descriptor - for example for types implementing - - - - - Use the default access mode - - - - - Class providing easier marshalling of CLR functions - - - - - Tries to create a new StandardUserDataMethodDescriptor, returning - null in case the method is not - visible to script code. - - The MethodBase. - The - if set to true forces visibility. - - A new StandardUserDataMethodDescriptor or null. - - - - - Initializes a new instance of the class. - - The MethodBase (MethodInfo or ConstructorInfo) got through reflection. - The interop access mode. - Invalid accessMode - - - - Checks if the method is compatible with a standard descriptor - - The MethodBase. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The method contains unresolved generic parameters, or has an unresolved generic return type - or - The method contains pointer parameters, or has a pointer return type - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function as a DynValue. - - The script for which the callback must be generated. - The object (null for static). - - - - - Creates a callback DynValue starting from a MethodInfo. - - The script. - The mi. - The object. - - - - - The internal callback which actually executes the method - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value. - - The script. - The object. - The v. - - - - - Gets the method information (can be a MethodInfo or ConstructorInfo) - - - - - Gets the access mode used for interop - - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - Gets a value indicating whether the described method is a constructor - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets the types of access supported by this member - - - - - Class providing easier marshalling of CLR properties - - - - - Tries to create a new StandardUserDataPropertyDescriptor, returning null in case the property is not - visible to script code. - - The PropertyInfo. - The - A new StandardUserDataPropertyDescriptor or null. - - - - Initializes a new instance of the class. - NOTE: This constructor gives get/set visibility based exclusively on the CLR visibility of the - getter and setter methods. - - The pi. - The access mode. - - - - Initializes a new instance of the class. - - The PropertyInfo. - The - The getter method. Use null to make the property writeonly. - The setter method. Use null to make the property readonly. - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Gets the PropertyInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance can be read from - - - true if this instance can be read from; otherwise, false. - - - - - Gets a value indicating whether this instance can be written to. - - - true if this instance can be written to; otherwise, false. - - - - - Gets the types of access supported by this member - - - - - The scope of a closure (container of upvalues) - - - - - Gets the symbols. - - - - - Enumeration of the types of SymbolRef - - - - - The symbol ref of a local variable - - - - - The symbol ref of an upvalue variable - - - - - The symbol ref of a global variable - - - - - The symbol ref of the global environment - - - - - This class stores a possible l-value (that is a potential target of an assignment) - - - - - Creates a new symbol reference pointing to a global var - - The name. - The _ENV symbol. - - - - - Creates a new symbol reference pointing to a local var - - The name. - The index of the var in local scope. - - - - - Creates a new symbol reference pointing to an upvalue var - - The name. - The index of the var in closure scope. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Writes this instance to a binary stream - - - - - Reads a symbolref from a binary stream - - - - - Gets the type of this symbol reference - - - - - Gets the index of this symbol in its scope context - - - - - Gets the name of this symbol - - - - - Gets the environment this symbol refers to (for global symbols only) - - - - - Gets the default _ENV. - - - - - Enumeration of possible data types in MoonSharp - - - - - A nil value, as in Lua - - - - - A place holder for no value - - - - - A Lua boolean - - - - - A Lua number - - - - - A Lua string - - - - - A Lua function - - - - - A Lua table - - - - - A set of multiple values - - - - - A userdata reference - that is a wrapped CLR object - - - - - A coroutine handle - - - - - A callback function - - - - - A request to execute a tail call - - - - - A request to coroutine.yield - - - - - Extension methods to DataType - - - - - Determines whether this data type can have type metatables. - - The type. - - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function, with additional values - to support debuggers - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - A script loader loading scripts from an assembly resources - - - - - A base implementation of IScriptLoader, offering resolution of module names. - - - - - Class dictating how requests to read scripts from files are handled. - - It's recommended that no class implement IScriptLoader directly, and rather extend ScriptLoaderBase. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile) - - The modname. - The global context. - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves the name of a module on a set of paths. - - The modname. - The paths. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable (if and only if - the IgnoreLuaPathGlobal is false), and - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - Unpacks a string path in a form like "?;?.lua" to an array - - - - - Gets the default environment paths. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Gets or sets the modules paths used by the "require" function. If null, the default paths are used (using - environment variables etc.). - - - - - Gets or sets a value indicating whether the LUA_PATH global is checked or not to get the path where modules are contained. - If true, the LUA_PATH global is NOT checked. - - - - - Initializes a new instance of the class. - - The assembly containing the scripts as embedded resources or null to use the calling assembly. - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader used for platforms we cannot initialize in any better way.. - - - - - An implementation of which supports a very basic history of recent input lines. - - - - - This class provides a simple REPL intepreter ready to be reused in a simple way. - - - - - Initializes a new instance of the class. - - The script. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - This method returns the result of the computation, or null if more input is needed for a computation. - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "?" as a - dynamic expression to evaluate instead of script code (likely invalid) - - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "=" as a - non-dynamic expression to evaluate (just like the Lua interpreter does by default). - - - - - Gets a value indicating whether this instance has a pending command - - - - - Gets the current pending command. - - - - - Gets the classic prompt (">" or ">>") given the current state of the interpreter - - - - - Initializes a new instance of the class. - - The script. - Size of the history. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - - This method returns the result of the computation, or null if more input is needed for a computation. - - - - - Gets the previous item in history, or null - - - - - Gets the next item in history, or null - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - AND starts with module paths taken from environment variables (again, not going through the platform object). - - The paths are preconstructed using : - * The MOONSHARP_PATH environment variable if it exists - * The LUA_PATH_5_2 environment variable if MOONSHARP_PATH does not exists - * The LUA_PATH environment variable if LUA_PATH_5_2 and MOONSHARP_PATH do not exists - * The "?;?.lua" path if all the above fail - - Also, everytime a module is require(d), the "LUA_PATH" global variable is checked. If it exists, those paths - will be used to load the module instead of the global ones. - - - - - Initializes a new instance of the class. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable, and - - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - A script loader which can load scripts from assets in Unity3D. - Scripts should be saved as .txt files in a subdirectory of Assets/Resources. - - When MoonSharp is activated on Unity3D and the default script loader is used, - scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. - - - - - The default path where scripts are meant to be stored (if not changed) - - - - - Initializes a new instance of the class. - - The path, relative to Assets/Resources. For example - if your scripts are stored under Assets/Resources/Scripts, you should - pass the value "Scripts". If null, "MoonSharp/Scripts" is used. - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - UnityAssetsScriptLoader.LoadFile : Cannot load + file - - - - Checks if a given file exists - - The file. - - - - - Gets the list of loaded scripts filenames (useful for debugging purposes). - - - - - - In a module type, mark fields with this attribute to have them exposed as a module constant. - - See for more information about modules. - - - - - Gets or sets the name of the constant - if different from the name of the field itself - - - - - Namespace containing all the most commonly used classes for MoonSharp operation. - When in doubt, refer to and classes as starting points. - - - - - Namespace containing the implementation of the Lua standard library, as MoonSharp modules. - There's seldom the need to access these classes directly. - - - - - Namespace containing userdata classes for the 'io' module - - - - - Namespace containing classes used to support debuggers - - - - - Namespace containing classes used to support self diagnostics (e.g. performance counters) - - - - - Namespace containing classes used to customize and support advanced interoperations between - scripts and CLR code. - - - - - Namespace containing classes used to provide a minimal support for porting code based on the classic - "LuaState" model (e.g. code based on KopiLua, UniLua or Lua itself). - - - - - Namespace containing classes used to customized how scripts are loaded from external files. - - - - - Namespace containing classes used to customize how the interfacing with the operative system happens - for the 'os' and 'io' modules, and for future modules/classes which may require OS access. - See and . - - - - - Contains classes useful to implement REPL interpreters. - See : - - - - - Interface to abstract all accesses made to the underlying platform (OS, framework) by the scripting engine. - Can be used both to support "non-standard" platforms (i.e. non-posix, non-windows) and/or to sandbox the behaviour - of the scripting engine. - - It's recommended that no class implement IPlatformAccessor directly, and rather extend . - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - Gets the name of the platform (used for debug purposes). - - The name of the platform (used for debug purposes) - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If a meaningful implementation cannot be provided, this method should return null. - - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - The script. - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - True if the file exists, false otherwise. - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - An abstract class which offers basic services on top of IPlatformAccessor to provide easier implementation of platforms. - - - - - Gets the platform name prefix - - - - - - Gets the name of the platform (used for debug purposes). - - - The name of the platform (used for debug purposes) - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - DEPRECATED. - This is kept for backward compatibility, see the overload taking a prompt as an input parameter. - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - A static class offering properties for autodetection of system/platform details - - - - - Gets a value indicating whether this instance is running on mono. - - - - - Gets a value indicating whether this instance is running on a CLR4 compatible implementation - - - - - Gets a value indicating whether this instance is running on Unity-3D - - - - - Gets a value indicating whether this instance has been built as a Portable Class Library - - - - - Gets a value indicating whether this instance is running a system using Ahead-Of-Time compilation - and not supporting JIT. - - - - - A class implementing all the bits needed to have a minimal support of a platform. - This does not support the 'io'/'file' modules and has partial support of the 'os' module. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - A function used to open files in the 'io' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a standard stream (stdin, stdout, stderr). - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The type. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Exits the process, returning the specified exit code. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The exit code. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Checks if a file exists. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - - True if the file exists, false otherwise. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Deletes the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Moves the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The source. - The DST. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The cmdline. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets the platform name prefix - - - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - - Enumeration of standard file handles - - - - - Standard Input - - - - - Standard Output - - - - - Standard Error Output - - - - - Class providing the IPlatformAccessor interface for standard full-feaured implementations. - - - - - Converts a Lua string access mode to a FileAccess enum - - The mode. - - - - - Converts a Lua string access mode to a ParseFileMode enum - - The mode. - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - type - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets the platform name prefix - - - - - - - This class implements a MoonSharp scripting session. Multiple Script objects can coexist in the same program but cannot share - data among themselves unless some mechanism is put in place. - - - - - The version of the MoonSharp engine - - - - - The Lua version being supported - - - - - Initializes the class. - - - - - Initializes a new instance of the clas.s - - - - - Initializes a new instance of the class. - - The core modules to be pre-registered in the default global table. - - - - Loads a string containing a Lua/MoonSharp function. - - The code. - The global table to bind to this chunk. - Name of the function used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a Lua/MoonSharp script from a System.IO.Stream. NOTE: This will *NOT* close the stream! - - The stream containing code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Dumps on the specified stream. - - The function. - The stream. - - function arg is not a function! - or - stream is readonly! - or - function arg has upvalues other than _ENV - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - The filename to be used in error messages. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads and executes a string containing a Lua/MoonSharp script. - - The code. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a stream containing a Lua/MoonSharp script. - - The stream. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a file containing a Lua/MoonSharp script. - - The filename. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Runs the specified file with all possible defaults for quick experimenting. - - The filename. - A DynValue containing the result of the processing of the executed script. - - - - Runs the specified code with all possible defaults for quick experimenting. - - The Lua/MoonSharp code. - A DynValue containing the result of the processing of the executed script. - - - - Creates a closure from a bytecode address. - - The address. - The env table to create a 0-upvalue - - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Gets the main chunk function. - - A DynValue containing a function which executes the first chunk that has been loaded. - - - - Attaches a debugger. This usually should be called by the debugger itself and not by user code. - - The debugger object. - - - - Gets the source code. - - The source code identifier. - - - - - Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html - - The module name - The global context. - - Raised if module is not found - - - - Gets a type metatable. - - The type. - - - - - Sets a type metatable. - - The type. Must be Nil, Boolean, Number, String or Function - The metatable. - Specified type not supported : + type.ToString() - - - - Warms up the parser/lexer structures so that MoonSharp operations start faster. - - - - - Creates a new dynamic expression. - - The code of the expression. - - - - - Creates a new dynamic expression which is actually quite static, returning always the same constant value. - - The code of the not-so-dynamic expression. - The constant to return. - - - - - Gets an execution context exposing only partial functionality, which should be used for - those cases where the execution engine is not really running - for example for dynamic expression - or calls from CLR to CLR callbacks - - - - - Gets or sets the script loader which will be used as the value of the - ScriptLoader property for all newly created scripts. - - - - - Gets access to the script options. - - - - - Gets the global options, that is options which cannot be customized per-script. - - - - - Gets access to performance statistics. - - - - - Gets the default global table for this script. Unless a different table is intentionally passed (or setfenv has been used) - execution uses this table. - - - - - Gets the source code count. - - - The source code count. - - - - - MoonSharp (like Lua itself) provides a registry, a predefined table that can be used by any CLR code to - store whatever Lua values it needs to store. - Any CLR code can store data into this table, but it should take care to choose keys - that are different from those used by other libraries, to avoid collisions. - Typically, you should use as key a string GUID, a string containing your library name, or a - userdata with the address of a CLR object in your code. - - - - - A class representing a Lua table. - - - - - Initializes a new instance of the class. - - The owner script. - - - - Removes all items from the Table. - - - - - Gets the integral key from a double. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) - - The key. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) as a System.Object. - - The key. - - - - - Sets the dynvalue associated with the specified key. Both expressed as System.Object. - - The key. - The value. - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Gets the value associated with the specified key, without bringing to Nil the non-existant values. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Collects the dead keys. This frees up memory but invalidates pending iterators. - It's called automatically internally when the semantics of Lua tables allow, but can be forced - externally if it's known that no iterators are pending. - - - - - Returns the next pair from a value - - - - - Gets the script owning this resource. - - - - - Gets or sets the - with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - Multiple keys can be used to access subtables. - - - The . - - The key. - Optional subkeys to access subtables - - - - - Gets or sets the with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - - - The . - - The key. - - - - - Gets the length of the "array part". - - - - - Gets the meta-table associated with this instance. - - - - - Enumerates the key/value pairs. - - - - - - Enumerates the keys. - - - - - - Enumerates the values - - - - - - A preallocated, non-resizable, stack - - - - - - Enumeration (combinable as flags) of all the standard library modules - - - - - Value used to specify no modules to be loaded (equals 0). - - - - - The basic methods. Includes "assert", "collectgarbage", "error", "print", "select", "type", "tonumber" and "tostring". - - - - - The global constants: "_G", "_VERSION" and "_MOONSHARP". - - - - - The table iterators: "next", "ipairs" and "pairs". - - - - - The metatable methods : "setmetatable", "getmetatable", "rawset", "rawget", "rawequal" and "rawlen". - - - - - The string package - - - - - The load methods: "load", "loadsafe", "loadfile", "loadfilesafe", "dofile" and "require" - - - - - The table package - - - - - The error handling methods: "pcall" and "xpcall" - - - - - The math package - - - - - The coroutine package - - - - - The bit32 package - - - - - The time methods of the "os" package: "clock", "difftime", "date" and "time" - - - - - The methods of "os" package excluding those listed for OS_Time. These are not supported under Unity. - - - - - The methods of "io" and "file" packages. These are not supported under Unity. - - - - - The "debug" package (it has limited support) - - - - - The "dynamic" package (introduced by MoonSharp). - - - - - A sort of "hard" sandbox preset, including string, math, table, bit32 packages, constants and table iterators. - - - - - A softer sandbox preset, adding metatables support, error handling, coroutine, time functions and dynamic evaluations. - - - - - The default preset. Includes everything except "debug" as now. - Beware that using this preset allows scripts unlimited access to the system. - - - - - The complete package. - Beware that using this preset allows scripts unlimited access to the system. - - - - - Class managing modules (mostly as extension methods) - - - - - Register the core modules to a table - - The table. - The modules. - - - - - Registers the standard constants (_G, _VERSION, _MOONSHARP) to a table - - The table. - - - - - Registers a module type to the specified table - - The table. - The type - - If the module contains some incompatibility - - - - Registers a module type to the specified table - - The module type - The table. - - If the module contains some incompatibility - - - - In a module type, mark methods or fields with this attribute to have them exposed as module functions. - Methods must have the signature "public static DynValue ...(ScriptExecutionContextCallbackArguments)". - Fields must be static or const strings, with an anonymous Lua function inside. - - See for more information about modules. - - - - - Gets or sets the name of the function in the module (defaults to member name) - - - - - Marks a CLR type to be a MoonSharp module. - Modules are the fastest way to bring interop between scripts and CLR code, albeit at the cost of a very increased - complexity in writing them. Modules is what's used for the standard library, for maximum efficiency. - - Modules are basically classes containing only static methods, with the callback function signature. - - See and for (extension) methods used to register modules to a - table. - - See for information regarding the standard callback signature along with easier ways - to marshal methods. - - See for easier object marshalling. - - - - - Gets or sets the namespace, that is the name of the table which will contain the defined functions. - Can be null to be in the global table. - - - - - Class containing script global options, that is options which cannot be customized per-script. - - - - - - Gets or sets the custom converters. - - - - - Gets or sets the platform abstraction to use. - - - The current platform abstraction. - - - - - This class contains options to customize behaviour of Script objects. - - - - - Gets or sets the current script-loader. - - - - - Gets or sets the debug print handler - - - - - Gets or sets the debug input handler (takes a prompt as an input, for interactive interpreters, like debug.debug). - - - - - Gets or sets a value indicating whether error messages will use Lua error locations instead of MoonSharp - improved ones. Use this for compatibility with legacy Lua code which parses error messages. - - - - - Gets or sets the stream used as stdin. If null, a default stream is used. - - - - - Gets or sets the stream used as stdout. If null, a default stream is used. - - - - - Gets or sets the stream used as stderr. If null, a default stream is used. - - - - - Gets or sets the stack depth threshold at which MoonSharp starts doing - tail call optimizations. - TCOs can provide the little benefit of avoiding stack overflows in corner case - scenarios, at the expense of losing debug information and error stack traces - in all other, more common scenarios. MoonSharp choice is to start performing - TCOs only after a certain threshold of stack usage is reached - by default - half the current stack depth (128K entries), thus 64K entries, on either - the internal stacks. - Set this to int.MaxValue to disable TCOs entirely, or to 0 to always have - TCOs enabled. - - - - - Gets or sets a value indicating whether the thread check is enabled. - A "lazy" thread check is performed everytime execution is entered to ensure that no two threads - calls MoonSharp execution concurrently. However 1) the check is performed best effort (thus, it might - not detect all issues) and 2) it might trigger in very odd legal situations (like, switching threads - inside a CLR-callback without actually having concurrency. - - Disable this option if the thread check is giving problems in your scenario, but please check that - you are not calling MoonSharp execution concurrently as it is not supported. - - - - - Primaries the exp. - - The lcontext. - - - - - - - - - - Creates a sub tree of binary expressions - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net40-client/MoonSharp.Interpreter.xml b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net40-client/MoonSharp.Interpreter.xml deleted file mode 100644 index 51902bef..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/net40-client/MoonSharp.Interpreter.xml +++ /dev/null @@ -1,6529 +0,0 @@ - - - - MoonSharp.Interpreter - - - - - Class implementing coroutine Lua functions - - - - - Class implementing basic Lua functions (print, type, tostring, etc) as a MoonSharp module. - - - - - Class implementing debug Lua functions. Support for the debug module is partial. - - - - - Class implementing dynamic expression evaluations at runtime (a MoonSharp addition). - - - - - Class implementing error handling Lua functions (pcall and xpcall) - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - A base class for many MoonSharp objects. - Helds a ReferenceID property which gets a different value for every object instance, for debugging - purposes. Note that the ID is not assigned in a thread safe manner for speed reason, so the IDs - are guaranteed to be unique only if everything is running on one thread at a time. - - - - - Formats a string with a type name and a ref-id - - The type name. - - - - - Gets the reference identifier. - - - The reference identifier. - - - - - Class implementing io Lua functions. Proper support requires a compatible IPlatformAccessor - - - - - Abstract class implementing an unclosable file Lua userdata. Methods are meant to be called by Lua code. - - - - - Class implementing loading Lua functions like 'require', 'load', etc. - - - - - Class implementing bit32 Lua functions - - - - - Class implementing math Lua functions - - - - - Class implementing metatable related Lua functions (xxxmetatable and rawxxx). - - - - - Class implementing system related Lua functions from the 'os' module. - Proper support requires a compatible IPlatformAccessor - - - - - Class implementing time related Lua functions from the 'os' module. - - - - - Classes using the classic interface should inherit from this class. - This class defines only static methods and is really meant to be used only - from C# and not other .NET languages. - - For easier operation they should also define: - using ptrdiff_t = System.Int32; - using lua_Integer = System.Int32; - using LUA_INTFRM_T = System.Int64; - using UNSIGNED_LUA_INTFRM_T = System.UInt64; - - - - - Calls a function. - To call a function you must use the following protocol: first, the function to be called is pushed onto the stack; then, - the arguments to the function are pushed in direct order; that is, the first argument is pushed first. Finally you call - lua_call; nargs is the number of arguments that you pushed onto the stack. All arguments and the function value are - popped from the stack when the function is called. The function results are pushed onto the stack when the function - returns. The number of results is adjusted to nresults, unless nresults is LUA_MULTRET. In this case, all results from - the function are pushed. Lua takes care that the returned values fit into the stack space. The function results are - pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is on - the top of the stack. - - The LuaState - The number of arguments. - The number of expected results. - - - - - A Dictionary where multiple values can be associated to the same key - - The key type - The value type - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The equality comparer to use in the underlying dictionary. - - - - Adds the specified key. Returns true if this is the first value for a given key - - The key. - The value. - - - - - Finds all the values associated with the specified key. - An empty collection is returned if not found. - - The key. - - - - Determines whether this contains the specified key - - The key. - - - - Clears this instance. - - - - - Removes the specified key and all its associated values from the multidictionary - - The key. - - - - Removes the value. Returns true if the removed value was the last of a given key - - The key. - The value. - - - - - Gets the keys. - - - - - Implementation of IEqualityComparer enforcing reference equality - - - - - Marks a method as the handler of metamethods of a userdata type - - - - - Initializes a new instance of the class. - - The metamethod name (like '__div', '__ipairs', etc.) - - - - The metamethod name (like '__div', '__ipairs', etc.) - - - - - Base interface to describe access to members of a given type. - While it's not infrastructural to implement custom type descriptors, it's needed for - classes extending . - - - - - Gets the value of this member as a to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value of this member as a . - - - - Sets the value of this member from a . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Extension methods for and . - - - - - Determines whether the specified MemberDescriptorAccess has ALL the specified flags. - - The access. - The flag. - - - - - Determines whether this instance can be read - - The descriptor instance. - - - - - Determines whether this instance can be written to - - The descriptor instance. - - - - - Determines whether this instance can be executed (called as a function) - - The descriptor instance. - - - - - Gets the getter of the member as a DynValue containing a callback - - The descriptor instance. - The script. - The object. - - - - - Returns the specified descriptor if it supports all the specified access modes, otherwise returns null. - - The descriptor instance. - The access mode(s). - - - - - Raises an appropriate ScriptRuntimeException if the specified access is not supported. - Checks are made for the MemberDescriptorAccess permissions AND for the access of instance - members through static userdatas. - - The desc. - The access. - The object to be checked for access. - - - - Interface for descriptors of any kind which support optimizations of their implementation according to InteropAccessMode - modes. This should seldom - if ever - be implemented in user code. - - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Specialized for members supporting overloads resolution. - - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Permissions for members access - - - - - The member can be read from - - - - - The member can be written to - - - - - The can be invoked - - - - - Descriptor of parameters used in implementations. - - - - - If the type got restricted, the original type before the restriction. - - - - - Initializes a new instance of the class. - - The name. - The type. - if set to true the parameter has default value. - The default value. - if set to true, is an out param. - - - - Initializes a new instance of the class. - - A ParameterInfo taken from reflection. - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Restricts the type of this parameter to a tighter constraint. - Restrictions must be applied before the containing this - parameter is used in any way. - - The new type. - - Cannot restrict a ref/out param - or - Specified operation is not a restriction - - - - - Gets the name of the parameter - - - - - Gets the type of the parameter - - - - - Gets a value indicating whether this instance has a default value. - - - - - Gets the default value - - - - - Gets a value indicating whether this instance is an out parameter - - - - - Gets a value indicating whether this instance has been restricted. - - - - - Gets the original type of the parameter before any restriction has been applied. - - - - - Tries to convert a CLR object to a MoonSharp value, using "simple" logic. - Does NOT throw on failure. - - - - - Tries to convert a CLR object to a MoonSharp value, using more in-depth analysis - - - - - Converts an IEnumerable or IEnumerator to a DynValue - - The script. - The object. - - - - - Static functions to handle conversions of numeric types - - - - - HashSet of numeric types - - - - - Array of numeric types in order used for some conversions - - - - - Converts a double to another type - - - - - Converts a type to double - - - - - Converts a DynValue to a CLR object [simple conversion] - - - - - Converts a DynValue to a CLR object of a specific type - - - - - Gets a relative weight of how much the conversion is matching the given types. - Implementation must follow that of DynValueToObjectOfType.. it's not very DRY in that sense. - However here we are in perf-sensitive path.. TODO : double-check the gain and see if a DRY impl is better. - - - - - Converts an IList to a Lua table. - - - - - Converts an IDictionary to a Lua table. - - - - - Determines whether the specified table can be converted to the specified type - - The table. - The type. - - - - - Converts a table to a CLR object of a given type - - - - - Converts a table to a - - - - - Converts a table to a T[] - - - - - Converts a table to a - - - - - Converts a table to a , known in advance - - - - - Converts a table to a Dictionary, known in advance - - - - - A collection of custom converters between MoonSharp types and CLR types. - If a converter function is not specified or returns null, the standard conversion path applies. - - - - - Sets a custom converter from a script data type to a CLR data type. Set null to remove a previous custom converter. - - The script data type - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a script data type to a CLR data type, or null - - The script data type - The CLR data type. - The converter function, or null if not found - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a CLR data type, or null - - Type of the color data. - The converter function, or null if not found - - - - Removes all converters. - - - - - Helper extension methods used to simplify some parts of userdata descriptor implementations - - - - - Determines whether a - is changing visibility of a member - to scripts. - - The member to check. - - true if visibility is forced visible, - false if visibility is forced hidden or the specified MemberInfo is null, - if no attribute was found - - - - - Determines whether the specified PropertyInfo is visible publicly (either the getter or the setter is public). - - The PropertyInfo. - - - - - Gets the list of metamethod names from attributes - in practice the list of metamethods declared through - . - - The mi. - - - - - Gets the name of a conversion method to be exposed to Lua scripts - - The type. - - - - - An abstract user data descriptor which accepts members described by objects and - correctly dispatches to them. - Metamethods are also by default dispatched to operator overloads and other similar methods - see - . - - - - - Interface used by MoonSharp to access objects of a given type from scripts. - - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - The special name used by CLR for indexer getters - - - - - The special name used by CLR for indexer setters - - - - - The special name used by CLR for explicit cast conversions - - - - - The special name used by CLR for implicit cast conversions - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - A friendly name for the type, or null. - - - - Adds a member to the meta-members list. - - The name of the metamethod. - The desc. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Adds a DynValue as a member - - The name. - The value. - - - - Adds a property to the member list - - The name. - The descriptor. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Performs an "index" "get" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing operation by checking newly added extension methods for the given indexName. - - The script. - The object. - Member name to be indexed. - - - - - - Determines whether the descriptor contains the specified member (by exact name) - - Name of the member. - - - - - Determines whether the descriptor contains the specified member in the meta list (by exact name) - - Name of the meta-member. - - - - - Tries to perform an indexing operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - - - - - Performs an "index" "set" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing "set" operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - The value. - - - - - Converts the specified name from underscore_case to camelCase. - - The name. - - - - - Converts the specified name to one with an uppercase first letter (something to Something). - - The name. - - - - - Converts this userdata to string - - The object. - - - - - Executes the specified indexer method. - - The method descriptor - The script. - The object. - The indexer parameter - The dynvalue to set on a setter, or null. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - See for further details. - - If a method exists marked with for the specific - metamethod requested, that method is returned. - - If the above fails, the following dispatching occur: - - __add, __sub, __mul, __div, __mod and __unm are dispatched to C# operator overloads (if they exist) - __eq is dispatched to System.Object.Equals. - __lt and __le are dispatched IComparable.Compare, if the type implements IComparable or IComparable{object} - __len is dispatched to Length and Count properties, if those exist. - __iterator is handled if the object implements IEnumerable or IEnumerator. - __tonumber is dispatched to implicit or explicit conversion operators to standard numeric types. - __tobool is dispatched to an implicit or explicit conversion operator to bool. If that fails, operator true is used. - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Gets a human readable friendly name of the descriptor - - - - - Standard descriptor for Enum values - - - - - Initializes a new instance of the class. - - Type of the enum. - Name of the friendly. - enumType must be an enum! - - - - Fills the member list. - - - - - Adds an enum method to the object - - The name. - The dyn value. - - - - Gets the value of the enum as a long - - - - - Gets the value of the enum as a ulong - - - - - Creates an enum value from a long - - - - - Creates an enum value from a ulong - - - - - Creates conversion functions for signed enums - - - - - Creates conversion functions for unsigned enums - - - - - Determines whether the specified object is compatible with the specified type. - - The type. - The object. - - - - - Gets a "meta" operation on this userdata. - In this specific case, only the concat operator is supported, only on flags enums and it implements the - 'or' operator. - - - - - - - - - Gets the underlying type of the enum. - - - - - Gets a value indicating whether underlying type of the enum is unsigned. - - - - - Gets a value indicating whether this instance describes a flags enumeration. - - - - - Class providing a simple descriptor for constant DynValues in userdata - - - - - Initializes a new instance of the class. - - The name. - The value. - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - userdata '{0}' cannot be written to. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Gets the value wrapped by this descriptor - - - - - Class providing easier marshalling of CLR events. Handling is limited to a narrow range of handler signatures, which, - however, covers in practice most of all available events. - - - - - The maximum number of arguments supported in an event handler delegate - - - - - Tries to create a new StandardUserDataEventDescriptor, returning null in case the method is not - visible to script code. - - The EventInfo. - The - A new StandardUserDataEventDescriptor or null. - - - - Checks if the event is compatible with a standard descriptor - - The EventInfo. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The event is declared in a value type - or - The event does not have both add and remove methods - or - The event handler type doesn't implement a public Invoke method - or - The event handler has a return type which is not System.Void - or - The event handler has more than MAX_ARGS_IN_DELEGATE parameters - or - The event handler has a value type parameter or a by ref parameter - or - The event handler signature is not a valid method according to - - - - - Initializes a new instance of the class. - - The ei. - The access mode. - - - - Gets a dynvalue which is a facade supporting add/remove methods which is callable from scripts - - The script. - The object for which the facade should be written. - - - - - Sets the value. - - The script. - The object. - The v. - - - - Gets the EventInfo object of the event described by this descriptor - - - - - Gets a value indicating whether the event described by this descriptor is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - As a convenience, every type deriving from IUserDataType is "self-described". That is, no descriptor is needed/generated - and the object itself is used to describe the type for interop. See also , - and . - - - - - Performs an "index" "get" operation. - - The script originating the request - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The name of the metamember. - - - - - Class providing easier marshalling of overloaded CLR functions - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptor of the first overloaded method. - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptors of the overloaded methods. - - - - Sets the extension methods snapshot. - - The version. - The ext methods. - - - - Adds an overload. - - The overload. - - - - Performs the overloaded call. - - The script. - The object. - The context. - The arguments. - - function call doesn't match any overload - - - - Calculates the score for the overload. - - The context. - The arguments. - The method. - if set to true, is an extension method. - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - - - - - Gets or sets a value indicating whether this instance ignores extension methods. - - - - - Gets the name of the first described overload - - - - - Gets the name of the first described overload - - - - - Gets the number of overloaded methods contained in this collection - - - The overload count. - - - - - Gets a value indicating whether there is at least one static method in the resolution list - - - - - - Gets the types of access supported by this member - - - - - Comparer class for IOverloadableMemberDescriptor - - - - - Class providing easier marshalling of CLR fields - - - - - Tries to create a new StandardUserDataFieldDescriptor, returning null in case the field is not - visible to script code. - - The FieldInfo. - The - A new StandardUserDataFieldDescriptor or null. - - - - Initializes a new instance of the class. - - The FieldInfo. - The - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Gets the FieldInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance is a constant - - - - - Gets a value indicating whether this instance is readonly - - - - - Gets the types of access supported by this member - - - - - Member descriptor for the default constructor of value types. - - - - - Initializes a new instance of the - class - representing the default empty ctor for a value type. - - Type of the value. - valueType is not a value type - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a - to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a - . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - This property is equal to the value type to be constructed. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the types of access supported by this member - - - - - "Optimized" BinaryReader which shares strings and use a dumb compression for integers - - - - - "Optimized" BinaryWriter which shares strings and use a dumb compression for integers - - - - - An adapter over Stream which bypasses the Dispose and Close methods. - Used to work around the pesky wrappers .NET has over Stream (BinaryReader, StreamWriter, etc.) which think they - own the Stream and close them when they shouldn't. Damn. - - - - - Enumerations of the possible policies to handle UserData type registrations - See also : . - - - - - Types must be explicitly registered. If a base type or interface is registered, that is used. - - - - - Types are automatically registered if not found in the registry. This is easier to use but potentially unsafe. - - - - - A Delegate type which can wrap a script function - - The arguments. - The return value of the script function - - - - A Delegate type which can wrap a script function with a generic typed return value - - - The arguments. - The return value of the script function - - - - Flags to alter the way the DynValue.CheckType and other related functions operate on data types for - validation. - - - - - No type validation specific behaviour - - - - - Nil and Void values are allowed (and returned by the call) - - - - - Simple autoconversions are attempted: - 1) Numbers are convertible to strings - 2) Strings are convertible to numbers if they contain a number - 3) Everything is convertible to boolean (with void and nil converting to 'false', everything else converting to 'true') - Note: if both AutoConvert and AllowNil are specified, nils will NOT be converted to false booleans. - - - - - The default : Autoconverting values, no nils. - - - - - Exception thrown when a dynamic expression is invalid - - - - - Exception for all runtime errors. In addition to constructors, it offers a lot of static methods - generating more "standard" Lua errors. - - - - - Base type of all exceptions thrown in MoonSharp - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Gets the instruction pointer of the execution (if it makes sense) - - - - - Gets the interpreter call stack. - - - - - Gets the decorated message (error message plus error location in script) if possible. - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an arithmetic operation was attempted on non-numbers - - The left operand. - The right operand (or null). - The exception to be raised. - If both are numbers - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a concat operation was attempted on non-strings - - The left operand. - The right operand. - The exception to be raised. - If both are numbers or strings - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a len operator was applied on an invalid operand - - The operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a comparison operator was applied on an invalid combination of operand types - - The left operand. - The right operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The error message. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad userdata argument - - The argument number (0-based). - Name of the function generating this error. - The expected System.Type. - The object which was used. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - The data type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected type description. - The description of the type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - - This function creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - while creates a message like "bad argument #xxx to 'yyy' (value expected)" - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an out of range index was specified - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a negative number when a positive one was expected. - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - This function creates a message like "bad argument #xxx to 'yyy' (value expected)" - while creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an invalid attempt to index the specified object was made - - The object. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __index over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __newindex over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __call over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used nil as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used a NaN as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion to number failed. - - - Selects the correct error message: - 0 - "value must be a number" - 1 - "'for' initial value must be a number" - 2 - "'for' step must be a number" - 3 - "'for' limit must be a number" - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a CLR type to a Lua type has failed. - - The object which could not be converted. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a Lua type to a CLR type has failed. - - The Lua type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a constrained conversion of a Lua type to a CLR type has failed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a userdata of a specific CLR type was expected and a non-userdata type was passed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to index an invalid member of a userdata was done. - - The name of the userdata type. - The field name. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt resume a coroutine in an invalid state was done. - - The state of the coroutine. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield across a CLR boundary was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield from the main coroutine was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to call a non-function was made - - The lua non-function data type. - The debug text to aid location (appears as "near 'xxx'"). - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The member descriptor. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The type descriptor. - The member descriptor. - - - - - Gets or sets a value indicating whether the message should not be decorated - - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Initializes a new instance of the class. - - The message. - - - - Represents a dynamic expression in the script - - - - - Common interface for all resources which are uniquely bound to a script. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - The code which generated this expression - - - - - Evaluates the expression - - The context. - - - - - Finds a symbol in the expression - - The context. - - - - - Determines whether this instance is a constant expression - - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - Internal type used by for registration - - - - - Wrapper which allows for easier management of userdata without registering a new userdata type - useful - if a type which is not exposed to scripts but can be managed as a "black box" by scripts is desired. - - The type to wrap - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The o. - - - - Gets or sets the value this instance wraps. - - - - - Determines whether the specified value is of numeric type. - - The object to check. - - true if o is a numeric type; otherwise, false. - - - - - Determines whether the specified value is positive. - - The value. - if set to true treats 0 as positive. - - true if the specified value is positive; otherwise, false. - - - - - Converts the specified values boxed type to its correpsonding unsigned - type. - - The value. - A boxed numeric object whos type is unsigned. - - - - Converts the specified values boxed type to its correpsonding integer - type. - - The value. - if set to true [round]. - - A boxed numeric object whos type is an integer type. - - - - - Replaces the string representations of meta chars with their corresponding - character values. - - The input. - A string with all string meta chars are replaced - - - - Class implementing string Lua functions - - - - - Class implementing table Lua iterators (pairs, ipairs, next) - - - - - Class implementing table Lua functions - - - - - Class exposing table.unpack and table.pack in the global namespace (to work around the most common Lua 5.1 compatibility issue). - - - - - Extension methods used in the whole project. - - - - - Gets a value from the dictionary or returns the default value - - The type of the key. - The type of the value. - The dictionary. - The key. - - - - - Gets a value from the dictionary or creates it - - The type of the key. - The type of the value. - The dictionary. - The key. - A function which will create the value if it doesn't exist. - - - - - A non preallocated, non_fixed size stack - - - - - - An index to accelerate operations on a LinkedList using a single key of type - More than one LinkedListIndex can index the same linked list, but every node in the linked list must be indexed by one and only one - LinkedListIndex object. - - The type of the key. Must implement Equals and GetHashCode appropriately. - The type of the values contained in the linked list. - - - - Initializes a new instance of the class. - - The linked list to be indexed. - - - - Finds the node indexed by the specified key, or null. - - The key. - - - - Updates or creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - The previous value of the element - - - - Creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - - - - Removes the specified key from the index, and the node indexed by the key from the linked list. - - The key. - - - - Determines whether the index contains the specified key. - - The key. - - - - Clears this instance (removes all elements) - - - - - Provides facility to create a "sliced" view over an existing IList - - The type of the items contained in the collection - - - - Initializes a new instance of the class. - - The list to apply the Slice view on - From which index - The length of the slice - if set to true the view is in reversed order. - - - - Calculates the real index in the underlying collection - - - - - Returns an enumerator that iterates through the collection. - - - A that can be used to iterate through the collection. - - - - - Returns an enumerator that iterates through a collection. - - - An object that can be used to iterate through the collection. - - - - - Converts to an array. - - - - - Converts to an list. - - - - - Determines the index of a specific item in the . - - The object to locate in the . - - The index of if found in the list; otherwise, -1. - - - - - Inserts an item to the at the specified index. - - The zero-based index at which should be inserted. - The object to insert into the . - Slices are readonly - - - - Removes the item at the specified index. - - The zero-based index of the item to remove. - Slices are readonly - - - - Adds an item to the . - - The object to add to the . - Slices are readonly - - - - Removes all items from the . - - Slices are readonly - - - - Determines whether the contains a specific value. - - The object to locate in the . - - true if is found in the ; otherwise, false. - - - - - Copies to. - - The array. - Index of the array. - - - - Removes the first occurrence of a specific object from the . - - The object to remove from the . - - true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original . - - Slices are readonly - - - - Gets or sets the element at the specified index. - - The index. - - - - - Gets the index from which the slice starts - - - - - Gets the number of elements contained in the . - - The number of elements contained in the . - - - - Gets a value indicating whether this operates in a reversed direction. - - - true if this operates in a reversed direction; otherwise, false. - - - - - Gets a value indicating whether the is read-only. - - true if the is read-only; otherwise, false. - - - - A class representing a script coroutine - - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as DynValue(s) - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as System.Object. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as the specified type. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - The purpose of this method is to convert a MoonSharp/Lua coroutine to a Unity3D coroutine. - This loops over the coroutine, discarding returned values, and returning null for each invocation. - This means however that the coroutine will be invoked each frame. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - The arguments. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - - Resumes the coroutine - - The ScriptExecutionContext. - The arguments. - - - - - Gets the coroutine stack trace for debug purposes - - The skip. - The entry source reference. - - - - - Gets the type of coroutine - - - - - Gets the coroutine state. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - - Possible types of coroutine - - - - - A valid coroutine - - - - - A CLR callback assigned to a coroutine. - - - - - A CLR callback assigned to a coroutine and already executed. - - - - - Class used to support "tail" continuations - a way for C# / Lua interaction which supports - coroutine yielding (at the expense of a LOT of added complexity in calling code). - - - - - Gets or sets the function to call - - - - - Gets or sets the arguments to the function - - - - - Gets or sets the callback to be used as a continuation. - - - - - Gets or sets the callback to be used in case of errors. - - - - - Gets or sets the error handler to be called before stack unwinding - - - - - Class exposing C# objects as Lua userdata. - For efficiency, a global registry of types is maintained, instead of a per-script one. - - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. - - The assembly. - if set to true extension types are registered to the appropriate registry. - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The type to be unregistered - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The The type to be unregistered - - - - Creates a userdata DynValue from the specified object, using a specific descriptor - - The object - The descriptor. - - - - - Creates a userdata DynValue from the specified object - - The object - - - - - Creates a static userdata DynValue from the specified IUserDataDescriptor - - The IUserDataDescriptor - - - - - Creates a static userdata DynValue from the specified Type - - The type - - - - - Creates a static userdata DynValue from the specified Type - - The Type - - - - - Registers an extension Type (that is a type containing extension methods) - - The type. - The InteropAccessMode. - - - - Gets all the extension methods which can match a given name - - The name. - - - - - Gets a number which gets incremented everytime the extension methods registry changes. - Use this to invalidate caches based on extension methods - - - - - - Gets or sets the "uservalue". See debug.getuservalue and debug.setuservalue. - http://www.lua.org/manual/5.2/manual.html#pdf-debug.setuservalue - - - - - Gets the object associated to this userdata (null for statics) - - - - - Gets the type descriptor of this userdata - - - - - Gets or sets the registration policy to be used in the whole application - - - - - Gets or sets the default access mode to be used in the whole application - - - The default access mode. - - InteropAccessMode is InteropAccessMode.Default - - - - Constants of well known "symbols" in the MoonSharp grammar - - - - - The variadic argument symbol ("...") - - - - - The environment symbol ("_ENV") - - - - - Class wrapping a request to yield a coroutine - - - - - The return values of the coroutine - - - - - Wrapper for a debugger initiated action - - - - - Initializes a new instance of the class. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - The type of action - - - - - Gets the time stamp UTC of this action - - - - - Gets or sets the source identifier this action refers to. - - - - - Gets or sets the source line this action refers to. - - - - - Gets or sets the source column this action refers to. - - - - - Gets the age of this debugger action - - - - - Type of the action - - - - - Step-in at the bytecode level - - - - - Step-over at the bytecode level - - - - - Step-out at the bytecode level - - - - - Step-in at the source level - - - - - Step-over at the source level - - - - - Step-out at the source level - - - - - Continue execution "freely" - - - - - Toggles breakpoint - - - - - Sets a breakpoint - - - - - Clears a breakpoint - - - - - Refresh the data - - - - - Hard refresh of data - - - - - No action - - - - - Interface for debuggers to implement, in order to provide debugging facilities to Scripts. - - - - - Called by the script engine when a source code is added or changed. - - The source code object. - - - - Called by the script engine when the bytecode changes. - - The bytecode source - - - - Called by the script engine at execution time to check if a break has - been requested. Should return pretty fast as it's called A LOT. - - - - - Called by the script engine when a runtime error occurs. - The debugger can return true to signal the engine that it wants to break - into the source of the error. If it does so, it should also return true - to subsequent calls to IsPauseRequested(). - - The runtime exception. - True if this error should break execution. - - - - Called by the script engine to get what action to do next. - - The instruction pointer in bytecode. - The source reference. - T - - - - Called by the script engine when the execution ends. - - - - - Called by the script engine to update watches of a given type. Note - that this method is not called only for watches in the strictest term, - but also for the stack, etc. - - Type of the watch. - The items. - - - - Called by the script engine to get which expressions are active - watches in the debugger. - - A list of watches - - - - Called by the script engine to refresh the breakpoint list. - - - - - Class representing a reference to source code interval - - - - - Gets a value indicating whether this instance is a breakpoint - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets whether the source ref includes the specified location - - Index of the source. - The line. - The column. - - - - - Sets the CannotBreakpoint flag. - - - - - - Formats the location according to script preferences - - The script. - if set to true the classic Lua format is forced. - - - - - Gets a value indicating whether this location is inside CLR . - - - - - Gets the index of the source. - - - - - Gets from which column the source code ref starts - - - - - Gets to which column the source code ref ends - - - - - Gets from which line the source code ref starts - - - - - Gets to which line the source code ref ends - - - - - Gets a value indicating whether this instance is a stop "step" in source mode - - - - - Gets a value indicating whether this instance cannot be set as a breakpoint - - - - - A watch item for the debugger to consume. - Most properties make or not sense depending on the WatchType. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets or sets the address of the item - - - - - Gets or sets the base pointer (base value of v-stack at entering the function). - Valid only for call-stack items - - - - - Gets or sets the return address. - Valid only for call-stack items - - - - - Gets or sets the name of the item - - - - - Gets or sets the value of the item - - - - - Gets or sets the symbol reference of the item - - - - - Gets or sets a value indicating whether this instance is generating an error. - - - - - Gets or sets the source location this item refers to. - - - - - Enumeration of the possible watch types - - - - - A real variable watch - - - - - The status of the v-stack - - - - - The call stack - - - - - The list of coroutines - - - - - The maximum value of this enum - - - - - Enumeration of the possible performance counters - - - - - Measures the time spent parsing the source creating the AST - - - - - Measures the time spent converting ASTs in bytecode - - - - - Measures the time spent in executing scripts - - - - - Measures the on the fly creation/compilation of functions in userdata descriptors - - - - - Sentinel value to get the enum size - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Enumeration of unit of measures of the performance counters - - - - - The performance counter is specified in bytes (of memory) - - - - - The performance counter is specified in milliseconds - - - - - A single object of this type exists for every script and gives access to performance statistics. - - - - - Gets the result of the specified performance counter . - - The PerformanceCounter. - - - - - Starts a stopwatch. - - - - - - Starts a stopwatch. - - - - - - Gets a string with a complete performance log. - - - - - - Gets or sets a value indicating whether this collection of performance stats is enabled. - - - true if enabled; otherwise, false. - - - - - The result of a performance counter - - - - - Returns a that represents this instance. - - - - - Converts a PerformanceCounterType to a string. - - The type. - - - - Gets the name of the performance counter which generated this result. - - - - - Gets the quantity monitored - see Type to understand what this field contains - - - - - Gets the number of instances which led to the specified counter being incremented - e.g. the times a specific - code is executed, or object instanced - - - - - Gets a value indicating whether this is global or relative to the resource - for which it's called. - - - - - Gets the unit of measure of the Counter field. - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Exception thrown when an inconsistent state is reached in the interpreter - - - - - Exception for all parsing/lexing errors. - - - - - Gets or sets a value indicating whether this exception was caused by premature stream termination (that is, unexpected EOF). - This can be used in REPL interfaces to tell between unrecoverable errors and those which can be recovered by extra input. - - - - - This class is a container for arguments received by a CallbackFunction - - - - - Initializes a new instance of the class. - - The arguments. - if set to true [is method call]. - - - - Gets the at the specified index, or null. - - The index. - if set to true all voids are translated to nils. - - - - - Converts the arguments to an array - - The number of elements to skip (default= 0). - - - - - Gets the specified argument as as an argument of the specified type. If not possible, - an exception is raised. - - The argument number. - Name of the function. - The type desired. - if set to true nil values are allowed. - - - - - Gets the specified argument as as an argument of the specified user data type. If not possible, - an exception is raised. - - The desired userdata type - The argument number. - Name of the function. - if set to true nil values are allowed. - - - - - Gets the specified argument as an integer - - The argument number. - Name of the function. - - - - - Gets the specified argument as a string, calling the __tostring metamethod if needed, in a NON - yield-compatible way. - - The execution context. - The argument number. - Name of the function. - - 'tostring' must return a string to '{0}' - - - - Returns a copy of CallbackArguments where the first ("self") argument is skipped if this was a method call, - otherwise returns itself. - - - - - - Gets the count of arguments - - - - - Gets or sets a value indicating whether this is a method call. - - - - - Gets the at the specified index, or Void if not found - - - - - A class representing a script function - - - - - Shortcut for an empty closure - - - - - Initializes a new instance of the class. - - The script. - The index. - The symbols. - The resolved locals. - - - - Calls this function with the specified args - - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Gets a delegate wrapping calls to this scripted function - - - - - - Gets a delegate wrapping calls to this scripted function - - The type of return value of the delegate. - - - - - Gets the number of upvalues in this closure - - The number of upvalues in this closure - - - - Gets the name of the specified upvalue. - - The index of the upvalue. - The upvalue name - - - - Gets the value of an upvalue - - The index of the upvalue. - The value of an upvalue - - - - Gets the type of the upvalues contained in this closure - - - - - - Gets the entry point location in bytecode . - - - - - Gets the script owning this function - - - - - The current closure context - - - - - Type of closure based on upvalues - - - - - The closure has no upvalues (thus, technically, it's a function and not a closure!) - - - - - The closure has _ENV as its only upvalue - - - - - The closure is a "real" closure, with multiple upvalues - - - - - This class wraps a CLR function - - - - - Initializes a new instance of the class. - - The callback function to be called. - The callback name, used in stacktraces, debugger, etc.. - - - - Invokes the callback function - - The execution context. - The arguments. - if set to true this is a method call. - - - - - Creates a CallbackFunction from a delegate. - - The script. - The delegate. - The access mode. - - - - - Creates a CallbackFunction from a MethodInfo relative to a function. - - The script. - The MethodInfo object. - The object to which the function applies, or null for static methods. - The access mode. - - The method is not static. - - - - Checks the callback signature of a method is compatible for callbacks - - - - - Gets the name of the function - - - - - Gets the call back. - - - The call back. - - - - - Gets or sets the default access mode used when marshalling delegates - - - The default access mode. Default, HideMembers and BackgroundOptimized are NOT supported. - - Default, HideMembers and BackgroundOptimized are NOT supported. - - - - Gets or sets an object used as additional data to the callback function (available in the execution context). - - - - - A class representing a value in a Lua/MoonSharp script. - - - - - Creates a new writable value initialized to Nil. - - - - - Creates a new writable value initialized to the specified boolean. - - - - - Creates a new writable value initialized to the specified number. - - - - - Creates a new writable value initialized to the specified string. - - - - - Creates a new writable value initialized to the specified StringBuilder. - - - - - Creates a new writable value initialized to the specified string using String.Format like syntax - - - - - Creates a new writable value initialized to the specified coroutine. - Internal use only, for external use, see Script.CoroutineCreate - - The coroutine object. - - - - - Creates a new writable value initialized to the specified closure (function). - - - - - Creates a new writable value initialized to the specified CLR callback. - - - - - Creates a new writable value initialized to the specified CLR callback. - See also CallbackFunction.FromDelegate and CallbackFunction.FromMethodInfo factory methods. - - - - - Creates a new writable value initialized to the specified table. - - - - - Creates a new writable value initialized to an empty table. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The function to be called. - The arguments. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The data for the tail call. - - - - - Creates a new request for a yield of the current coroutine. - - The yield argumenst. - - - - - Creates a new tuple initialized to the specified values. - - - - - Creates a new tuple initialized to the specified values - which can be potentially other tuples - - - - - Creates a new userdata value - - - - - Returns this value as readonly - eventually cloning it in the process if it isn't readonly to start with. - - - - - Clones this instance. - - - - - - Clones this instance, overriding the "readonly" status. - - if set to true the new instance is set as readonly, or writeable otherwise. - - - - - Clones this instance, returning a writable copy. - - Can't clone Symbol values - - - - Returns a string which is what it's expected to be output by the print function applied to this value. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Casts this DynValue to string, using coercion if the type is number. - - The string representation, or null if not number, not string. - - - - Casts this DynValue to a double, using coercion if the type is string. - - The string representation, or null if not number, not string or non-convertible-string. - - - - Casts this DynValue to a bool - - False if value is false or nil, true otherwise. - - - - Converts a tuple to a scalar value. If it's already a scalar value, this function returns "this". - - - - - Performs an assignment, overwriting the value with the specified one. - - The value. - If the value is readonly. - - - - Gets the length of a string or table value. - - - Value is not a table or string. - - - - Determines whether this instance is nil or void - - - - - Determines whether this instance is not nil or void - - - - - Determines whether this instance is void - - - - - Determines whether this instance is not void - - - - - Determines whether is nil, void or NaN (and thus unsuitable for using as a table key). - - - - - Changes the numeric value of a number DynValue. - - - - - Creates a new DynValue from a CLR object - - The script. - The object. - - - - - Converts this MoonSharp DynValue to a CLR object. - - - - - Converts this MoonSharp DynValue to a CLR object of the specified type. - - - - - Checks the type of this value corresponds to the desired type. A propert ScriptRuntimeException is thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - Name of the function requesting the value, for error message purposes. - The desired data type. - The argument number, for error message purposes. - The TypeValidationFlags. - - Thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - - - Checks if the type is a specific userdata type, and returns it or throws. - - - Name of the function. - The argument number. - The flags. - - - - - Gets a unique reference identifier. This is guaranteed to be unique only for dynvalues created in a single thread as it's not thread-safe. - - - - - Gets the type of the value. - - - - - Gets the function (valid only if the is ) - - - - - Gets the numeric value (valid only if the is ) - - - - - Gets the values in the tuple (valid only if the is Tuple). - This field is currently also used to hold arguments in values whose is . - - - - - Gets the coroutine handle. (valid only if the is Thread). - - - - - Gets the table (valid only if the is ) - - - - - Gets the boolean value (valid only if the is ) - - - - - Gets the string value (valid only if the is ) - - - - - Gets the CLR callback (valid only if the is ) - - - - - Gets the tail call data. - - - - - Gets the yield request data. - - - - - Gets the tail call data. - - - - - Returns true if this instance is write protected. - - - - - A preinitialized, readonly instance, equaling Void - - - - - A preinitialized, readonly instance, equaling Nil - - - - - A preinitialized, readonly instance, equaling True - - - - - A preinitialized, readonly instance, equaling False - - - - - A class representing a key/value pair for Table use - - - - - Initializes a new instance of the struct. - - The key. - The value. - - - - Gets the key. - - - - - Gets or sets the value. - - - - - Gets the nil pair - - - - - Class giving access to details of the environment where the script is executing - - - - - Gets the metatable associated with the given value. - - The value. - - - - - Gets the specified metamethod associated with the given value. - - The value. - The metamethod name. - - - - - prepares a tail call request for the specified metamethod, or null if no metamethod is found. - - - - - Gets the metamethod to be used for a binary operation using op1 and op2. - - - - - Gets the script object associated with this request - - - - - - Gets the coroutine which is performing the call - - - - - Calls a callback function implemented in "classic way". - Useful to port C code from Lua, or C# code from UniLua and KopiLua. - Lua : http://www.lua.org/ - UniLua : http://github.com/xebecnan/UniLua - KopiLua : http://github.com/NLua/KopiLua - - The arguments. - Name of the function - for error messages. - The callback. - - - - - Calls the specified function, supporting most cases. The called function must not yield. - - The function; it must be a Function or ClrFunction or have a call metamethod defined. - The arguments. - - If the function yields, returns a tail call request with continuations/handlers or, of course, if it encounters errors. - - - - Tries to get the reference of a symbol in the current execution state - - - - - Tries to get the value of a symbol in the current execution state - - - - - Finds a symbol by name in the current execution state - - - - - Performs a message decoration before unwinding after an error. To be used in the implementation of xpcall like functions. - - The message handler. - The exception. - - - - Gets a value indicating whether this instance is running a dynamic execution. - Under a dynamic execution, most methods of ScriptExecutionContext are not reliable as the - processing engine of the script is not "really" running or is not available. - - - - - Gets the location of the code calling back - - - - - Gets or sets the additional data associated to this CLR function call. - - - - - Gets the current global env, or null if not found. - - - - - Class representing the source code of a given script - - - - - Gets the code snippet represented by a source ref - - The source code reference. - - - - - Gets the name of the source code - - - - - Gets the source code as a string - - - - - Gets the source code lines. - - - - - Gets the script owning this resource. - - - - - Gets the source identifier inside a script - - - - - State of coroutines - - - - - This is the main coroutine - - - - - Coroutine has not started yet - - - - - Coroutine is suspended - - - - - Coroutine is running - - - - - Coroutine has terminated - - - - - Wrappers for enumerables as return types - - - - - LINQ helper methods - - - - - Converts the specified enumerable dynvalues of a given script type to objects of a given type - - The desired type - The enumerable. - The type. - - - - Filters an enumeration for items of the given script type - - The enumerable. - The script type. - - - - Converts the elements to CLR objects - - The enumerable. - - - - Converts the elements to CLR objects of the desired type - - The desired type - The enumerable. - - - - - - - - - Marks a type of automatic registration as userdata (which happens only if UserData.RegisterAssembly is called). - - - - - Initializes a new instance of the class. - - - - - The interop access mode - - - - - Forces a class member visibility to scripts. Can be used to hide public members or to expose non-public ones. - - - - - Initializes a new instance of the class. - - if set to true the member will be exposed to scripts, if false the member will be hidden. - - - - Gets a value indicating whether this is set to "visible". - - - - - Descriptor which acts as a non-containing adapter from IUserDataType to IUserDataDescriptor - - - - - Initializes a new instance of the class. - - The type. - Name of the friendly. - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Standard descriptor for userdata types. - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - The interop access mode this descriptor uses for members access - A human readable friendly name of the descriptor. - - - - Fills the member list. - - - - - Gets the interop access mode this descriptor uses for members access - - - - - Enumerations of the possible strategies to marshal CLR objects to MoonSharp userdata and functions - when using automatic descriptors. - Note that these are "hints" and MoonSharp is free to ignore the access mode specified (if different from - HideMembers) and downgrade the access mode to "Reflection". - This particularly happens when running on AOT platforms like iOS. - See also : and . - - - - - Optimization is not performed and reflection is used everytime to access members. - This is the slowest approach but saves a lot of memory if members are seldomly used. - - - - - Optimization is done on the fly the first time a member is accessed. - This saves memory for all members that are never accessed, at the cost of an increased script execution time. - - - - - Optimization is done at registration time. - - - - - Optimization is done in a background thread which starts at registration time. - If a member is accessed before optimization is completed, reflection is used. - - - - - No optimization is done, and members are not accessible at all. - - - - - No reflection is allowed, nor code generation. This is used as a safeguard when registering types which should not - use a standard reflection based descriptor - for example for types implementing - - - - - Use the default access mode - - - - - Class providing easier marshalling of CLR functions - - - - - Tries to create a new StandardUserDataMethodDescriptor, returning - null in case the method is not - visible to script code. - - The MethodBase. - The - if set to true forces visibility. - - A new StandardUserDataMethodDescriptor or null. - - - - - Initializes a new instance of the class. - - The MethodBase (MethodInfo or ConstructorInfo) got through reflection. - The interop access mode. - Invalid accessMode - - - - Checks if the method is compatible with a standard descriptor - - The MethodBase. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The method contains unresolved generic parameters, or has an unresolved generic return type - or - The method contains pointer parameters, or has a pointer return type - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function as a DynValue. - - The script for which the callback must be generated. - The object (null for static). - - - - - Creates a callback DynValue starting from a MethodInfo. - - The script. - The mi. - The object. - - - - - The internal callback which actually executes the method - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value. - - The script. - The object. - The v. - - - - - Gets the method information (can be a MethodInfo or ConstructorInfo) - - - - - Gets the access mode used for interop - - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - Gets a value indicating whether the described method is a constructor - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets the types of access supported by this member - - - - - Class providing easier marshalling of CLR properties - - - - - Tries to create a new StandardUserDataPropertyDescriptor, returning null in case the property is not - visible to script code. - - The PropertyInfo. - The - A new StandardUserDataPropertyDescriptor or null. - - - - Initializes a new instance of the class. - NOTE: This constructor gives get/set visibility based exclusively on the CLR visibility of the - getter and setter methods. - - The pi. - The access mode. - - - - Initializes a new instance of the class. - - The PropertyInfo. - The - The getter method. Use null to make the property writeonly. - The setter method. Use null to make the property readonly. - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Gets the PropertyInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance can be read from - - - true if this instance can be read from; otherwise, false. - - - - - Gets a value indicating whether this instance can be written to. - - - true if this instance can be written to; otherwise, false. - - - - - Gets the types of access supported by this member - - - - - The scope of a closure (container of upvalues) - - - - - Gets the symbols. - - - - - Enumeration of the types of SymbolRef - - - - - The symbol ref of a local variable - - - - - The symbol ref of an upvalue variable - - - - - The symbol ref of a global variable - - - - - The symbol ref of the global environment - - - - - This class stores a possible l-value (that is a potential target of an assignment) - - - - - Creates a new symbol reference pointing to a global var - - The name. - The _ENV symbol. - - - - - Creates a new symbol reference pointing to a local var - - The name. - The index of the var in local scope. - - - - - Creates a new symbol reference pointing to an upvalue var - - The name. - The index of the var in closure scope. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Writes this instance to a binary stream - - - - - Reads a symbolref from a binary stream - - - - - Gets the type of this symbol reference - - - - - Gets the index of this symbol in its scope context - - - - - Gets the name of this symbol - - - - - Gets the environment this symbol refers to (for global symbols only) - - - - - Gets the default _ENV. - - - - - Enumeration of possible data types in MoonSharp - - - - - A nil value, as in Lua - - - - - A place holder for no value - - - - - A Lua boolean - - - - - A Lua number - - - - - A Lua string - - - - - A Lua function - - - - - A Lua table - - - - - A set of multiple values - - - - - A userdata reference - that is a wrapped CLR object - - - - - A coroutine handle - - - - - A callback function - - - - - A request to execute a tail call - - - - - A request to coroutine.yield - - - - - Extension methods to DataType - - - - - Determines whether this data type can have type metatables. - - The type. - - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function, with additional values - to support debuggers - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - A script loader loading scripts from an assembly resources - - - - - A base implementation of IScriptLoader, offering resolution of module names. - - - - - Class dictating how requests to read scripts from files are handled. - - It's recommended that no class implement IScriptLoader directly, and rather extend ScriptLoaderBase. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile) - - The modname. - The global context. - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves the name of a module on a set of paths. - - The modname. - The paths. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable (if and only if - the IgnoreLuaPathGlobal is false), and - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - Unpacks a string path in a form like "?;?.lua" to an array - - - - - Gets the default environment paths. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Gets or sets the modules paths used by the "require" function. If null, the default paths are used (using - environment variables etc.). - - - - - Gets or sets a value indicating whether the LUA_PATH global is checked or not to get the path where modules are contained. - If true, the LUA_PATH global is NOT checked. - - - - - Initializes a new instance of the class. - - The assembly containing the scripts as embedded resources or null to use the calling assembly. - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader used for platforms we cannot initialize in any better way.. - - - - - An implementation of which supports a very basic history of recent input lines. - - - - - This class provides a simple REPL intepreter ready to be reused in a simple way. - - - - - Initializes a new instance of the class. - - The script. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - This method returns the result of the computation, or null if more input is needed for a computation. - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "?" as a - dynamic expression to evaluate instead of script code (likely invalid) - - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "=" as a - non-dynamic expression to evaluate (just like the Lua interpreter does by default). - - - - - Gets a value indicating whether this instance has a pending command - - - - - Gets the current pending command. - - - - - Gets the classic prompt (">" or ">>") given the current state of the interpreter - - - - - Initializes a new instance of the class. - - The script. - Size of the history. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - - This method returns the result of the computation, or null if more input is needed for a computation. - - - - - Gets the previous item in history, or null - - - - - Gets the next item in history, or null - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - AND starts with module paths taken from environment variables (again, not going through the platform object). - - The paths are preconstructed using : - * The MOONSHARP_PATH environment variable if it exists - * The LUA_PATH_5_2 environment variable if MOONSHARP_PATH does not exists - * The LUA_PATH environment variable if LUA_PATH_5_2 and MOONSHARP_PATH do not exists - * The "?;?.lua" path if all the above fail - - Also, everytime a module is require(d), the "LUA_PATH" global variable is checked. If it exists, those paths - will be used to load the module instead of the global ones. - - - - - Initializes a new instance of the class. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable, and - - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - A script loader which can load scripts from assets in Unity3D. - Scripts should be saved as .txt files in a subdirectory of Assets/Resources. - - When MoonSharp is activated on Unity3D and the default script loader is used, - scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. - - - - - The default path where scripts are meant to be stored (if not changed) - - - - - Initializes a new instance of the class. - - The path, relative to Assets/Resources. For example - if your scripts are stored under Assets/Resources/Scripts, you should - pass the value "Scripts". If null, "MoonSharp/Scripts" is used. - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - UnityAssetsScriptLoader.LoadFile : Cannot load + file - - - - Checks if a given file exists - - The file. - - - - - Gets the list of loaded scripts filenames (useful for debugging purposes). - - - - - - In a module type, mark fields with this attribute to have them exposed as a module constant. - - See for more information about modules. - - - - - Gets or sets the name of the constant - if different from the name of the field itself - - - - - Namespace containing all the most commonly used classes for MoonSharp operation. - When in doubt, refer to and classes as starting points. - - - - - Namespace containing the implementation of the Lua standard library, as MoonSharp modules. - There's seldom the need to access these classes directly. - - - - - Namespace containing userdata classes for the 'io' module - - - - - Namespace containing classes used to support debuggers - - - - - Namespace containing classes used to support self diagnostics (e.g. performance counters) - - - - - Namespace containing classes used to customize and support advanced interoperations between - scripts and CLR code. - - - - - Namespace containing classes used to provide a minimal support for porting code based on the classic - "LuaState" model (e.g. code based on KopiLua, UniLua or Lua itself). - - - - - Namespace containing classes used to customized how scripts are loaded from external files. - - - - - Namespace containing classes used to customize how the interfacing with the operative system happens - for the 'os' and 'io' modules, and for future modules/classes which may require OS access. - See and . - - - - - Contains classes useful to implement REPL interpreters. - See : - - - - - Interface to abstract all accesses made to the underlying platform (OS, framework) by the scripting engine. - Can be used both to support "non-standard" platforms (i.e. non-posix, non-windows) and/or to sandbox the behaviour - of the scripting engine. - - It's recommended that no class implement IPlatformAccessor directly, and rather extend . - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - Gets the name of the platform (used for debug purposes). - - The name of the platform (used for debug purposes) - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If a meaningful implementation cannot be provided, this method should return null. - - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - The script. - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - True if the file exists, false otherwise. - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - An abstract class which offers basic services on top of IPlatformAccessor to provide easier implementation of platforms. - - - - - Gets the platform name prefix - - - - - - Gets the name of the platform (used for debug purposes). - - - The name of the platform (used for debug purposes) - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - DEPRECATED. - This is kept for backward compatibility, see the overload taking a prompt as an input parameter. - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - A static class offering properties for autodetection of system/platform details - - - - - Gets a value indicating whether this instance is running on mono. - - - - - Gets a value indicating whether this instance is running on a CLR4 compatible implementation - - - - - Gets a value indicating whether this instance is running on Unity-3D - - - - - Gets a value indicating whether this instance has been built as a Portable Class Library - - - - - Gets a value indicating whether this instance is running a system using Ahead-Of-Time compilation - and not supporting JIT. - - - - - A class implementing all the bits needed to have a minimal support of a platform. - This does not support the 'io'/'file' modules and has partial support of the 'os' module. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - A function used to open files in the 'io' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a standard stream (stdin, stdout, stderr). - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The type. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Exits the process, returning the specified exit code. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The exit code. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Checks if a file exists. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - - True if the file exists, false otherwise. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Deletes the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Moves the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The source. - The DST. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The cmdline. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets the platform name prefix - - - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - - Enumeration of standard file handles - - - - - Standard Input - - - - - Standard Output - - - - - Standard Error Output - - - - - Class providing the IPlatformAccessor interface for standard full-feaured implementations. - - - - - Converts a Lua string access mode to a FileAccess enum - - The mode. - - - - - Converts a Lua string access mode to a ParseFileMode enum - - The mode. - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - type - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets the platform name prefix - - - - - - - This class implements a MoonSharp scripting session. Multiple Script objects can coexist in the same program but cannot share - data among themselves unless some mechanism is put in place. - - - - - The version of the MoonSharp engine - - - - - The Lua version being supported - - - - - Initializes the class. - - - - - Initializes a new instance of the clas.s - - - - - Initializes a new instance of the class. - - The core modules to be pre-registered in the default global table. - - - - Loads a string containing a Lua/MoonSharp function. - - The code. - The global table to bind to this chunk. - Name of the function used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a Lua/MoonSharp script from a System.IO.Stream. NOTE: This will *NOT* close the stream! - - The stream containing code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Dumps on the specified stream. - - The function. - The stream. - - function arg is not a function! - or - stream is readonly! - or - function arg has upvalues other than _ENV - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - The filename to be used in error messages. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads and executes a string containing a Lua/MoonSharp script. - - The code. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a stream containing a Lua/MoonSharp script. - - The stream. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a file containing a Lua/MoonSharp script. - - The filename. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Runs the specified file with all possible defaults for quick experimenting. - - The filename. - A DynValue containing the result of the processing of the executed script. - - - - Runs the specified code with all possible defaults for quick experimenting. - - The Lua/MoonSharp code. - A DynValue containing the result of the processing of the executed script. - - - - Creates a closure from a bytecode address. - - The address. - The env table to create a 0-upvalue - - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Gets the main chunk function. - - A DynValue containing a function which executes the first chunk that has been loaded. - - - - Attaches a debugger. This usually should be called by the debugger itself and not by user code. - - The debugger object. - - - - Gets the source code. - - The source code identifier. - - - - - Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html - - The module name - The global context. - - Raised if module is not found - - - - Gets a type metatable. - - The type. - - - - - Sets a type metatable. - - The type. Must be Nil, Boolean, Number, String or Function - The metatable. - Specified type not supported : + type.ToString() - - - - Warms up the parser/lexer structures so that MoonSharp operations start faster. - - - - - Creates a new dynamic expression. - - The code of the expression. - - - - - Creates a new dynamic expression which is actually quite static, returning always the same constant value. - - The code of the not-so-dynamic expression. - The constant to return. - - - - - Gets an execution context exposing only partial functionality, which should be used for - those cases where the execution engine is not really running - for example for dynamic expression - or calls from CLR to CLR callbacks - - - - - Gets or sets the script loader which will be used as the value of the - ScriptLoader property for all newly created scripts. - - - - - Gets access to the script options. - - - - - Gets the global options, that is options which cannot be customized per-script. - - - - - Gets access to performance statistics. - - - - - Gets the default global table for this script. Unless a different table is intentionally passed (or setfenv has been used) - execution uses this table. - - - - - Gets the source code count. - - - The source code count. - - - - - MoonSharp (like Lua itself) provides a registry, a predefined table that can be used by any CLR code to - store whatever Lua values it needs to store. - Any CLR code can store data into this table, but it should take care to choose keys - that are different from those used by other libraries, to avoid collisions. - Typically, you should use as key a string GUID, a string containing your library name, or a - userdata with the address of a CLR object in your code. - - - - - A class representing a Lua table. - - - - - Initializes a new instance of the class. - - The owner script. - - - - Removes all items from the Table. - - - - - Gets the integral key from a double. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) - - The key. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) as a System.Object. - - The key. - - - - - Sets the dynvalue associated with the specified key. Both expressed as System.Object. - - The key. - The value. - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Gets the value associated with the specified key, without bringing to Nil the non-existant values. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Collects the dead keys. This frees up memory but invalidates pending iterators. - It's called automatically internally when the semantics of Lua tables allow, but can be forced - externally if it's known that no iterators are pending. - - - - - Returns the next pair from a value - - - - - Gets the script owning this resource. - - - - - Gets or sets the - with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - Multiple keys can be used to access subtables. - - - The . - - The key. - Optional subkeys to access subtables - - - - - Gets or sets the with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - - - The . - - The key. - - - - - Gets the length of the "array part". - - - - - Gets the meta-table associated with this instance. - - - - - Enumerates the key/value pairs. - - - - - - Enumerates the keys. - - - - - - Enumerates the values - - - - - - A preallocated, non-resizable, stack - - - - - - Enumeration (combinable as flags) of all the standard library modules - - - - - Value used to specify no modules to be loaded (equals 0). - - - - - The basic methods. Includes "assert", "collectgarbage", "error", "print", "select", "type", "tonumber" and "tostring". - - - - - The global constants: "_G", "_VERSION" and "_MOONSHARP". - - - - - The table iterators: "next", "ipairs" and "pairs". - - - - - The metatable methods : "setmetatable", "getmetatable", "rawset", "rawget", "rawequal" and "rawlen". - - - - - The string package - - - - - The load methods: "load", "loadsafe", "loadfile", "loadfilesafe", "dofile" and "require" - - - - - The table package - - - - - The error handling methods: "pcall" and "xpcall" - - - - - The math package - - - - - The coroutine package - - - - - The bit32 package - - - - - The time methods of the "os" package: "clock", "difftime", "date" and "time" - - - - - The methods of "os" package excluding those listed for OS_Time. These are not supported under Unity. - - - - - The methods of "io" and "file" packages. These are not supported under Unity. - - - - - The "debug" package (it has limited support) - - - - - The "dynamic" package (introduced by MoonSharp). - - - - - A sort of "hard" sandbox preset, including string, math, table, bit32 packages, constants and table iterators. - - - - - A softer sandbox preset, adding metatables support, error handling, coroutine, time functions and dynamic evaluations. - - - - - The default preset. Includes everything except "debug" as now. - Beware that using this preset allows scripts unlimited access to the system. - - - - - The complete package. - Beware that using this preset allows scripts unlimited access to the system. - - - - - Class managing modules (mostly as extension methods) - - - - - Register the core modules to a table - - The table. - The modules. - - - - - Registers the standard constants (_G, _VERSION, _MOONSHARP) to a table - - The table. - - - - - Registers a module type to the specified table - - The table. - The type - - If the module contains some incompatibility - - - - Registers a module type to the specified table - - The module type - The table. - - If the module contains some incompatibility - - - - In a module type, mark methods or fields with this attribute to have them exposed as module functions. - Methods must have the signature "public static DynValue ...(ScriptExecutionContextCallbackArguments)". - Fields must be static or const strings, with an anonymous Lua function inside. - - See for more information about modules. - - - - - Gets or sets the name of the function in the module (defaults to member name) - - - - - Marks a CLR type to be a MoonSharp module. - Modules are the fastest way to bring interop between scripts and CLR code, albeit at the cost of a very increased - complexity in writing them. Modules is what's used for the standard library, for maximum efficiency. - - Modules are basically classes containing only static methods, with the callback function signature. - - See and for (extension) methods used to register modules to a - table. - - See for information regarding the standard callback signature along with easier ways - to marshal methods. - - See for easier object marshalling. - - - - - Gets or sets the namespace, that is the name of the table which will contain the defined functions. - Can be null to be in the global table. - - - - - Class containing script global options, that is options which cannot be customized per-script. - - - - - - Gets or sets the custom converters. - - - - - Gets or sets the platform abstraction to use. - - - The current platform abstraction. - - - - - This class contains options to customize behaviour of Script objects. - - - - - Gets or sets the current script-loader. - - - - - Gets or sets the debug print handler - - - - - Gets or sets the debug input handler (takes a prompt as an input, for interactive interpreters, like debug.debug). - - - - - Gets or sets a value indicating whether error messages will use Lua error locations instead of MoonSharp - improved ones. Use this for compatibility with legacy Lua code which parses error messages. - - - - - Gets or sets the stream used as stdin. If null, a default stream is used. - - - - - Gets or sets the stream used as stdout. If null, a default stream is used. - - - - - Gets or sets the stream used as stderr. If null, a default stream is used. - - - - - Gets or sets the stack depth threshold at which MoonSharp starts doing - tail call optimizations. - TCOs can provide the little benefit of avoiding stack overflows in corner case - scenarios, at the expense of losing debug information and error stack traces - in all other, more common scenarios. MoonSharp choice is to start performing - TCOs only after a certain threshold of stack usage is reached - by default - half the current stack depth (128K entries), thus 64K entries, on either - the internal stacks. - Set this to int.MaxValue to disable TCOs entirely, or to 0 to always have - TCOs enabled. - - - - - Gets or sets a value indicating whether the thread check is enabled. - A "lazy" thread check is performed everytime execution is entered to ensure that no two threads - calls MoonSharp execution concurrently. However 1) the check is performed best effort (thus, it might - not detect all issues) and 2) it might trigger in very odd legal situations (like, switching threads - inside a CLR-callback without actually having concurrency. - - Disable this option if the thread check is giving problems in your scenario, but please check that - you are not calling MoonSharp execution concurrently as it is not supported. - - - - - Primaries the exp. - - The lcontext. - - - - - - - - - - Creates a sub tree of binary expressions - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/portable-net4+sl5+wp8+win8/MoonSharp.Interpreter.xml b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/portable-net4+sl5+wp8+win8/MoonSharp.Interpreter.xml deleted file mode 100644 index 51902bef..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.0.9.4.0/lib/portable-net4+sl5+wp8+win8/MoonSharp.Interpreter.xml +++ /dev/null @@ -1,6529 +0,0 @@ - - - - MoonSharp.Interpreter - - - - - Class implementing coroutine Lua functions - - - - - Class implementing basic Lua functions (print, type, tostring, etc) as a MoonSharp module. - - - - - Class implementing debug Lua functions. Support for the debug module is partial. - - - - - Class implementing dynamic expression evaluations at runtime (a MoonSharp addition). - - - - - Class implementing error handling Lua functions (pcall and xpcall) - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - - - - - A base class for many MoonSharp objects. - Helds a ReferenceID property which gets a different value for every object instance, for debugging - purposes. Note that the ID is not assigned in a thread safe manner for speed reason, so the IDs - are guaranteed to be unique only if everything is running on one thread at a time. - - - - - Formats a string with a type name and a ref-id - - The type name. - - - - - Gets the reference identifier. - - - The reference identifier. - - - - - Class implementing io Lua functions. Proper support requires a compatible IPlatformAccessor - - - - - Abstract class implementing an unclosable file Lua userdata. Methods are meant to be called by Lua code. - - - - - Class implementing loading Lua functions like 'require', 'load', etc. - - - - - Class implementing bit32 Lua functions - - - - - Class implementing math Lua functions - - - - - Class implementing metatable related Lua functions (xxxmetatable and rawxxx). - - - - - Class implementing system related Lua functions from the 'os' module. - Proper support requires a compatible IPlatformAccessor - - - - - Class implementing time related Lua functions from the 'os' module. - - - - - Classes using the classic interface should inherit from this class. - This class defines only static methods and is really meant to be used only - from C# and not other .NET languages. - - For easier operation they should also define: - using ptrdiff_t = System.Int32; - using lua_Integer = System.Int32; - using LUA_INTFRM_T = System.Int64; - using UNSIGNED_LUA_INTFRM_T = System.UInt64; - - - - - Calls a function. - To call a function you must use the following protocol: first, the function to be called is pushed onto the stack; then, - the arguments to the function are pushed in direct order; that is, the first argument is pushed first. Finally you call - lua_call; nargs is the number of arguments that you pushed onto the stack. All arguments and the function value are - popped from the stack when the function is called. The function results are pushed onto the stack when the function - returns. The number of results is adjusted to nresults, unless nresults is LUA_MULTRET. In this case, all results from - the function are pushed. Lua takes care that the returned values fit into the stack space. The function results are - pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is on - the top of the stack. - - The LuaState - The number of arguments. - The number of expected results. - - - - - A Dictionary where multiple values can be associated to the same key - - The key type - The value type - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The equality comparer to use in the underlying dictionary. - - - - Adds the specified key. Returns true if this is the first value for a given key - - The key. - The value. - - - - - Finds all the values associated with the specified key. - An empty collection is returned if not found. - - The key. - - - - Determines whether this contains the specified key - - The key. - - - - Clears this instance. - - - - - Removes the specified key and all its associated values from the multidictionary - - The key. - - - - Removes the value. Returns true if the removed value was the last of a given key - - The key. - The value. - - - - - Gets the keys. - - - - - Implementation of IEqualityComparer enforcing reference equality - - - - - Marks a method as the handler of metamethods of a userdata type - - - - - Initializes a new instance of the class. - - The metamethod name (like '__div', '__ipairs', etc.) - - - - The metamethod name (like '__div', '__ipairs', etc.) - - - - - Base interface to describe access to members of a given type. - While it's not infrastructural to implement custom type descriptors, it's needed for - classes extending . - - - - - Gets the value of this member as a to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value of this member as a . - - - - Sets the value of this member from a . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Extension methods for and . - - - - - Determines whether the specified MemberDescriptorAccess has ALL the specified flags. - - The access. - The flag. - - - - - Determines whether this instance can be read - - The descriptor instance. - - - - - Determines whether this instance can be written to - - The descriptor instance. - - - - - Determines whether this instance can be executed (called as a function) - - The descriptor instance. - - - - - Gets the getter of the member as a DynValue containing a callback - - The descriptor instance. - The script. - The object. - - - - - Returns the specified descriptor if it supports all the specified access modes, otherwise returns null. - - The descriptor instance. - The access mode(s). - - - - - Raises an appropriate ScriptRuntimeException if the specified access is not supported. - Checks are made for the MemberDescriptorAccess permissions AND for the access of instance - members through static userdatas. - - The desc. - The access. - The object to be checked for access. - - - - Interface for descriptors of any kind which support optimizations of their implementation according to InteropAccessMode - modes. This should seldom - if ever - be implemented in user code. - - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Specialized for members supporting overloads resolution. - - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Permissions for members access - - - - - The member can be read from - - - - - The member can be written to - - - - - The can be invoked - - - - - Descriptor of parameters used in implementations. - - - - - If the type got restricted, the original type before the restriction. - - - - - Initializes a new instance of the class. - - The name. - The type. - if set to true the parameter has default value. - The default value. - if set to true, is an out param. - - - - Initializes a new instance of the class. - - A ParameterInfo taken from reflection. - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Restricts the type of this parameter to a tighter constraint. - Restrictions must be applied before the containing this - parameter is used in any way. - - The new type. - - Cannot restrict a ref/out param - or - Specified operation is not a restriction - - - - - Gets the name of the parameter - - - - - Gets the type of the parameter - - - - - Gets a value indicating whether this instance has a default value. - - - - - Gets the default value - - - - - Gets a value indicating whether this instance is an out parameter - - - - - Gets a value indicating whether this instance has been restricted. - - - - - Gets the original type of the parameter before any restriction has been applied. - - - - - Tries to convert a CLR object to a MoonSharp value, using "simple" logic. - Does NOT throw on failure. - - - - - Tries to convert a CLR object to a MoonSharp value, using more in-depth analysis - - - - - Converts an IEnumerable or IEnumerator to a DynValue - - The script. - The object. - - - - - Static functions to handle conversions of numeric types - - - - - HashSet of numeric types - - - - - Array of numeric types in order used for some conversions - - - - - Converts a double to another type - - - - - Converts a type to double - - - - - Converts a DynValue to a CLR object [simple conversion] - - - - - Converts a DynValue to a CLR object of a specific type - - - - - Gets a relative weight of how much the conversion is matching the given types. - Implementation must follow that of DynValueToObjectOfType.. it's not very DRY in that sense. - However here we are in perf-sensitive path.. TODO : double-check the gain and see if a DRY impl is better. - - - - - Converts an IList to a Lua table. - - - - - Converts an IDictionary to a Lua table. - - - - - Determines whether the specified table can be converted to the specified type - - The table. - The type. - - - - - Converts a table to a CLR object of a given type - - - - - Converts a table to a - - - - - Converts a table to a T[] - - - - - Converts a table to a - - - - - Converts a table to a , known in advance - - - - - Converts a table to a Dictionary, known in advance - - - - - A collection of custom converters between MoonSharp types and CLR types. - If a converter function is not specified or returns null, the standard conversion path applies. - - - - - Sets a custom converter from a script data type to a CLR data type. Set null to remove a previous custom converter. - - The script data type - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a script data type to a CLR data type, or null - - The script data type - The CLR data type. - The converter function, or null if not found - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - - The CLR data type. - The converter, or null. - - - - Gets a custom converter from a CLR data type, or null - - Type of the color data. - The converter function, or null if not found - - - - Removes all converters. - - - - - Helper extension methods used to simplify some parts of userdata descriptor implementations - - - - - Determines whether a - is changing visibility of a member - to scripts. - - The member to check. - - true if visibility is forced visible, - false if visibility is forced hidden or the specified MemberInfo is null, - if no attribute was found - - - - - Determines whether the specified PropertyInfo is visible publicly (either the getter or the setter is public). - - The PropertyInfo. - - - - - Gets the list of metamethod names from attributes - in practice the list of metamethods declared through - . - - The mi. - - - - - Gets the name of a conversion method to be exposed to Lua scripts - - The type. - - - - - An abstract user data descriptor which accepts members described by objects and - correctly dispatches to them. - Metamethods are also by default dispatched to operator overloads and other similar methods - see - . - - - - - Interface used by MoonSharp to access objects of a given type from scripts. - - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - The special name used by CLR for indexer getters - - - - - The special name used by CLR for indexer setters - - - - - The special name used by CLR for explicit cast conversions - - - - - The special name used by CLR for implicit cast conversions - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - A friendly name for the type, or null. - - - - Adds a member to the meta-members list. - - The name of the metamethod. - The desc. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Adds a DynValue as a member - - The name. - The value. - - - - Adds a property to the member list - - The name. - The descriptor. - - Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - - - - - Performs an "index" "get" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing operation by checking newly added extension methods for the given indexName. - - The script. - The object. - Member name to be indexed. - - - - - - Determines whether the descriptor contains the specified member (by exact name) - - Name of the member. - - - - - Determines whether the descriptor contains the specified member in the meta list (by exact name) - - Name of the meta-member. - - - - - Tries to perform an indexing operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - - - - - Performs an "index" "set" operation. This tries to resolve minor variations of member names. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Tries to perform an indexing "set" operation by checking methods and properties for the given indexName - - The script. - The object. - Member name to be indexed. - The value. - - - - - Converts the specified name from underscore_case to camelCase. - - The name. - - - - - Converts the specified name to one with an uppercase first letter (something to Something). - - The name. - - - - - Converts this userdata to string - - The object. - - - - - Executes the specified indexer method. - - The method descriptor - The script. - The object. - The indexer parameter - The dynvalue to set on a setter, or null. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - See for further details. - - If a method exists marked with for the specific - metamethod requested, that method is returned. - - If the above fails, the following dispatching occur: - - __add, __sub, __mul, __div, __mod and __unm are dispatched to C# operator overloads (if they exist) - __eq is dispatched to System.Object.Equals. - __lt and __le are dispatched IComparable.Compare, if the type implements IComparable or IComparable{object} - __len is dispatched to Length and Count properties, if those exist. - __iterator is handled if the object implements IEnumerable or IEnumerator. - __tonumber is dispatched to implicit or explicit conversion operators to standard numeric types. - __tobool is dispatched to an implicit or explicit conversion operator to bool. If that fails, operator true is used. - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Gets a human readable friendly name of the descriptor - - - - - Standard descriptor for Enum values - - - - - Initializes a new instance of the class. - - Type of the enum. - Name of the friendly. - enumType must be an enum! - - - - Fills the member list. - - - - - Adds an enum method to the object - - The name. - The dyn value. - - - - Gets the value of the enum as a long - - - - - Gets the value of the enum as a ulong - - - - - Creates an enum value from a long - - - - - Creates an enum value from a ulong - - - - - Creates conversion functions for signed enums - - - - - Creates conversion functions for unsigned enums - - - - - Determines whether the specified object is compatible with the specified type. - - The type. - The object. - - - - - Gets a "meta" operation on this userdata. - In this specific case, only the concat operator is supported, only on flags enums and it implements the - 'or' operator. - - - - - - - - - Gets the underlying type of the enum. - - - - - Gets a value indicating whether underlying type of the enum is unsigned. - - - - - Gets a value indicating whether this instance describes a flags enumeration. - - - - - Class providing a simple descriptor for constant DynValues in userdata - - - - - Initializes a new instance of the class. - - The name. - The value. - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - userdata '{0}' cannot be written to. - - - - Gets a value indicating whether the described member is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - Gets the value wrapped by this descriptor - - - - - Class providing easier marshalling of CLR events. Handling is limited to a narrow range of handler signatures, which, - however, covers in practice most of all available events. - - - - - The maximum number of arguments supported in an event handler delegate - - - - - Tries to create a new StandardUserDataEventDescriptor, returning null in case the method is not - visible to script code. - - The EventInfo. - The - A new StandardUserDataEventDescriptor or null. - - - - Checks if the event is compatible with a standard descriptor - - The EventInfo. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The event is declared in a value type - or - The event does not have both add and remove methods - or - The event handler type doesn't implement a public Invoke method - or - The event handler has a return type which is not System.Void - or - The event handler has more than MAX_ARGS_IN_DELEGATE parameters - or - The event handler has a value type parameter or a by ref parameter - or - The event handler signature is not a valid method according to - - - - - Initializes a new instance of the class. - - The ei. - The access mode. - - - - Gets a dynvalue which is a facade supporting add/remove methods which is callable from scripts - - The script. - The object for which the facade should be written. - - - - - Sets the value. - - The script. - The object. - The v. - - - - Gets the EventInfo object of the event described by this descriptor - - - - - Gets a value indicating whether the event described by this descriptor is static. - - - - - Gets the name of the member - - - - - Gets the types of access supported by this member - - - - - As a convenience, every type deriving from IUserDataType is "self-described". That is, no descriptor is needed/generated - and the object itself is used to describe the type for interop. See also , - and . - - - - - Performs an "index" "get" operation. - - The script originating the request - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - - The script originating the request - The name of the metamember. - - - - - Class providing easier marshalling of overloaded CLR functions - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptor of the first overloaded method. - - - - Initializes a new instance of the class. - - The name. - The declaring type. - The descriptors of the overloaded methods. - - - - Sets the extension methods snapshot. - - The version. - The ext methods. - - - - Adds an overload. - - The overload. - - - - Performs the overloaded call. - - The script. - The object. - The context. - The arguments. - - function call doesn't match any overload - - - - Calculates the score for the overload. - - The context. - The arguments. - The method. - if set to true, is an extension method. - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a . - - The script. - The object owning this member, or null if static. - The value to be set. - - - - - Gets or sets a value indicating whether this instance ignores extension methods. - - - - - Gets the name of the first described overload - - - - - Gets the name of the first described overload - - - - - Gets the number of overloaded methods contained in this collection - - - The overload count. - - - - - Gets a value indicating whether there is at least one static method in the resolution list - - - - - - Gets the types of access supported by this member - - - - - Comparer class for IOverloadableMemberDescriptor - - - - - Class providing easier marshalling of CLR fields - - - - - Tries to create a new StandardUserDataFieldDescriptor, returning null in case the field is not - visible to script code. - - The FieldInfo. - The - A new StandardUserDataFieldDescriptor or null. - - - - Initializes a new instance of the class. - - The FieldInfo. - The - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Gets the FieldInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance is a constant - - - - - Gets a value indicating whether this instance is readonly - - - - - Gets the types of access supported by this member - - - - - Member descriptor for the default constructor of value types. - - - - - Initializes a new instance of the - class - representing the default empty ctor for a value type. - - Type of the value. - valueType is not a value type - - - - Invokes the member from script. - Implementors should raise exceptions if the value cannot be executed or if access to an - instance member through a static userdata is attempted. - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a - to be exposed to scripts. - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value of this member from a - . - Implementors should raise exceptions if the value cannot be read or if access to an - instance member through a static userdata is attempted. - - The script. - The object owning this member, or null if static. - The value to be set. - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - This property is equal to the value type to be constructed. - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the types of access supported by this member - - - - - "Optimized" BinaryReader which shares strings and use a dumb compression for integers - - - - - "Optimized" BinaryWriter which shares strings and use a dumb compression for integers - - - - - An adapter over Stream which bypasses the Dispose and Close methods. - Used to work around the pesky wrappers .NET has over Stream (BinaryReader, StreamWriter, etc.) which think they - own the Stream and close them when they shouldn't. Damn. - - - - - Enumerations of the possible policies to handle UserData type registrations - See also : . - - - - - Types must be explicitly registered. If a base type or interface is registered, that is used. - - - - - Types are automatically registered if not found in the registry. This is easier to use but potentially unsafe. - - - - - A Delegate type which can wrap a script function - - The arguments. - The return value of the script function - - - - A Delegate type which can wrap a script function with a generic typed return value - - - The arguments. - The return value of the script function - - - - Flags to alter the way the DynValue.CheckType and other related functions operate on data types for - validation. - - - - - No type validation specific behaviour - - - - - Nil and Void values are allowed (and returned by the call) - - - - - Simple autoconversions are attempted: - 1) Numbers are convertible to strings - 2) Strings are convertible to numbers if they contain a number - 3) Everything is convertible to boolean (with void and nil converting to 'false', everything else converting to 'true') - Note: if both AutoConvert and AllowNil are specified, nils will NOT be converted to false booleans. - - - - - The default : Autoconverting values, no nils. - - - - - Exception thrown when a dynamic expression is invalid - - - - - Exception for all runtime errors. In addition to constructors, it offers a lot of static methods - generating more "standard" Lua errors. - - - - - Base type of all exceptions thrown in MoonSharp - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Gets the instruction pointer of the execution (if it makes sense) - - - - - Gets the interpreter call stack. - - - - - Gets the decorated message (error message plus error location in script) if possible. - - - - - Initializes a new instance of the class. - - The ex. - - - - Initializes a new instance of the class. - - The message that describes the error. - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an arithmetic operation was attempted on non-numbers - - The left operand. - The right operand (or null). - The exception to be raised. - If both are numbers - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a concat operation was attempted on non-strings - - The left operand. - The right operand. - The exception to be raised. - If both are numbers or strings - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a len operator was applied on an invalid operand - - The operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a comparison operator was applied on an invalid combination of operand types - - The left operand. - The right operand. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The error message. - The exception to be raised. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad userdata argument - - The argument number (0-based). - Name of the function generating this error. - The expected System.Type. - The object which was used. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - The data type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a bad argument - - The argument number (0-based). - Name of the function generating this error. - The expected type description. - The description of the type received. - True if nils were allowed in this call. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - - This function creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - while creates a message like "bad argument #xxx to 'yyy' (value expected)" - - The argument number (0-based). - Name of the function generating this error. - The expected data type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an out of range index was specified - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with a negative number when a positive one was expected. - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a function was called with no value when a value was required. - This function creates a message like "bad argument #xxx to 'yyy' (value expected)" - while creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - - The argument number (0-based). - Name of the function generating this error. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an invalid attempt to index the specified object was made - - The object. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __index over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __newindex over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a loop was detected when performing __call over metatables. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used nil as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a table indexing operation used a NaN as the key. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion to number failed. - - - Selects the correct error message: - 0 - "value must be a number" - 1 - "'for' initial value must be a number" - 2 - "'for' step must be a number" - 3 - "'for' limit must be a number" - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a CLR type to a Lua type has failed. - - The object which could not be converted. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a conversion of a Lua type to a CLR type has failed. - - The Lua type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a constrained conversion of a Lua type to a CLR type has failed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - a userdata of a specific CLR type was expected and a non-userdata type was passed. - - The Lua type. - The expected CLR type. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to index an invalid member of a userdata was done. - - The name of the userdata type. - The field name. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt resume a coroutine in an invalid state was done. - - The state of the coroutine. - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield across a CLR boundary was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to yield from the main coroutine was made. - - - The exception to be raised. - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to call a non-function was made - - The lua non-function data type. - The debug text to aid location (appears as "near 'xxx'"). - - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The member descriptor. - - - - Creates a ScriptRuntimeException with a predefined error message specifying that - an attempt to access a non-static member from a static userdata was made - - The type descriptor. - The member descriptor. - - - - - Gets or sets a value indicating whether the message should not be decorated - - - - - Initializes a new instance of the class. - - The format. - The arguments. - - - - Initializes a new instance of the class. - - The message. - - - - Represents a dynamic expression in the script - - - - - Common interface for all resources which are uniquely bound to a script. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - The code which generated this expression - - - - - Evaluates the expression - - The context. - - - - - Finds a symbol in the expression - - The context. - - - - - Determines whether this instance is a constant expression - - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - Internal type used by for registration - - - - - Wrapper which allows for easier management of userdata without registering a new userdata type - useful - if a type which is not exposed to scripts but can be managed as a "black box" by scripts is desired. - - The type to wrap - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - The o. - - - - Gets or sets the value this instance wraps. - - - - - Determines whether the specified value is of numeric type. - - The object to check. - - true if o is a numeric type; otherwise, false. - - - - - Determines whether the specified value is positive. - - The value. - if set to true treats 0 as positive. - - true if the specified value is positive; otherwise, false. - - - - - Converts the specified values boxed type to its correpsonding unsigned - type. - - The value. - A boxed numeric object whos type is unsigned. - - - - Converts the specified values boxed type to its correpsonding integer - type. - - The value. - if set to true [round]. - - A boxed numeric object whos type is an integer type. - - - - - Replaces the string representations of meta chars with their corresponding - character values. - - The input. - A string with all string meta chars are replaced - - - - Class implementing string Lua functions - - - - - Class implementing table Lua iterators (pairs, ipairs, next) - - - - - Class implementing table Lua functions - - - - - Class exposing table.unpack and table.pack in the global namespace (to work around the most common Lua 5.1 compatibility issue). - - - - - Extension methods used in the whole project. - - - - - Gets a value from the dictionary or returns the default value - - The type of the key. - The type of the value. - The dictionary. - The key. - - - - - Gets a value from the dictionary or creates it - - The type of the key. - The type of the value. - The dictionary. - The key. - A function which will create the value if it doesn't exist. - - - - - A non preallocated, non_fixed size stack - - - - - - An index to accelerate operations on a LinkedList using a single key of type - More than one LinkedListIndex can index the same linked list, but every node in the linked list must be indexed by one and only one - LinkedListIndex object. - - The type of the key. Must implement Equals and GetHashCode appropriately. - The type of the values contained in the linked list. - - - - Initializes a new instance of the class. - - The linked list to be indexed. - - - - Finds the node indexed by the specified key, or null. - - The key. - - - - Updates or creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - The previous value of the element - - - - Creates a new node in the linked list, indexed by the specified key. - - The key. - The value. - - - - Removes the specified key from the index, and the node indexed by the key from the linked list. - - The key. - - - - Determines whether the index contains the specified key. - - The key. - - - - Clears this instance (removes all elements) - - - - - Provides facility to create a "sliced" view over an existing IList - - The type of the items contained in the collection - - - - Initializes a new instance of the class. - - The list to apply the Slice view on - From which index - The length of the slice - if set to true the view is in reversed order. - - - - Calculates the real index in the underlying collection - - - - - Returns an enumerator that iterates through the collection. - - - A that can be used to iterate through the collection. - - - - - Returns an enumerator that iterates through a collection. - - - An object that can be used to iterate through the collection. - - - - - Converts to an array. - - - - - Converts to an list. - - - - - Determines the index of a specific item in the . - - The object to locate in the . - - The index of if found in the list; otherwise, -1. - - - - - Inserts an item to the at the specified index. - - The zero-based index at which should be inserted. - The object to insert into the . - Slices are readonly - - - - Removes the item at the specified index. - - The zero-based index of the item to remove. - Slices are readonly - - - - Adds an item to the . - - The object to add to the . - Slices are readonly - - - - Removes all items from the . - - Slices are readonly - - - - Determines whether the contains a specific value. - - The object to locate in the . - - true if is found in the ; otherwise, false. - - - - - Copies to. - - The array. - Index of the array. - - - - Removes the first occurrence of a specific object from the . - - The object to remove from the . - - true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original . - - Slices are readonly - - - - Gets or sets the element at the specified index. - - The index. - - - - - Gets the index from which the slice starts - - - - - Gets the number of elements contained in the . - - The number of elements contained in the . - - - - Gets a value indicating whether this operates in a reversed direction. - - - true if this operates in a reversed direction; otherwise, false. - - - - - Gets a value indicating whether the is read-only. - - true if the is read-only; otherwise, false. - - - - A class representing a script coroutine - - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as DynValue(s) - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as System.Object. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Gets this coroutine as a typed enumerable which can be looped over for resuming. - Returns its result as the specified type. Only the first element of tuples is returned. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - The purpose of this method is to convert a MoonSharp/Lua coroutine to a Unity3D coroutine. - This loops over the coroutine, discarding returned values, and returning null for each invocation. - This means however that the coroutine will be invoked each frame. - Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - The arguments. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - - - - Resumes the coroutine. - - The ScriptExecutionContext. - - - - - Resumes the coroutine. - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - The arguments. - - Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - - - - Resumes the coroutine - - The ScriptExecutionContext. - The arguments. - - - - - Gets the coroutine stack trace for debug purposes - - The skip. - The entry source reference. - - - - - Gets the type of coroutine - - - - - Gets the coroutine state. - - - - - Gets the script owning this resource. - - - The script owning this resource. - - - - - - Possible types of coroutine - - - - - A valid coroutine - - - - - A CLR callback assigned to a coroutine. - - - - - A CLR callback assigned to a coroutine and already executed. - - - - - Class used to support "tail" continuations - a way for C# / Lua interaction which supports - coroutine yielding (at the expense of a LOT of added complexity in calling code). - - - - - Gets or sets the function to call - - - - - Gets or sets the arguments to the function - - - - - Gets or sets the callback to be used as a continuation. - - - - - Gets or sets the callback to be used in case of errors. - - - - - Gets or sets the error handler to be called before stack unwinding - - - - - Class exposing C# objects as Lua userdata. - For efficiency, a global registry of types is maintained, instead of a per-script one. - - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type for userdata interop - - The type to be registered - The access mode (optional). - Friendly name for the type (optional) - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers a type with a custom userdata descriptor - - The type to be registered - The custom descriptor. - - - - Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. - - The assembly. - if set to true extension types are registered to the appropriate registry. - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The type to be unregistered - - - - Unregisters a type. - WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - Use this only for testing purposes or to re-register the same type in a slightly different way. - Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - - The The type to be unregistered - - - - Creates a userdata DynValue from the specified object, using a specific descriptor - - The object - The descriptor. - - - - - Creates a userdata DynValue from the specified object - - The object - - - - - Creates a static userdata DynValue from the specified IUserDataDescriptor - - The IUserDataDescriptor - - - - - Creates a static userdata DynValue from the specified Type - - The type - - - - - Creates a static userdata DynValue from the specified Type - - The Type - - - - - Registers an extension Type (that is a type containing extension methods) - - The type. - The InteropAccessMode. - - - - Gets all the extension methods which can match a given name - - The name. - - - - - Gets a number which gets incremented everytime the extension methods registry changes. - Use this to invalidate caches based on extension methods - - - - - - Gets or sets the "uservalue". See debug.getuservalue and debug.setuservalue. - http://www.lua.org/manual/5.2/manual.html#pdf-debug.setuservalue - - - - - Gets the object associated to this userdata (null for statics) - - - - - Gets the type descriptor of this userdata - - - - - Gets or sets the registration policy to be used in the whole application - - - - - Gets or sets the default access mode to be used in the whole application - - - The default access mode. - - InteropAccessMode is InteropAccessMode.Default - - - - Constants of well known "symbols" in the MoonSharp grammar - - - - - The variadic argument symbol ("...") - - - - - The environment symbol ("_ENV") - - - - - Class wrapping a request to yield a coroutine - - - - - The return values of the coroutine - - - - - Wrapper for a debugger initiated action - - - - - Initializes a new instance of the class. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - The type of action - - - - - Gets the time stamp UTC of this action - - - - - Gets or sets the source identifier this action refers to. - - - - - Gets or sets the source line this action refers to. - - - - - Gets or sets the source column this action refers to. - - - - - Gets the age of this debugger action - - - - - Type of the action - - - - - Step-in at the bytecode level - - - - - Step-over at the bytecode level - - - - - Step-out at the bytecode level - - - - - Step-in at the source level - - - - - Step-over at the source level - - - - - Step-out at the source level - - - - - Continue execution "freely" - - - - - Toggles breakpoint - - - - - Sets a breakpoint - - - - - Clears a breakpoint - - - - - Refresh the data - - - - - Hard refresh of data - - - - - No action - - - - - Interface for debuggers to implement, in order to provide debugging facilities to Scripts. - - - - - Called by the script engine when a source code is added or changed. - - The source code object. - - - - Called by the script engine when the bytecode changes. - - The bytecode source - - - - Called by the script engine at execution time to check if a break has - been requested. Should return pretty fast as it's called A LOT. - - - - - Called by the script engine when a runtime error occurs. - The debugger can return true to signal the engine that it wants to break - into the source of the error. If it does so, it should also return true - to subsequent calls to IsPauseRequested(). - - The runtime exception. - True if this error should break execution. - - - - Called by the script engine to get what action to do next. - - The instruction pointer in bytecode. - The source reference. - T - - - - Called by the script engine when the execution ends. - - - - - Called by the script engine to update watches of a given type. Note - that this method is not called only for watches in the strictest term, - but also for the stack, etc. - - Type of the watch. - The items. - - - - Called by the script engine to get which expressions are active - watches in the debugger. - - A list of watches - - - - Called by the script engine to refresh the breakpoint list. - - - - - Class representing a reference to source code interval - - - - - Gets a value indicating whether this instance is a breakpoint - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets whether the source ref includes the specified location - - Index of the source. - The line. - The column. - - - - - Sets the CannotBreakpoint flag. - - - - - - Formats the location according to script preferences - - The script. - if set to true the classic Lua format is forced. - - - - - Gets a value indicating whether this location is inside CLR . - - - - - Gets the index of the source. - - - - - Gets from which column the source code ref starts - - - - - Gets to which column the source code ref ends - - - - - Gets from which line the source code ref starts - - - - - Gets to which line the source code ref ends - - - - - Gets a value indicating whether this instance is a stop "step" in source mode - - - - - Gets a value indicating whether this instance cannot be set as a breakpoint - - - - - A watch item for the debugger to consume. - Most properties make or not sense depending on the WatchType. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Gets or sets the address of the item - - - - - Gets or sets the base pointer (base value of v-stack at entering the function). - Valid only for call-stack items - - - - - Gets or sets the return address. - Valid only for call-stack items - - - - - Gets or sets the name of the item - - - - - Gets or sets the value of the item - - - - - Gets or sets the symbol reference of the item - - - - - Gets or sets a value indicating whether this instance is generating an error. - - - - - Gets or sets the source location this item refers to. - - - - - Enumeration of the possible watch types - - - - - A real variable watch - - - - - The status of the v-stack - - - - - The call stack - - - - - The list of coroutines - - - - - The maximum value of this enum - - - - - Enumeration of the possible performance counters - - - - - Measures the time spent parsing the source creating the AST - - - - - Measures the time spent converting ASTs in bytecode - - - - - Measures the time spent in executing scripts - - - - - Measures the on the fly creation/compilation of functions in userdata descriptors - - - - - Sentinel value to get the enum size - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Enumeration of unit of measures of the performance counters - - - - - The performance counter is specified in bytes (of memory) - - - - - The performance counter is specified in milliseconds - - - - - A single object of this type exists for every script and gives access to performance statistics. - - - - - Gets the result of the specified performance counter . - - The PerformanceCounter. - - - - - Starts a stopwatch. - - - - - - Starts a stopwatch. - - - - - - Gets a string with a complete performance log. - - - - - - Gets or sets a value indicating whether this collection of performance stats is enabled. - - - true if enabled; otherwise, false. - - - - - The result of a performance counter - - - - - Returns a that represents this instance. - - - - - Converts a PerformanceCounterType to a string. - - The type. - - - - Gets the name of the performance counter which generated this result. - - - - - Gets the quantity monitored - see Type to understand what this field contains - - - - - Gets the number of instances which led to the specified counter being incremented - e.g. the times a specific - code is executed, or object instanced - - - - - Gets a value indicating whether this is global or relative to the resource - for which it's called. - - - - - Gets the unit of measure of the Counter field. - - - - - This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - You are free to reuse this instance after calling Dispose. - - - - - Exception thrown when an inconsistent state is reached in the interpreter - - - - - Exception for all parsing/lexing errors. - - - - - Gets or sets a value indicating whether this exception was caused by premature stream termination (that is, unexpected EOF). - This can be used in REPL interfaces to tell between unrecoverable errors and those which can be recovered by extra input. - - - - - This class is a container for arguments received by a CallbackFunction - - - - - Initializes a new instance of the class. - - The arguments. - if set to true [is method call]. - - - - Gets the at the specified index, or null. - - The index. - if set to true all voids are translated to nils. - - - - - Converts the arguments to an array - - The number of elements to skip (default= 0). - - - - - Gets the specified argument as as an argument of the specified type. If not possible, - an exception is raised. - - The argument number. - Name of the function. - The type desired. - if set to true nil values are allowed. - - - - - Gets the specified argument as as an argument of the specified user data type. If not possible, - an exception is raised. - - The desired userdata type - The argument number. - Name of the function. - if set to true nil values are allowed. - - - - - Gets the specified argument as an integer - - The argument number. - Name of the function. - - - - - Gets the specified argument as a string, calling the __tostring metamethod if needed, in a NON - yield-compatible way. - - The execution context. - The argument number. - Name of the function. - - 'tostring' must return a string to '{0}' - - - - Returns a copy of CallbackArguments where the first ("self") argument is skipped if this was a method call, - otherwise returns itself. - - - - - - Gets the count of arguments - - - - - Gets or sets a value indicating whether this is a method call. - - - - - Gets the at the specified index, or Void if not found - - - - - A class representing a script function - - - - - Shortcut for an empty closure - - - - - Initializes a new instance of the class. - - The script. - The index. - The symbols. - The resolved locals. - - - - Calls this function with the specified args - - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Calls this function with the specified args - - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Gets a delegate wrapping calls to this scripted function - - - - - - Gets a delegate wrapping calls to this scripted function - - The type of return value of the delegate. - - - - - Gets the number of upvalues in this closure - - The number of upvalues in this closure - - - - Gets the name of the specified upvalue. - - The index of the upvalue. - The upvalue name - - - - Gets the value of an upvalue - - The index of the upvalue. - The value of an upvalue - - - - Gets the type of the upvalues contained in this closure - - - - - - Gets the entry point location in bytecode . - - - - - Gets the script owning this function - - - - - The current closure context - - - - - Type of closure based on upvalues - - - - - The closure has no upvalues (thus, technically, it's a function and not a closure!) - - - - - The closure has _ENV as its only upvalue - - - - - The closure is a "real" closure, with multiple upvalues - - - - - This class wraps a CLR function - - - - - Initializes a new instance of the class. - - The callback function to be called. - The callback name, used in stacktraces, debugger, etc.. - - - - Invokes the callback function - - The execution context. - The arguments. - if set to true this is a method call. - - - - - Creates a CallbackFunction from a delegate. - - The script. - The delegate. - The access mode. - - - - - Creates a CallbackFunction from a MethodInfo relative to a function. - - The script. - The MethodInfo object. - The object to which the function applies, or null for static methods. - The access mode. - - The method is not static. - - - - Checks the callback signature of a method is compatible for callbacks - - - - - Gets the name of the function - - - - - Gets the call back. - - - The call back. - - - - - Gets or sets the default access mode used when marshalling delegates - - - The default access mode. Default, HideMembers and BackgroundOptimized are NOT supported. - - Default, HideMembers and BackgroundOptimized are NOT supported. - - - - Gets or sets an object used as additional data to the callback function (available in the execution context). - - - - - A class representing a value in a Lua/MoonSharp script. - - - - - Creates a new writable value initialized to Nil. - - - - - Creates a new writable value initialized to the specified boolean. - - - - - Creates a new writable value initialized to the specified number. - - - - - Creates a new writable value initialized to the specified string. - - - - - Creates a new writable value initialized to the specified StringBuilder. - - - - - Creates a new writable value initialized to the specified string using String.Format like syntax - - - - - Creates a new writable value initialized to the specified coroutine. - Internal use only, for external use, see Script.CoroutineCreate - - The coroutine object. - - - - - Creates a new writable value initialized to the specified closure (function). - - - - - Creates a new writable value initialized to the specified CLR callback. - - - - - Creates a new writable value initialized to the specified CLR callback. - See also CallbackFunction.FromDelegate and CallbackFunction.FromMethodInfo factory methods. - - - - - Creates a new writable value initialized to the specified table. - - - - - Creates a new writable value initialized to an empty table. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The function to be called. - The arguments. - - - - - Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - although it's not always possible to use it. When a function (callback or script closure) returns a - TailCallRequest, the bytecode processor immediately executes the function contained in the request. - By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - of functionality (state savings, coroutines, etc) keeps working at full power. - - The data for the tail call. - - - - - Creates a new request for a yield of the current coroutine. - - The yield argumenst. - - - - - Creates a new tuple initialized to the specified values. - - - - - Creates a new tuple initialized to the specified values - which can be potentially other tuples - - - - - Creates a new userdata value - - - - - Returns this value as readonly - eventually cloning it in the process if it isn't readonly to start with. - - - - - Clones this instance. - - - - - - Clones this instance, overriding the "readonly" status. - - if set to true the new instance is set as readonly, or writeable otherwise. - - - - - Clones this instance, returning a writable copy. - - Can't clone Symbol values - - - - Returns a string which is what it's expected to be output by the print function applied to this value. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Returns a hash code for this instance. - - - A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - - - - - Determines whether the specified , is equal to this instance. - - The to compare with this instance. - - true if the specified is equal to this instance; otherwise, false. - - - - - Casts this DynValue to string, using coercion if the type is number. - - The string representation, or null if not number, not string. - - - - Casts this DynValue to a double, using coercion if the type is string. - - The string representation, or null if not number, not string or non-convertible-string. - - - - Casts this DynValue to a bool - - False if value is false or nil, true otherwise. - - - - Converts a tuple to a scalar value. If it's already a scalar value, this function returns "this". - - - - - Performs an assignment, overwriting the value with the specified one. - - The value. - If the value is readonly. - - - - Gets the length of a string or table value. - - - Value is not a table or string. - - - - Determines whether this instance is nil or void - - - - - Determines whether this instance is not nil or void - - - - - Determines whether this instance is void - - - - - Determines whether this instance is not void - - - - - Determines whether is nil, void or NaN (and thus unsuitable for using as a table key). - - - - - Changes the numeric value of a number DynValue. - - - - - Creates a new DynValue from a CLR object - - The script. - The object. - - - - - Converts this MoonSharp DynValue to a CLR object. - - - - - Converts this MoonSharp DynValue to a CLR object of the specified type. - - - - - Checks the type of this value corresponds to the desired type. A propert ScriptRuntimeException is thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - Name of the function requesting the value, for error message purposes. - The desired data type. - The argument number, for error message purposes. - The TypeValidationFlags. - - Thrown - if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - to the specified type. - - - - Checks if the type is a specific userdata type, and returns it or throws. - - - Name of the function. - The argument number. - The flags. - - - - - Gets a unique reference identifier. This is guaranteed to be unique only for dynvalues created in a single thread as it's not thread-safe. - - - - - Gets the type of the value. - - - - - Gets the function (valid only if the is ) - - - - - Gets the numeric value (valid only if the is ) - - - - - Gets the values in the tuple (valid only if the is Tuple). - This field is currently also used to hold arguments in values whose is . - - - - - Gets the coroutine handle. (valid only if the is Thread). - - - - - Gets the table (valid only if the is ) - - - - - Gets the boolean value (valid only if the is ) - - - - - Gets the string value (valid only if the is ) - - - - - Gets the CLR callback (valid only if the is ) - - - - - Gets the tail call data. - - - - - Gets the yield request data. - - - - - Gets the tail call data. - - - - - Returns true if this instance is write protected. - - - - - A preinitialized, readonly instance, equaling Void - - - - - A preinitialized, readonly instance, equaling Nil - - - - - A preinitialized, readonly instance, equaling True - - - - - A preinitialized, readonly instance, equaling False - - - - - A class representing a key/value pair for Table use - - - - - Initializes a new instance of the struct. - - The key. - The value. - - - - Gets the key. - - - - - Gets or sets the value. - - - - - Gets the nil pair - - - - - Class giving access to details of the environment where the script is executing - - - - - Gets the metatable associated with the given value. - - The value. - - - - - Gets the specified metamethod associated with the given value. - - The value. - The metamethod name. - - - - - prepares a tail call request for the specified metamethod, or null if no metamethod is found. - - - - - Gets the metamethod to be used for a binary operation using op1 and op2. - - - - - Gets the script object associated with this request - - - - - - Gets the coroutine which is performing the call - - - - - Calls a callback function implemented in "classic way". - Useful to port C code from Lua, or C# code from UniLua and KopiLua. - Lua : http://www.lua.org/ - UniLua : http://github.com/xebecnan/UniLua - KopiLua : http://github.com/NLua/KopiLua - - The arguments. - Name of the function - for error messages. - The callback. - - - - - Calls the specified function, supporting most cases. The called function must not yield. - - The function; it must be a Function or ClrFunction or have a call metamethod defined. - The arguments. - - If the function yields, returns a tail call request with continuations/handlers or, of course, if it encounters errors. - - - - Tries to get the reference of a symbol in the current execution state - - - - - Tries to get the value of a symbol in the current execution state - - - - - Finds a symbol by name in the current execution state - - - - - Performs a message decoration before unwinding after an error. To be used in the implementation of xpcall like functions. - - The message handler. - The exception. - - - - Gets a value indicating whether this instance is running a dynamic execution. - Under a dynamic execution, most methods of ScriptExecutionContext are not reliable as the - processing engine of the script is not "really" running or is not available. - - - - - Gets the location of the code calling back - - - - - Gets or sets the additional data associated to this CLR function call. - - - - - Gets the current global env, or null if not found. - - - - - Class representing the source code of a given script - - - - - Gets the code snippet represented by a source ref - - The source code reference. - - - - - Gets the name of the source code - - - - - Gets the source code as a string - - - - - Gets the source code lines. - - - - - Gets the script owning this resource. - - - - - Gets the source identifier inside a script - - - - - State of coroutines - - - - - This is the main coroutine - - - - - Coroutine has not started yet - - - - - Coroutine is suspended - - - - - Coroutine is running - - - - - Coroutine has terminated - - - - - Wrappers for enumerables as return types - - - - - LINQ helper methods - - - - - Converts the specified enumerable dynvalues of a given script type to objects of a given type - - The desired type - The enumerable. - The type. - - - - Filters an enumeration for items of the given script type - - The enumerable. - The script type. - - - - Converts the elements to CLR objects - - The enumerable. - - - - Converts the elements to CLR objects of the desired type - - The desired type - The enumerable. - - - - - - - - - Marks a type of automatic registration as userdata (which happens only if UserData.RegisterAssembly is called). - - - - - Initializes a new instance of the class. - - - - - The interop access mode - - - - - Forces a class member visibility to scripts. Can be used to hide public members or to expose non-public ones. - - - - - Initializes a new instance of the class. - - if set to true the member will be exposed to scripts, if false the member will be hidden. - - - - Gets a value indicating whether this is set to "visible". - - - - - Descriptor which acts as a non-containing adapter from IUserDataType to IUserDataDescriptor - - - - - Initializes a new instance of the class. - - The type. - Name of the friendly. - - - - Performs an "index" "get" operation. - - The script originating the request - The object (null if a static request is done) - The index. - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Performs an "index" "set" operation. - - The script originating the request - The object (null if a static request is done) - The index. - The value to be set - If set to true, it's indexed with a name, if false it's indexed through brackets. - - - - - Converts this userdata to string - - The object. - - - - - Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - it should return "null" (not a nil). - These standard metamethods can be supported (the return value should be a function accepting the - classic parameters of the corresponding metamethod): - __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - __pairs, __ipairs, __iterator, __call - These standard metamethods are supported through other calls for efficiency: - __index, __newindex, __tostring - - The script originating the request - The object (null if a static request is done) - The name of the metamember. - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Gets the name of the descriptor (usually, the name of the type described). - - - - - Gets the type this descriptor refers to - - - - - Determines whether the specified object is compatible with the specified type. - Unless a very specific behaviour is needed, the correct implementation is a - simple " return type.IsInstanceOfType(obj); " - - The type. - The object. - - - - - Standard descriptor for userdata types. - - - - - Initializes a new instance of the class. - - The type this descriptor refers to. - The interop access mode this descriptor uses for members access - A human readable friendly name of the descriptor. - - - - Fills the member list. - - - - - Gets the interop access mode this descriptor uses for members access - - - - - Enumerations of the possible strategies to marshal CLR objects to MoonSharp userdata and functions - when using automatic descriptors. - Note that these are "hints" and MoonSharp is free to ignore the access mode specified (if different from - HideMembers) and downgrade the access mode to "Reflection". - This particularly happens when running on AOT platforms like iOS. - See also : and . - - - - - Optimization is not performed and reflection is used everytime to access members. - This is the slowest approach but saves a lot of memory if members are seldomly used. - - - - - Optimization is done on the fly the first time a member is accessed. - This saves memory for all members that are never accessed, at the cost of an increased script execution time. - - - - - Optimization is done at registration time. - - - - - Optimization is done in a background thread which starts at registration time. - If a member is accessed before optimization is completed, reflection is used. - - - - - No optimization is done, and members are not accessible at all. - - - - - No reflection is allowed, nor code generation. This is used as a safeguard when registering types which should not - use a standard reflection based descriptor - for example for types implementing - - - - - Use the default access mode - - - - - Class providing easier marshalling of CLR functions - - - - - Tries to create a new StandardUserDataMethodDescriptor, returning - null in case the method is not - visible to script code. - - The MethodBase. - The - if set to true forces visibility. - - A new StandardUserDataMethodDescriptor or null. - - - - - Initializes a new instance of the class. - - The MethodBase (MethodInfo or ConstructorInfo) got through reflection. - The interop access mode. - Invalid accessMode - - - - Checks if the method is compatible with a standard descriptor - - The MethodBase. - if set to true an exception with the proper error message is thrown if not compatible. - - - Thrown if throwException is true and one of this applies: - The method contains unresolved generic parameters, or has an unresolved generic return type - or - The method contains pointer parameters, or has a pointer return type - - - - - Gets a callback function as a delegate - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function. - - The script for which the callback must be generated. - The object (null for static). - - - - - Gets the callback function as a DynValue. - - The script for which the callback must be generated. - The object (null for static). - - - - - Creates a callback DynValue starting from a MethodInfo. - - The script. - The mi. - The object. - - - - - The internal callback which actually executes the method - - The script. - The object. - The context. - The arguments. - - - - - Gets the value of this member as a to be exposed to scripts. - - The script. - The object owning this member, or null if static. - - The value of this member as a . - - - - - Sets the value. - - The script. - The object. - The v. - - - - - Gets the method information (can be a MethodInfo or ConstructorInfo) - - - - - Gets the access mode used for interop - - - - - Gets a value indicating whether the described method is static. - - - - - Gets the name of the described method - - - - - Gets a value indicating whether the described method is a constructor - - - - - Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - - - - - Gets the type of the arguments of the underlying CLR function - - - - - Gets the type which this extension method extends, null if this is not an extension method. - - - - - Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - null is returned. - - - - - Gets the types of access supported by this member - - - - - Class providing easier marshalling of CLR properties - - - - - Tries to create a new StandardUserDataPropertyDescriptor, returning null in case the property is not - visible to script code. - - The PropertyInfo. - The - A new StandardUserDataPropertyDescriptor or null. - - - - Initializes a new instance of the class. - NOTE: This constructor gives get/set visibility based exclusively on the CLR visibility of the - getter and setter methods. - - The pi. - The access mode. - - - - Initializes a new instance of the class. - - The PropertyInfo. - The - The getter method. Use null to make the property writeonly. - The setter method. Use null to make the property readonly. - - - - Gets the value of the property - - The script. - The object. - - - - - Sets the value of the property - - The script. - The object. - The value to set. - - - - Called by standard descriptors when background optimization or preoptimization needs to be performed. - - - - - Gets the PropertyInfo got by reflection - - - - - Gets the - - - - - Gets a value indicating whether the described property is static. - - - - - Gets the name of the property - - - - - Gets a value indicating whether this instance can be read from - - - true if this instance can be read from; otherwise, false. - - - - - Gets a value indicating whether this instance can be written to. - - - true if this instance can be written to; otherwise, false. - - - - - Gets the types of access supported by this member - - - - - The scope of a closure (container of upvalues) - - - - - Gets the symbols. - - - - - Enumeration of the types of SymbolRef - - - - - The symbol ref of a local variable - - - - - The symbol ref of an upvalue variable - - - - - The symbol ref of a global variable - - - - - The symbol ref of the global environment - - - - - This class stores a possible l-value (that is a potential target of an assignment) - - - - - Creates a new symbol reference pointing to a global var - - The name. - The _ENV symbol. - - - - - Creates a new symbol reference pointing to a local var - - The name. - The index of the var in local scope. - - - - - Creates a new symbol reference pointing to an upvalue var - - The name. - The index of the var in closure scope. - - - - - Returns a that represents this instance. - - - A that represents this instance. - - - - - Writes this instance to a binary stream - - - - - Reads a symbolref from a binary stream - - - - - Gets the type of this symbol reference - - - - - Gets the index of this symbol in its scope context - - - - - Gets the name of this symbol - - - - - Gets the environment this symbol refers to (for global symbols only) - - - - - Gets the default _ENV. - - - - - Enumeration of possible data types in MoonSharp - - - - - A nil value, as in Lua - - - - - A place holder for no value - - - - - A Lua boolean - - - - - A Lua number - - - - - A Lua string - - - - - A Lua function - - - - - A Lua table - - - - - A set of multiple values - - - - - A userdata reference - that is a wrapped CLR object - - - - - A coroutine handle - - - - - A callback function - - - - - A request to execute a tail call - - - - - A request to coroutine.yield - - - - - Extension methods to DataType - - - - - Determines whether this data type can have type metatables. - - The type. - - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function, with additional values - to support debuggers - - The type. - - The DataType is not a Lua type - - - - Converts the DataType to the string returned by the "type(...)" Lua function - - The type. - - The DataType is not a Lua type - - - - A script loader loading scripts from an assembly resources - - - - - A base implementation of IScriptLoader, offering resolution of module names. - - - - - Class dictating how requests to read scripts from files are handled. - - It's recommended that no class implement IScriptLoader directly, and rather extend ScriptLoaderBase. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile) - - The modname. - The global context. - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - Resolves the name of a module on a set of paths. - - The modname. - The paths. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable (if and only if - the IgnoreLuaPathGlobal is false), and - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - Unpacks a string path in a form like "?;?.lua" to an array - - - - - Gets the default environment paths. - - - - - Resolves a filename [applying paths, etc.] - - The filename. - The global context. - - - - - Gets or sets the modules paths used by the "require" function. If null, the default paths are used (using - environment variables etc.). - - - - - Gets or sets a value indicating whether the LUA_PATH global is checked or not to get the path where modules are contained. - If true, the LUA_PATH global is NOT checked. - - - - - Initializes a new instance of the class. - - The assembly containing the scripts as embedded resources or null to use the calling assembly. - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - - - - - Checks if a script file exists. - - The script filename. - - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - - - - A script loader used for platforms we cannot initialize in any better way.. - - - - - An implementation of which supports a very basic history of recent input lines. - - - - - This class provides a simple REPL intepreter ready to be reused in a simple way. - - - - - Initializes a new instance of the class. - - The script. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - This method returns the result of the computation, or null if more input is needed for a computation. - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "?" as a - dynamic expression to evaluate instead of script code (likely invalid) - - - - - Gets or sets a value indicating whether this instances handle inputs starting with a "=" as a - non-dynamic expression to evaluate (just like the Lua interpreter does by default). - - - - - Gets a value indicating whether this instance has a pending command - - - - - Gets the current pending command. - - - - - Gets the classic prompt (">" or ">>") given the current state of the interpreter - - - - - Initializes a new instance of the class. - - The script. - Size of the history. - - - - Evaluate a REPL command. - This method returns the result of the computation, or null if more input is needed for having valid code. - In case of errors, exceptions are propagated to the caller. - - The input. - - This method returns the result of the computation, or null if more input is needed for a computation. - - - - - Gets the previous item in history, or null - - - - - Gets the next item in history, or null - - - - - A script loader loading scripts directly from the file system (does not go through platform object) - AND starts with module paths taken from environment variables (again, not going through the platform object). - - The paths are preconstructed using : - * The MOONSHARP_PATH environment variable if it exists - * The LUA_PATH_5_2 environment variable if MOONSHARP_PATH does not exists - * The LUA_PATH environment variable if LUA_PATH_5_2 and MOONSHARP_PATH do not exists - * The "?;?.lua" path if all the above fail - - Also, everytime a module is require(d), the "LUA_PATH" global variable is checked. If it exists, those paths - will be used to load the module instead of the global ones. - - - - - Initializes a new instance of the class. - - - - - Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - The resolution happens first on paths included in the LUA_PATH global variable, and - - if the variable does not exist - by consulting the - ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - - The modname. - The global context. - - - - - A script loader which can load scripts from assets in Unity3D. - Scripts should be saved as .txt files in a subdirectory of Assets/Resources. - - When MoonSharp is activated on Unity3D and the default script loader is used, - scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. - - - - - The default path where scripts are meant to be stored (if not changed) - - - - - Initializes a new instance of the class. - - The path, relative to Assets/Resources. For example - if your scripts are stored under Assets/Resources/Scripts, you should - pass the value "Scripts". If null, "MoonSharp/Scripts" is used. - - - - Opens a file for reading the script code. - It can return either a string, a byte[] or a Stream. - If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - - The file. - The global context. - - A string, a byte[] or a Stream. - - UnityAssetsScriptLoader.LoadFile : Cannot load + file - - - - Checks if a given file exists - - The file. - - - - - Gets the list of loaded scripts filenames (useful for debugging purposes). - - - - - - In a module type, mark fields with this attribute to have them exposed as a module constant. - - See for more information about modules. - - - - - Gets or sets the name of the constant - if different from the name of the field itself - - - - - Namespace containing all the most commonly used classes for MoonSharp operation. - When in doubt, refer to and classes as starting points. - - - - - Namespace containing the implementation of the Lua standard library, as MoonSharp modules. - There's seldom the need to access these classes directly. - - - - - Namespace containing userdata classes for the 'io' module - - - - - Namespace containing classes used to support debuggers - - - - - Namespace containing classes used to support self diagnostics (e.g. performance counters) - - - - - Namespace containing classes used to customize and support advanced interoperations between - scripts and CLR code. - - - - - Namespace containing classes used to provide a minimal support for porting code based on the classic - "LuaState" model (e.g. code based on KopiLua, UniLua or Lua itself). - - - - - Namespace containing classes used to customized how scripts are loaded from external files. - - - - - Namespace containing classes used to customize how the interfacing with the operative system happens - for the 'os' and 'io' modules, and for future modules/classes which may require OS access. - See and . - - - - - Contains classes useful to implement REPL interpreters. - See : - - - - - Interface to abstract all accesses made to the underlying platform (OS, framework) by the scripting engine. - Can be used both to support "non-standard" platforms (i.e. non-posix, non-windows) and/or to sandbox the behaviour - of the scripting engine. - - It's recommended that no class implement IPlatformAccessor directly, and rather extend . - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - Gets the name of the platform (used for debug purposes). - - The name of the platform (used for debug purposes) - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If a meaningful implementation cannot be provided, this method should return null. - - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - The script. - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - True if the file exists, false otherwise. - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - An abstract class which offers basic services on top of IPlatformAccessor to provide easier implementation of platforms. - - - - - Gets the platform name prefix - - - - - - Gets the name of the platform (used for debug purposes). - - - The name of the platform (used for debug purposes) - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - DEPRECATED. - This is kept for backward compatibility, see the overload taking a prompt as an input parameter. - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - Default handler for interactive line input calls. Can be customized in ScriptOptions. - If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - - null - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Determines whether the application is running in AOT (ahead-of-time) mode - - - - - A static class offering properties for autodetection of system/platform details - - - - - Gets a value indicating whether this instance is running on mono. - - - - - Gets a value indicating whether this instance is running on a CLR4 compatible implementation - - - - - Gets a value indicating whether this instance is running on Unity-3D - - - - - Gets a value indicating whether this instance has been built as a Portable Class Library - - - - - Gets a value indicating whether this instance is running a system using Ahead-Of-Time compilation - and not supporting JIT. - - - - - A class implementing all the bits needed to have a minimal support of a platform. - This does not support the 'io'/'file' modules and has partial support of the 'os' module. - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - A function used to open files in the 'io' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a standard stream (stdin, stdout, stderr). - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The type. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Exits the process, returning the specified exit code. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The exit code. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Checks if a file exists. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - - True if the file exists, false otherwise. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Deletes the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The file. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Moves the specified file. Used by the 'os' module. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The source. - The DST. - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - thus does not support 'io' and 'os' modules. - - The cmdline. - - The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - - - - Gets the platform name prefix - - - - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - - Enumeration of standard file handles - - - - - Standard Input - - - - - Standard Output - - - - - Standard Error Output - - - - - Class providing the IPlatformAccessor interface for standard full-feaured implementations. - - - - - Converts a Lua string access mode to a FileAccess enum - - The mode. - - - - - Converts a Lua string access mode to a ParseFileMode enum - - The mode. - - - - - A function used to open files in the 'io' module. - Can have an invalid implementation if 'io' module is filtered out. - It should return a correctly initialized Stream for the given file and access - - - The filename. - The encoding. - The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - - - - - Gets an environment variable. Must be implemented, but an implementation is allowed - to always return null if a more meaningful implementation cannot be achieved or is - not desired. - - The envvarname. - - The environment variable value, or null if not found - - - - - Gets a standard stream (stdin, stdout, stderr). - - The type. - - type - - - - Default handler for 'print' calls. Can be customized in ScriptOptions - - The content. - - - - Gets a temporary filename. Used in 'io' and 'os' modules. - Can have an invalid implementation if 'io' and 'os' modules are filtered out. - - - - - - Exits the process, returning the specified exit code. - Can have an invalid implementation if the 'os' module is filtered out. - - The exit code. - - - - Checks if a file exists. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - True if the file exists, false otherwise. - - - - - Deletes the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The file. - - - - Moves the specified file. Used by the 'os' module. - Can have an invalid implementation if the 'os' module is filtered out. - - The source. - The DST. - - - - Executes the specified command line, returning the child process exit code and blocking in the meantime. - Can have an invalid implementation if the 'os' module is filtered out. - - The cmdline. - - - - - Filters the CoreModules enumeration to exclude non-supported operations - - The requested modules. - - The requested modules, with unsupported modules filtered out. - - - - - Gets the platform name prefix - - - - - - - This class implements a MoonSharp scripting session. Multiple Script objects can coexist in the same program but cannot share - data among themselves unless some mechanism is put in place. - - - - - The version of the MoonSharp engine - - - - - The Lua version being supported - - - - - Initializes the class. - - - - - Initializes a new instance of the clas.s - - - - - Initializes a new instance of the class. - - The core modules to be pre-registered in the default global table. - - - - Loads a string containing a Lua/MoonSharp function. - - The code. - The global table to bind to this chunk. - Name of the function used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads a Lua/MoonSharp script from a System.IO.Stream. NOTE: This will *NOT* close the stream! - - The stream containing code. - The global table to bind to this chunk. - Name of the code - used to report errors, etc. - - A DynValue containing a function which will execute the loaded code. - - - - - Dumps on the specified stream. - - The function. - The stream. - - function arg is not a function! - or - stream is readonly! - or - function arg has upvalues other than _ENV - - - - - Loads a string containing a Lua/MoonSharp script. - - The code. - The global table to bind to this chunk. - The filename to be used in error messages. - - A DynValue containing a function which will execute the loaded code. - - - - - Loads and executes a string containing a Lua/MoonSharp script. - - The code. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a stream containing a Lua/MoonSharp script. - - The stream. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Loads and executes a file containing a Lua/MoonSharp script. - - The filename. - The global context. - - A DynValue containing the result of the processing of the loaded chunk. - - - - - Runs the specified file with all possible defaults for quick experimenting. - - The filename. - A DynValue containing the result of the processing of the executed script. - - - - Runs the specified code with all possible defaults for quick experimenting. - - The Lua/MoonSharp code. - A DynValue containing the result of the processing of the executed script. - - - - Creates a closure from a bytecode address. - - The address. - The env table to create a 0-upvalue - - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - The return value(s) of the function call. - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - - Thrown if function is not of DataType.Function - - - - Calls the specified function. - - The Lua/MoonSharp function to be called - The arguments to pass to the function. - - Thrown if function is not of DataType.Function - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Creates a coroutine pointing at the specified function. - - The function. - - The coroutine handle. - - Thrown if function is not of DataType.Function or DataType.ClrFunction - - - - Gets the main chunk function. - - A DynValue containing a function which executes the first chunk that has been loaded. - - - - Attaches a debugger. This usually should be called by the debugger itself and not by user code. - - The debugger object. - - - - Gets the source code. - - The source code identifier. - - - - - Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html - - The module name - The global context. - - Raised if module is not found - - - - Gets a type metatable. - - The type. - - - - - Sets a type metatable. - - The type. Must be Nil, Boolean, Number, String or Function - The metatable. - Specified type not supported : + type.ToString() - - - - Warms up the parser/lexer structures so that MoonSharp operations start faster. - - - - - Creates a new dynamic expression. - - The code of the expression. - - - - - Creates a new dynamic expression which is actually quite static, returning always the same constant value. - - The code of the not-so-dynamic expression. - The constant to return. - - - - - Gets an execution context exposing only partial functionality, which should be used for - those cases where the execution engine is not really running - for example for dynamic expression - or calls from CLR to CLR callbacks - - - - - Gets or sets the script loader which will be used as the value of the - ScriptLoader property for all newly created scripts. - - - - - Gets access to the script options. - - - - - Gets the global options, that is options which cannot be customized per-script. - - - - - Gets access to performance statistics. - - - - - Gets the default global table for this script. Unless a different table is intentionally passed (or setfenv has been used) - execution uses this table. - - - - - Gets the source code count. - - - The source code count. - - - - - MoonSharp (like Lua itself) provides a registry, a predefined table that can be used by any CLR code to - store whatever Lua values it needs to store. - Any CLR code can store data into this table, but it should take care to choose keys - that are different from those used by other libraries, to avoid collisions. - Typically, you should use as key a string GUID, a string containing your library name, or a - userdata with the address of a CLR object in your code. - - - - - A class representing a Lua table. - - - - - Initializes a new instance of the class. - - The owner script. - - - - Removes all items from the Table. - - - - - Gets the integral key from a double. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) - - The key. - - - - - Gets the dynvalue associated with the specified key (expressed as a System.Object) as a System.Object. - - The key. - - - - - Sets the dynvalue associated with the specified key. Both expressed as System.Object. - - The key. - The value. - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Gets the value associated with the specified key, without bringing to Nil the non-existant values. - - The key. - - - - - Sets the value associated to the specified key. - - The key. - The value. - - - - Gets the value associated with the specified key. - - The key. - - - - - Collects the dead keys. This frees up memory but invalidates pending iterators. - It's called automatically internally when the semantics of Lua tables allow, but can be forced - externally if it's known that no iterators are pending. - - - - - Returns the next pair from a value - - - - - Gets the script owning this resource. - - - - - Gets or sets the - with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - Multiple keys can be used to access subtables. - - - The . - - The key. - Optional subkeys to access subtables - - - - - Gets or sets the with the specified key(s). - This will marshall CLR and MoonSharp objects in the best possible way. - - - The . - - The key. - - - - - Gets the length of the "array part". - - - - - Gets the meta-table associated with this instance. - - - - - Enumerates the key/value pairs. - - - - - - Enumerates the keys. - - - - - - Enumerates the values - - - - - - A preallocated, non-resizable, stack - - - - - - Enumeration (combinable as flags) of all the standard library modules - - - - - Value used to specify no modules to be loaded (equals 0). - - - - - The basic methods. Includes "assert", "collectgarbage", "error", "print", "select", "type", "tonumber" and "tostring". - - - - - The global constants: "_G", "_VERSION" and "_MOONSHARP". - - - - - The table iterators: "next", "ipairs" and "pairs". - - - - - The metatable methods : "setmetatable", "getmetatable", "rawset", "rawget", "rawequal" and "rawlen". - - - - - The string package - - - - - The load methods: "load", "loadsafe", "loadfile", "loadfilesafe", "dofile" and "require" - - - - - The table package - - - - - The error handling methods: "pcall" and "xpcall" - - - - - The math package - - - - - The coroutine package - - - - - The bit32 package - - - - - The time methods of the "os" package: "clock", "difftime", "date" and "time" - - - - - The methods of "os" package excluding those listed for OS_Time. These are not supported under Unity. - - - - - The methods of "io" and "file" packages. These are not supported under Unity. - - - - - The "debug" package (it has limited support) - - - - - The "dynamic" package (introduced by MoonSharp). - - - - - A sort of "hard" sandbox preset, including string, math, table, bit32 packages, constants and table iterators. - - - - - A softer sandbox preset, adding metatables support, error handling, coroutine, time functions and dynamic evaluations. - - - - - The default preset. Includes everything except "debug" as now. - Beware that using this preset allows scripts unlimited access to the system. - - - - - The complete package. - Beware that using this preset allows scripts unlimited access to the system. - - - - - Class managing modules (mostly as extension methods) - - - - - Register the core modules to a table - - The table. - The modules. - - - - - Registers the standard constants (_G, _VERSION, _MOONSHARP) to a table - - The table. - - - - - Registers a module type to the specified table - - The table. - The type - - If the module contains some incompatibility - - - - Registers a module type to the specified table - - The module type - The table. - - If the module contains some incompatibility - - - - In a module type, mark methods or fields with this attribute to have them exposed as module functions. - Methods must have the signature "public static DynValue ...(ScriptExecutionContextCallbackArguments)". - Fields must be static or const strings, with an anonymous Lua function inside. - - See for more information about modules. - - - - - Gets or sets the name of the function in the module (defaults to member name) - - - - - Marks a CLR type to be a MoonSharp module. - Modules are the fastest way to bring interop between scripts and CLR code, albeit at the cost of a very increased - complexity in writing them. Modules is what's used for the standard library, for maximum efficiency. - - Modules are basically classes containing only static methods, with the callback function signature. - - See and for (extension) methods used to register modules to a - table. - - See for information regarding the standard callback signature along with easier ways - to marshal methods. - - See for easier object marshalling. - - - - - Gets or sets the namespace, that is the name of the table which will contain the defined functions. - Can be null to be in the global table. - - - - - Class containing script global options, that is options which cannot be customized per-script. - - - - - - Gets or sets the custom converters. - - - - - Gets or sets the platform abstraction to use. - - - The current platform abstraction. - - - - - This class contains options to customize behaviour of Script objects. - - - - - Gets or sets the current script-loader. - - - - - Gets or sets the debug print handler - - - - - Gets or sets the debug input handler (takes a prompt as an input, for interactive interpreters, like debug.debug). - - - - - Gets or sets a value indicating whether error messages will use Lua error locations instead of MoonSharp - improved ones. Use this for compatibility with legacy Lua code which parses error messages. - - - - - Gets or sets the stream used as stdin. If null, a default stream is used. - - - - - Gets or sets the stream used as stdout. If null, a default stream is used. - - - - - Gets or sets the stream used as stderr. If null, a default stream is used. - - - - - Gets or sets the stack depth threshold at which MoonSharp starts doing - tail call optimizations. - TCOs can provide the little benefit of avoiding stack overflows in corner case - scenarios, at the expense of losing debug information and error stack traces - in all other, more common scenarios. MoonSharp choice is to start performing - TCOs only after a certain threshold of stack usage is reached - by default - half the current stack depth (128K entries), thus 64K entries, on either - the internal stacks. - Set this to int.MaxValue to disable TCOs entirely, or to 0 to always have - TCOs enabled. - - - - - Gets or sets a value indicating whether the thread check is enabled. - A "lazy" thread check is performed everytime execution is entered to ensure that no two threads - calls MoonSharp execution concurrently. However 1) the check is performed best effort (thus, it might - not detect all issues) and 2) it might trigger in very odd legal situations (like, switching threads - inside a CLR-callback without actually having concurrency. - - Disable this option if the thread check is giving problems in your scenario, but please check that - you are not calling MoonSharp execution concurrently as it is not supported. - - - - - Primaries the exp. - - The lcontext. - - - - - - - - - - Creates a sub tree of binary expressions - - - - diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.Debugger.0.9.4.0/MoonSharp.Debugger.0.9.4.0.nupkg b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.Debugger.0.9.4.0/MoonSharp.Debugger.0.9.4.0.nupkg deleted file mode 100644 index 572aa4a6..00000000 Binary files a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/MoonSharp.Debugger.0.9.4.0/MoonSharp.Debugger.0.9.4.0.nupkg and /dev/null differ diff --git a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/repositories.config b/src/DevTools/Nuget_Tests/NugetTests_net35/packages/repositories.config deleted file mode 100644 index 5c04ec63..00000000 --- a/src/DevTools/Nuget_Tests/NugetTests_net35/packages/repositories.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/DevTools/PerformanceComparison/CallbacksAndForthTests.cs b/src/DevTools/PerformanceComparison/CallbacksAndForthTests.cs deleted file mode 100644 index 9c30894b..00000000 --- a/src/DevTools/PerformanceComparison/CallbacksAndForthTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter; -using NLua; - -namespace PerformanceComparison -{ - [MoonSharpUserData] - public class ChampionPropertiesComponent - { - string name; - - internal void SetFirstName(string p) - { - name = p; - } - - internal void SetLastName(string p) - { - name += " " + p; - } - - public string getName() - { - return name; - } - - internal ChampionPropertiesComponent ToInterface() - { - return this; - } - } - - - class CallbacksAndForthTests - { - public static void xxMain() - { - (new CallbacksAndForthTests()).Start(); - //Console.ReadLine(); - } - - private void Start() - { - //UserData.DefaultAccessMode = InteropAccessMode.Preoptimized; - UserData.RegisterAssembly(); - - //var nLuaState = new Lua(); - var moonSharpState = new Script(); - - const string script = @" - a = """" - onUpdate = function(championPropertiesComponent) - a = championPropertiesComponent:getName() - end - "; - - //nLuaState.DoString(script); - moonSharpState.DoString(script); - - var championProperties = new ChampionPropertiesComponent(); - championProperties.SetFirstName("John"); - championProperties.SetLastName("Smith"); - - //var nLuaFunction = (LuaFunction)nLuaState["onUpdate"]; - var moonSharpFunction = (Closure)moonSharpState.Globals["onUpdate"]; - - int startTime, endTime; - - //// Test NLua - //startTime = Environment.TickCount; - //for (int i = 0; i < 100000; i++) nLuaFunction.Call(championProperties.ToInterface()); - //endTime = Environment.TickCount; - //Console.WriteLine("NLua : {0}", endTime - startTime); - - // Test MoonSharp - startTime = Environment.TickCount; - //DynValue v = DynValue.FromObject(moonSharpState, championProperties.ToInterface()); - for (int i = 0; i < 100000; i++) moonSharpFunction.Call(championProperties.ToInterface()); - endTime = Environment.TickCount; - Console.WriteLine("MoonSharp : {0}", endTime - startTime); - } - - } -} diff --git a/src/DevTools/PerformanceComparison/CoroutineTest.cs b/src/DevTools/PerformanceComparison/CoroutineTest.cs deleted file mode 100644 index b3b8becf..00000000 --- a/src/DevTools/PerformanceComparison/CoroutineTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices.ComTypes; -using System.Text; -using System.Threading.Tasks; -using MoonSharp.Interpreter; - -namespace PerformanceComparison -{ - class CoroutineTest - { - public static void xMain() - { - string code = @" - return function() - local x = 0 - while true do - x = x + 1 - coroutine.yield(x) - end - end - "; - - // Load the code and get the returned function - Script script = new Script(); - DynValue function = script.DoString(code); - - // Create the coroutine in C# - DynValue coroutine = script.CreateCoroutine(function); - - // Resume the coroutine forever and ever.. - while (true) - { - DynValue x = coroutine.Coroutine.Resume(); - Console.WriteLine("{0}", x); - } - } - - - public static void xxMain() - { - string code = @" - function a() - callback(b) - end - - function b() - coroutine.yield(); - end - - c = coroutine.create(a); - - return coroutine.resume(c); - "; - - // Load the code and get the returned function - Script script = new Script(); - - script.Globals["callback"] = DynValue.NewCallback( - (ctx, args) => args[0].Function.Call() - ); - - DynValue ret = script.DoString(code); - - // false, "attempt to yield from outside a coroutine" - Console.WriteLine(ret); - - - - Console.ReadKey(); - } - - - - - - - } -} diff --git a/src/DevTools/PerformanceComparison/HugeFile.cs b/src/DevTools/PerformanceComparison/HugeFile.cs deleted file mode 100644 index aeabafd4..00000000 --- a/src/DevTools/PerformanceComparison/HugeFile.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter; - - -namespace PerformanceComparison -{ - public class HugeFile - { - static void xxMain(string[] args) - { - Console.WriteLine("Started..."); - Script.WarmUp(); - Console.WriteLine("Warmed-up..."); - - Script s = new Script(CoreModules.None); - // s.LoadFile(@"C:\gr\tsg\mod_assets\scripts\alcoves.lua"); - //s.LoadFile(@"C:\temp\test3.lua"); - - Stopwatch sw = Stopwatch.StartNew(); - - //for (int i = 0; i < 10; i++) - var v = s.LoadFile(@"C:\temp\test3.lua"); - - //for(int i = 0; i < 1000; i++) - // s.Call(v); - - sw.Stop(); - - Console.WriteLine("Ended : {0} ms", sw.ElapsedMilliseconds); - - Console.WriteLine(s.PerformanceStats.GetPerformanceLog()); - Console.ReadLine(); - } - - - - } -} diff --git a/src/DevTools/PerformanceComparison/PerformanceComparison.csproj b/src/DevTools/PerformanceComparison/PerformanceComparison.csproj deleted file mode 100644 index cdd14080..00000000 --- a/src/DevTools/PerformanceComparison/PerformanceComparison.csproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Debug - AnyCPU - {01C3C379-C816-4779-942D-0263763F8EA5} - Exe - Properties - PerformanceComparison - PerformanceComparison - v4.5.1 - 512 - - - - - - - - - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 0 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - false - prompt - MinimumRecommendedRules.ruleset - false - - - true - bin\Dev\ - DEBUG;TRACE - 0 - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Dev\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - DEBUG;TRACE - 0 - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Devp4\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\..\..\..\prg\NLua\NLua.dll - - - - - - - - - - - - Code - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/PerformanceComparison/Program.cs b/src/DevTools/PerformanceComparison/Program.cs deleted file mode 100644 index aeb6812f..00000000 --- a/src/DevTools/PerformanceComparison/Program.cs +++ /dev/null @@ -1,197 +0,0 @@ -// This code is a workbench code - it gets commented on the fly, changed, etc. -// Disable warnings for "assigned but value never used" and "unreachable code". -#pragma warning disable 414 -#pragma warning disable 429 - -//#define PROFILER - -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.Execution; -using NLua; -using System.Diagnostics; - -namespace PerformanceComparison -{ - class Program - { -#if PROFILER - const int ITERATIONS = 10; -#else - const int ITERATIONS = 1; -#endif - - static string scriptText = @" - function move(n, src, dst, via) - if n > 0 then - move(n - 1, src, via, dst) - --check(src, 'to', dst) - move(n - 1, via, dst, src) - end - end - - for i = 1, 10000 do - move(4, 1, 2, 3) - end - "; - static string scriptText22 = @" -N = 8 - -board = {} -for i = 1, N do - board[i] = {} - for j = 1, N do - board[i][j] = false - end -end - -function Allowed( x, y ) - for i = 1, x-1 do - if ( board[i][y] ) or ( i <= y and board[x-i][y-i] ) or ( y+i <= N and board[x-i][y+i] ) then - return false - end - end - return true -end - -function Find_Solution( x ) - for y = 1, N do - if Allowed( x, y ) then - board[x][y] = true - if x == N or Find_Solution( x+1 ) then - return true - end - board[x][y] = false - end - end - return false -end - -if Find_Solution( 1 ) then - for i = 1, N do - for j = 1, N do - if board[i][j] then - --print( 'Q' ) - else - --print( 'x' ) - end - end - --print( '|' ) - end -else - --print( 'NO!' ) -end - - "; - static StringBuilder g_MoonSharpStr = new StringBuilder(); - static StringBuilder g_NLuaStr = new StringBuilder(); - - public static DynValue Check(ScriptExecutionContext executionContext, CallbackArguments values) - { - //foreach (var val in values.GetArray()) - //{ - // g_MoonSharpStr.Append(val.ToPrintString()); - //} - - //g_MoonSharpStr.AppendLine(); - return DynValue.Nil; - } - - - public static void NCheck(params object[] values) - { - //foreach (var val in values) - //{ - // g_NLuaStr.Append(val.ToString()); - //} - //g_NLuaStr.AppendLine(); - } - - public static void XCheck(int from, string mid, int to) - { - g_MoonSharpStr.Append(from); - g_MoonSharpStr.Append(mid); - g_MoonSharpStr.Append(to); - g_MoonSharpStr.AppendLine(); - } - - static Lua lua = new Lua(); - static string testString = "world"; - - static void Main(string[] args) - { - Script.WarmUp(); - - Stopwatch sw; - - sw = Stopwatch.StartNew(); - - var _s = new Script(); - _s.LoadString(scriptText); - - sw.Stop(); - - Console.WriteLine("Build : {0} ms", sw.ElapsedMilliseconds); - - sw = Stopwatch.StartNew(); - - var script = new Script(); - script.Globals.Set("check", DynValue.NewCallback(new CallbackFunction(Check))); - CallbackFunction.DefaultAccessMode = InteropAccessMode.Preoptimized; - - //script.Globals["print"] = (Action)PrintX; - - - DynValue func = script.LoadString(scriptText); - - sw.Stop(); - - Console.WriteLine("Build 2: {0} ms", sw.ElapsedMilliseconds); - - - sw = Stopwatch.StartNew(); - for (int i = 0; i < ITERATIONS; i++) - { - script.Call(func); - } - sw.Stop(); - - Console.WriteLine("MoonSharp : {0} ms", sw.ElapsedMilliseconds); - - - lua.RegisterFunction("check", typeof(Program).GetMethod("NCheck")); - - File.WriteAllText(@"c:\temp\hanoi.lua", scriptText); - -#if !PROFILER - - var fn = lua.LoadFile(@"c:\temp\hanoi.lua"); - - sw = Stopwatch.StartNew(); - for (int i = 0; i < ITERATIONS; i++) - { - fn.Call(); - } - sw.Stop(); - -#endif - - Console.WriteLine("NLua : {0} ms", sw.ElapsedMilliseconds); - - Console.WriteLine("M# == NL ? {0}", g_MoonSharpStr.ToString() == g_NLuaStr.ToString()); - - Console.WriteLine("=== MoonSharp ==="); - //Console.WriteLine(g_MoonSharpStr.ToString()); - Console.WriteLine(""); - Console.WriteLine("=== NLua ==="); - //Console.WriteLine(g_NLuaStr.ToString()); - - Console.ReadKey(); - } - } -} diff --git a/src/DevTools/PerformanceComparison/Properties/AssemblyInfo.cs b/src/DevTools/PerformanceComparison/Properties/AssemblyInfo.cs deleted file mode 100644 index d2e68238..00000000 --- a/src/DevTools/PerformanceComparison/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PerformanceComparison")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PerformanceComparison")] -[assembly: AssemblyCopyright("Copyright © 2014-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("40bffac0-24eb-4141-815d-f75076bce829")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/PerformanceComparison/Sample.cs b/src/DevTools/PerformanceComparison/Sample.cs deleted file mode 100644 index 56705a8b..00000000 --- a/src/DevTools/PerformanceComparison/Sample.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MoonSharp.Interpreter; - -namespace PerformanceComparison -{ - class Sample - { - - // This prints : - // 3 - // hello world - // 3 - // hello world - // 3 - // hello world - // 3 - // hello world - // Done - public static void xxMain() - { - string code = @" - x = 3 - - function onThis() - print(x) - x = 'hello' - end - - function onThat() - print(x .. ' world') - x = 3 - end - "; - - // Load the code - Script script = new Script(); - script.DoString(code); - - var onThis = script.Globals.Get("onThis").Function.GetDelegate(); - var onThat = script.Globals.Get("onThat").Function.GetDelegate(); - - for (int i = 0; i < 4; i++) - { - onThis(); - onThat(); - } - - Console.WriteLine("Done"); - Console.ReadKey(); - } - } -} diff --git a/src/DevTools/PerformanceComparison/app.config b/src/DevTools/PerformanceComparison/app.config deleted file mode 100644 index 884f9844..00000000 --- a/src/DevTools/PerformanceComparison/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/DevTools/Playground/App.config b/src/DevTools/Playground/App.config deleted file mode 100644 index c1fd8012..00000000 --- a/src/DevTools/Playground/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/DevTools/Playground/Playground.csproj b/src/DevTools/Playground/Playground.csproj deleted file mode 100644 index 304834cf..00000000 --- a/src/DevTools/Playground/Playground.csproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Debug - AnyCPU - {F039D7BE-0761-4618-BFA4-924E96584219} - Exe - Properties - Playground - Playground - v3.5 - 512 - Client - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - Always - - - Always - - - Always - - - - - {b25a2316-6897-4caa-be0e-e784071d8199} - MoonSharp.Hardwire.net35-client - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - {43d3ad52-fed5-4305-b0f4-6b991220cd0a} - MoonSharp.RemoteDebugger.net35-client - - - - - - \ No newline at end of file diff --git a/src/DevTools/Playground/Program.cs b/src/DevTools/Playground/Program.cs deleted file mode 100644 index f570edc1..00000000 --- a/src/DevTools/Playground/Program.cs +++ /dev/null @@ -1,39 +0,0 @@ -using MoonSharp.Interpreter; -using System; -using System.Diagnostics; -using System.IO; -using MoonSharp.Interpreter.Loaders; - -namespace Test -{ - class Program - { - static void Main(string[] args) - { - ((ScriptLoaderBase)Script.DefaultOptions.ScriptLoader).ModulePaths = new string[] { "./?", "./?.lua" }; - - try - { - Script S = new Script(); - S.Options.ColonOperatorClrCallbackBehaviour = ColonOperatorBehaviour.TreatAsDotOnUserData; - - S.DoString(@" - -require 'test' -require 'test2' - -"); - - - } - catch (InterpreterException ex) - { - Console.WriteLine(ex.DecoratedMessage); - } - - Console.WriteLine(">> DONE"); - - Console.ReadKey(); - } - } -} \ No newline at end of file diff --git a/src/DevTools/Playground/Properties/AssemblyInfo.cs b/src/DevTools/Playground/Properties/AssemblyInfo.cs deleted file mode 100644 index 34cd00b0..00000000 --- a/src/DevTools/Playground/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Playground")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Playground")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3ca41a0f-4348-475f-87cb-484b3c68c79a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/Playground/Test.cs b/src/DevTools/Playground/Test.cs deleted file mode 100644 index 5f282702..00000000 --- a/src/DevTools/Playground/Test.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/DevTools/Playground/core.lua b/src/DevTools/Playground/core.lua deleted file mode 100644 index 450e9a29..00000000 --- a/src/DevTools/Playground/core.lua +++ /dev/null @@ -1,5 +0,0 @@ - -print "in core.lua" - -print(os.date("*t", os.time()).hour) -print(os.date("!*t", os.time()).hour) diff --git a/src/DevTools/Playground/test.lua b/src/DevTools/Playground/test.lua deleted file mode 100644 index 3761ebaf..00000000 --- a/src/DevTools/Playground/test.lua +++ /dev/null @@ -1,2 +0,0 @@ -require "core" -print("in test 1") diff --git a/src/DevTools/Playground/test2.lua b/src/DevTools/Playground/test2.lua deleted file mode 100644 index 1431f0cd..00000000 --- a/src/DevTools/Playground/test2.lua +++ /dev/null @@ -1,2 +0,0 @@ -require "core" -print("in test 2") diff --git a/src/DevTools/SynchProjects/Program.cs b/src/DevTools/SynchProjects/Program.cs deleted file mode 100755 index 5597ec99..00000000 --- a/src/DevTools/SynchProjects/Program.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Xml; - -namespace SynchProjects -{ - class Program - { - static string BASEPATH; - - static void CopyCompileFilesAsLinks(string platformName, string srcCsProj, string platformDest, string pathPrefix) - { - platformName = AdjustBasePath(platformName); - srcCsProj = AdjustBasePath(srcCsProj); - platformDest = AdjustBasePath(platformDest); - pathPrefix = AdjustBasePath(pathPrefix); - - string dstCsProj = string.Format(platformDest, platformName); - try - { - int warningCount = 0; - const string XMLNS = "http://schemas.microsoft.com/developer/msbuild/2003"; - HashSet linksDone = new HashSet(); - - Console.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine("Synch vsproj compiles {0} ...", Path.GetFileNameWithoutExtension(dstCsProj)); - - XmlDocument xsrc = new XmlDocument(); - XmlDocument xdst = new XmlDocument(); - - xsrc.Load(srcCsProj); - xdst.Load(dstCsProj); - - XmlNamespaceManager sxns = new XmlNamespaceManager(xsrc.NameTable); - XmlNamespaceManager dxns = new XmlNamespaceManager(xdst.NameTable); - - sxns.AddNamespace("ms", XMLNS); - dxns.AddNamespace("ms", XMLNS); - - XmlElement srccont = xsrc.SelectSingleNode("/ms:Project/ms:ItemGroup[count(ms:Compile) != 0]", sxns) as XmlElement; - XmlElement dstcont = xdst.SelectSingleNode("/ms:Project/ms:ItemGroup[count(ms:Compile) != 0]", dxns) as XmlElement; - - // dirty hack - dstcont.InnerXml = srccont.InnerXml; - - List toRemove = new List(); - - foreach (XmlElement xe in dstcont.ChildNodes.OfType()) - { - string file = xe.GetAttribute("Include"); - string link = Path.GetFileName(file); - - if (link.Contains(".g4")) - { - toRemove.Add(xe); - continue; - } - - if (!linksDone.Add(link)) - { - ++warningCount; - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("\t[WARNING] - Duplicate file: {0}", link); - } - - file = pathPrefix + file; - - xe.SetAttribute("Include", file); - - XmlElement xlink = xe.OwnerDocument.CreateElement("Link", XMLNS); - xlink.InnerText = link; - xe.AppendChild(xlink); - } - - foreach (XmlElement xe in toRemove) - xe.ParentNode.RemoveChild(xe); - - xdst.Save(dstCsProj); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("\t[DONE] ({0} warnings)", warningCount); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("\t[ERROR] - {0}", ex.Message); - } - - Console.WriteLine("\n"); - } - - private static string AdjustBasePath(string str) - { - return str.Replace("{BASEPATH}", BASEPATH); - } - - static void Main(string[] args) - { - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("********************************************************"); - Console.WriteLine("* !! REMEMBER TO RSYNC UNITY AND .NET CORE PROJECTS !! *"); - Console.WriteLine("********************************************************"); - - - const string INTERPRETER_PROJECT = @"{BASEPATH}\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj"; - const string INTERPRETER_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.{0}\MoonSharp.Interpreter.{0}.csproj"; - const string INTERPRETER_PATH_PREFIX = @"..\..\"; - - const string DEBUGGER_PROJECT = @"{BASEPATH}\MoonSharp.RemoteDebugger\MoonSharp.RemoteDebugger.net35-client.csproj"; - const string DEBUGGER_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.RemoteDebugger\_Projects\MoonSharp.RemoteDebugger.{0}\MoonSharp.RemoteDebugger.{0}.csproj"; - const string DEBUGGER_PATH_PREFIX = @"..\..\"; - - const string VSCODEDEBUGGER_PROJECT = @"{BASEPATH}\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.net35-client.csproj"; - const string VSCODEDEBUGGER_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.VsCodeDebugger\_Projects\MoonSharp.VsCodeDebugger.{0}\MoonSharp.VsCodeDebugger.{0}.csproj"; - const string VSCODEDEBUGGER_PATH_PREFIX = @"..\..\"; - - const string TESTS_PROJECT = @"{BASEPATH}\MoonSharp.Interpreter.Tests\MoonSharp.Interpreter.Tests.net35-client.csproj"; - const string TESTS_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.Interpreter.Tests\_Projects\MoonSharp.Interpreter.Tests.{0}\MoonSharp.Interpreter.Tests.{0}.csproj"; - const string TESTS_PATH_PREFIX = @"..\..\"; - - string[] INTERPRETER_PLATFORMS = new string[] { "net40-client", "portable40" }; - string[] DEBUGGER_PLATFORMS = new string[] { "net40-client" }; - string[] VSCODEDEBUGGER_PLATFORMS = new string[] { "net40-client" }; - string[] TESTS_PLATFORMS = new string[] { "net40-client", "portable40", "Embeddable.portable40" }; - - CalcBasePath(); - - foreach (string platform in INTERPRETER_PLATFORMS) - CopyCompileFilesAsLinks(platform, INTERPRETER_PROJECT, INTERPRETER_SUBPROJECTS_PATHS, INTERPRETER_PATH_PREFIX); - - foreach (string platform in DEBUGGER_PLATFORMS) - CopyCompileFilesAsLinks(platform, DEBUGGER_PROJECT, DEBUGGER_SUBPROJECTS_PATHS, DEBUGGER_PATH_PREFIX); - - foreach (string platform in VSCODEDEBUGGER_PLATFORMS) - CopyCompileFilesAsLinks(platform, VSCODEDEBUGGER_PROJECT, VSCODEDEBUGGER_SUBPROJECTS_PATHS, VSCODEDEBUGGER_PATH_PREFIX); - - foreach (string platform in TESTS_PLATFORMS) - CopyCompileFilesAsLinks(platform, TESTS_PROJECT, TESTS_SUBPROJECTS_PATHS, TESTS_PATH_PREFIX); - - - Console.ReadLine(); - } - - private static void CalcBasePath() - { - string path = ""; - string[] dir = AppDomain.CurrentDomain.BaseDirectory.Split('\\'); - - for (int i = 0; i < dir.Length; i++) - { - if (dir[i].ToLower() == "devtools") - break; - - if (path.Length > 0) - path = path + "\\" + dir[i]; - else - path = dir[i]; - } - - BASEPATH = path; - } - } -} diff --git a/src/DevTools/SynchProjects/Properties/AssemblyInfo.cs b/src/DevTools/SynchProjects/Properties/AssemblyInfo.cs deleted file mode 100644 index 89e8f0a7..00000000 --- a/src/DevTools/SynchProjects/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SynchProjects")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SynchProjects")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a4934800-dd77-4047-b402-4eec63bbcf2f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/SynchProjects/SynchProjects.csproj b/src/DevTools/SynchProjects/SynchProjects.csproj deleted file mode 100644 index 596e56c0..00000000 --- a/src/DevTools/SynchProjects/SynchProjects.csproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - - Debug - AnyCPU - {321C9CCF-6F9B-4751-AB34-882DEE982A7E} - Exe - Properties - SynchProjects - SynchProjects - v4.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\Dev\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/DevTools/VsCodeDebugger_Testbed/Program.cs b/src/DevTools/VsCodeDebugger_Testbed/Program.cs deleted file mode 100755 index 93db7805..00000000 --- a/src/DevTools/VsCodeDebugger_Testbed/Program.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; -using MoonSharp.Interpreter; -using MoonSharp.VsCodeDebugger; -using MoonSharp.VsCodeDebugger.SDK; - -namespace VsCodeDebugger_Testbed -{ - class Program - { - public static void Main(string[] argv) - { - MoonSharpVsCodeDebugServer server = new MoonSharpVsCodeDebugServer(); - server.Logger = s => Console.WriteLine(s); - server.Start(); - - Script script1 = new Script(); - script1.DoFile(@"Z:/HDD/temp/lua/fact.lua"); - server.AttachToScript(script1, "Script #1"); - Closure func1 = script1.Globals.Get("run").Function; - - Script script2 = new Script(); - script2.DoFile(@"Z:/HDD/temp/lua/fact2.lua"); - server.AttachToScript(script2, "Script #2"); - Closure func2 = script2.Globals.Get("run").Function; - - Console.WriteLine("READY."); - int i = 0; - - server.Current = null; - - while (true)//(Console.ReadKey().Key != ConsoleKey.Escape) - { - if (Console.KeyAvailable) - { - Console.ReadKey(); - server.Detach(script2); - Console.WriteLine("Detached"); - } - - Closure func = ((++i) % 2) == 0 ? func1 : func2; - - try - { - var val = func.Call(5); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine(val.Number); - System.Threading.Thread.Sleep(1000); - } - catch (InterpreterException ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.Write(ex.DecoratedMessage); - } - } - } - } -} diff --git a/src/DevTools/VsCodeDebugger_Testbed/Properties/AssemblyInfo.cs b/src/DevTools/VsCodeDebugger_Testbed/Properties/AssemblyInfo.cs deleted file mode 100644 index 3a7bab12..00000000 --- a/src/DevTools/VsCodeDebugger_Testbed/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("VsCodeDebugger_Testbed")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("VsCodeDebugger_Testbed")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d17dd647-76cf-4d87-bdf7-75e1704e8783")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/DevTools/VsCodeDebugger_Testbed/VsCodeDebugger_Testbed.csproj b/src/DevTools/VsCodeDebugger_Testbed/VsCodeDebugger_Testbed.csproj deleted file mode 100644 index dc30aa4c..00000000 --- a/src/DevTools/VsCodeDebugger_Testbed/VsCodeDebugger_Testbed.csproj +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Debug - AnyCPU - {D17DD647-76CF-4D87-BDF7-75E1704E8783} - Exe - Properties - VsCodeDebugger_Testbed - VsCodeDebugger_Testbed - v3.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - {eb7d4595-299f-489b-90ac-55066a4675f9} - MoonSharp.VsCodeDebugger.net35-client - - - - - \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/.actionScriptProperties b/src/Flash/org.moonsharp.debugger.client/.actionScriptProperties deleted file mode 100644 index b9496357..00000000 --- a/src/Flash/org.moonsharp.debugger.client/.actionScriptProperties +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/.flexProperties b/src/Flash/org.moonsharp.debugger.client/.flexProperties deleted file mode 100644 index f2072112..00000000 --- a/src/Flash/org.moonsharp.debugger.client/.flexProperties +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Flash/org.moonsharp.debugger.client/.project b/src/Flash/org.moonsharp.debugger.client/.project deleted file mode 100644 index 49bde5e9..00000000 --- a/src/Flash/org.moonsharp.debugger.client/.project +++ /dev/null @@ -1,25 +0,0 @@ - - - org.moonsharp.debugger.client - - - - - - com.adobe.flexbuilder.project.flexbuilder - - - - - - com.adobe.flexbuilder.project.flexnature - com.adobe.flexbuilder.project.actionscriptnature - - - - bin-release1 - 2 - C:/git/moonsharp/src/MoonSharp.RemoteDebugger/Resources - - - diff --git a/src/Flash/org.moonsharp.debugger.client/.settings/org.eclipse.core.resources.prefs b/src/Flash/org.moonsharp.debugger.client/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 0365aaa0..00000000 --- a/src/Flash/org.moonsharp.debugger.client/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Wed Oct 22 15:56:57 CEST 2014 -eclipse.preferences.version=1 -encoding/=utf-8 diff --git a/src/Flash/org.moonsharp.debugger.client/bin-release/Main.html b/src/Flash/org.moonsharp.debugger.client/bin-release/Main.html deleted file mode 100644 index 23738b2a..00000000 --- a/src/Flash/org.moonsharp.debugger.client/bin-release/Main.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-

- To view this page ensure that Adobe Flash Player version - 11.1.0 or greater is installed. -

- -
- - - - diff --git a/src/Flash/org.moonsharp.debugger.client/bin-release/Main.swf b/src/Flash/org.moonsharp.debugger.client/bin-release/Main.swf deleted file mode 100644 index f461b470..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/bin-release/Main.swf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/bin-release/playerProductInstall.swf b/src/Flash/org.moonsharp.debugger.client/bin-release/playerProductInstall.swf deleted file mode 100644 index bdc34378..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/bin-release/playerProductInstall.swf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/bin-release/swfobject.js b/src/Flash/org.moonsharp.debugger.client/bin-release/swfobject.js deleted file mode 100644 index bf35c07c..00000000 --- a/src/Flash/org.moonsharp.debugger.client/bin-release/swfobject.js +++ /dev/null @@ -1,777 +0,0 @@ -/*! SWFObject v2.2 - is released under the MIT License -*/ - -var swfobject = function() { - - var UNDEF = "undefined", - OBJECT = "object", - SHOCKWAVE_FLASH = "Shockwave Flash", - SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", - FLASH_MIME_TYPE = "application/x-shockwave-flash", - EXPRESS_INSTALL_ID = "SWFObjectExprInst", - ON_READY_STATE_CHANGE = "onreadystatechange", - - win = window, - doc = document, - nav = navigator, - - plugin = false, - domLoadFnArr = [main], - regObjArr = [], - objIdArr = [], - listenersArr = [], - storedAltContent, - storedAltContentId, - storedCallbackFn, - storedCallbackObj, - isDomLoaded = false, - isExpressInstallActive = false, - dynamicStylesheet, - dynamicStylesheetMedia, - autoHideShow = true, - - /* Centralized function for browser feature detection - - User agent string detection is only used when no good alternative is possible - - Is executed directly for optimal performance - */ - ua = function() { - var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, - u = nav.userAgent.toLowerCase(), - p = nav.platform.toLowerCase(), - windows = p ? /win/.test(p) : /win/.test(u), - mac = p ? /mac/.test(p) : /mac/.test(u), - webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit - ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html - playerVersion = [0,0,0], - d = null; - if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { - d = nav.plugins[SHOCKWAVE_FLASH].description; - if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ - plugin = true; - ie = false; // cascaded feature detection for Internet Explorer - d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); - playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); - playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); - playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; - } - } - else if (typeof win.ActiveXObject != UNDEF) { - try { - var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); - if (a) { // a will return null when ActiveX is disabled - d = a.GetVariable("$version"); - if (d) { - ie = true; // cascaded feature detection for Internet Explorer - d = d.split(" ")[1].split(","); - playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - } - catch(e) {} - } - return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; - }(), - - /* Cross-browser onDomLoad - - Will fire an event as soon as the DOM of a web page is loaded - - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ - - Regular onload serves as fallback - */ - onDomLoad = function() { - if (!ua.w3) { return; } - if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically - callDomLoadFunctions(); - } - if (!isDomLoaded) { - if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); - } - if (ua.ie && ua.win) { - doc.attachEvent(ON_READY_STATE_CHANGE, function() { - if (doc.readyState == "complete") { - doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); - callDomLoadFunctions(); - } - }); - if (win == top) { // if not inside an iframe - (function(){ - if (isDomLoaded) { return; } - try { - doc.documentElement.doScroll("left"); - } - catch(e) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - } - if (ua.wk) { - (function(){ - if (isDomLoaded) { return; } - if (!/loaded|complete/.test(doc.readyState)) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - addLoadEvent(callDomLoadFunctions); - } - }(); - - function callDomLoadFunctions() { - if (isDomLoaded) { return; } - try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early - var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); - t.parentNode.removeChild(t); - } - catch (e) { return; } - isDomLoaded = true; - var dl = domLoadFnArr.length; - for (var i = 0; i < dl; i++) { - domLoadFnArr[i](); - } - } - - function addDomLoadEvent(fn) { - if (isDomLoaded) { - fn(); - } - else { - domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ - } - } - - /* Cross-browser onload - - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ - - Will fire an event as soon as a web page including all of its assets are loaded - */ - function addLoadEvent(fn) { - if (typeof win.addEventListener != UNDEF) { - win.addEventListener("load", fn, false); - } - else if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("load", fn, false); - } - else if (typeof win.attachEvent != UNDEF) { - addListener(win, "onload", fn); - } - else if (typeof win.onload == "function") { - var fnOld = win.onload; - win.onload = function() { - fnOld(); - fn(); - }; - } - else { - win.onload = fn; - } - } - - /* Main function - - Will preferably execute onDomLoad, otherwise onload (as a fallback) - */ - function main() { - if (plugin) { - testPlayerVersion(); - } - else { - matchVersions(); - } - } - - /* Detect the Flash Player version for non-Internet Explorer browsers - - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: - a. Both release and build numbers can be detected - b. Avoid wrong descriptions by corrupt installers provided by Adobe - c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports - - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available - */ - function testPlayerVersion() { - var b = doc.getElementsByTagName("body")[0]; - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - var t = b.appendChild(o); - if (t) { - var counter = 0; - (function(){ - if (typeof t.GetVariable != UNDEF) { - var d = t.GetVariable("$version"); - if (d) { - d = d.split(" ")[1].split(","); - ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - else if (counter < 10) { - counter++; - setTimeout(arguments.callee, 10); - return; - } - b.removeChild(o); - t = null; - matchVersions(); - })(); - } - else { - matchVersions(); - } - } - - /* Perform Flash Player and SWF version matching; static publishing only - */ - function matchVersions() { - var rl = regObjArr.length; - if (rl > 0) { - for (var i = 0; i < rl; i++) { // for each registered object element - var id = regObjArr[i].id; - var cb = regObjArr[i].callbackFn; - var cbObj = {success:false, id:id}; - if (ua.pv[0] > 0) { - var obj = getElementById(id); - if (obj) { - if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! - setVisibility(id, true); - if (cb) { - cbObj.success = true; - cbObj.ref = getObjectById(id); - cb(cbObj); - } - } - else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported - var att = {}; - att.data = regObjArr[i].expressInstall; - att.width = obj.getAttribute("width") || "0"; - att.height = obj.getAttribute("height") || "0"; - if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } - if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } - // parse HTML object param element's name-value pairs - var par = {}; - var p = obj.getElementsByTagName("param"); - var pl = p.length; - for (var j = 0; j < pl; j++) { - if (p[j].getAttribute("name").toLowerCase() != "movie") { - par[p[j].getAttribute("name")] = p[j].getAttribute("value"); - } - } - showExpressInstall(att, par, id, cb); - } - else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF - displayAltContent(obj); - if (cb) { cb(cbObj); } - } - } - } - else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) - setVisibility(id, true); - if (cb) { - var o = getObjectById(id); // test whether there is an HTML object element or not - if (o && typeof o.SetVariable != UNDEF) { - cbObj.success = true; - cbObj.ref = o; - } - cb(cbObj); - } - } - } - } - } - - function getObjectById(objectIdStr) { - var r = null; - var o = getElementById(objectIdStr); - if (o && o.nodeName == "OBJECT") { - if (typeof o.SetVariable != UNDEF) { - r = o; - } - else { - var n = o.getElementsByTagName(OBJECT)[0]; - if (n) { - r = n; - } - } - } - return r; - } - - /* Requirements for Adobe Express Install - - only one instance can be active at a time - - fp 6.0.65 or higher - - Win/Mac OS only - - no Webkit engines older than version 312 - */ - function canExpressInstall() { - return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); - } - - /* Show the Adobe Express Install dialog - - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 - */ - function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { - isExpressInstallActive = true; - storedCallbackFn = callbackFn || null; - storedCallbackObj = {success:false, id:replaceElemIdStr}; - var obj = getElementById(replaceElemIdStr); - if (obj) { - if (obj.nodeName == "OBJECT") { // static publishing - storedAltContent = abstractAltContent(obj); - storedAltContentId = null; - } - else { // dynamic publishing - storedAltContent = obj; - storedAltContentId = replaceElemIdStr; - } - att.id = EXPRESS_INSTALL_ID; - if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } - if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } - doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; - var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", - fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + fv; - } - else { - par.flashvars = fv; - } - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - if (ua.ie && ua.win && obj.readyState != 4) { - var newObj = createElement("div"); - replaceElemIdStr += "SWFObjectNew"; - newObj.setAttribute("id", replaceElemIdStr); - obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - createSWF(att, par, replaceElemIdStr); - } - } - - /* Functions to abstract and display alternative content - */ - function displayAltContent(obj) { - if (ua.ie && ua.win && obj.readyState != 4) { - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - var el = createElement("div"); - obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content - el.parentNode.replaceChild(abstractAltContent(obj), el); - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.replaceChild(abstractAltContent(obj), obj); - } - } - - function abstractAltContent(obj) { - var ac = createElement("div"); - if (ua.win && ua.ie) { - ac.innerHTML = obj.innerHTML; - } - else { - var nestedObj = obj.getElementsByTagName(OBJECT)[0]; - if (nestedObj) { - var c = nestedObj.childNodes; - if (c) { - var cl = c.length; - for (var i = 0; i < cl; i++) { - if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { - ac.appendChild(c[i].cloneNode(true)); - } - } - } - } - } - return ac; - } - - /* Cross-browser dynamic SWF creation - */ - function createSWF(attObj, parObj, id) { - var r, el = getElementById(id); - if (ua.wk && ua.wk < 312) { return r; } - if (el) { - if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content - attObj.id = id; - } - if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML - var att = ""; - for (var i in attObj) { - if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries - if (i.toLowerCase() == "data") { - parObj.movie = attObj[i]; - } - else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - att += ' class="' + attObj[i] + '"'; - } - else if (i.toLowerCase() != "classid") { - att += ' ' + i + '="' + attObj[i] + '"'; - } - } - } - var par = ""; - for (var j in parObj) { - if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries - par += ''; - } - } - el.outerHTML = '' + par + ''; - objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) - r = getElementById(attObj.id); - } - else { // well-behaving browsers - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - for (var m in attObj) { - if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries - if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - o.setAttribute("class", attObj[m]); - } - else if (m.toLowerCase() != "classid") { // filter out IE specific attribute - o.setAttribute(m, attObj[m]); - } - } - } - for (var n in parObj) { - if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element - createObjParam(o, n, parObj[n]); - } - } - el.parentNode.replaceChild(o, el); - r = o; - } - } - return r; - } - - function createObjParam(el, pName, pValue) { - var p = createElement("param"); - p.setAttribute("name", pName); - p.setAttribute("value", pValue); - el.appendChild(p); - } - - /* Cross-browser SWF removal - - Especially needed to safely and completely remove a SWF in Internet Explorer - */ - function removeSWF(id) { - var obj = getElementById(id); - if (obj && obj.nodeName == "OBJECT") { - if (ua.ie && ua.win) { - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - removeObjectInIE(id); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.removeChild(obj); - } - } - } - - function removeObjectInIE(id) { - var obj = getElementById(id); - if (obj) { - for (var i in obj) { - if (typeof obj[i] == "function") { - obj[i] = null; - } - } - obj.parentNode.removeChild(obj); - } - } - - /* Functions to optimize JavaScript compression - */ - function getElementById(id) { - var el = null; - try { - el = doc.getElementById(id); - } - catch (e) {} - return el; - } - - function createElement(el) { - return doc.createElement(el); - } - - /* Updated attachEvent function for Internet Explorer - - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks - */ - function addListener(target, eventType, fn) { - target.attachEvent(eventType, fn); - listenersArr[listenersArr.length] = [target, eventType, fn]; - } - - /* Flash Player and SWF content version matching - */ - function hasPlayerVersion(rv) { - var pv = ua.pv, v = rv.split("."); - v[0] = parseInt(v[0], 10); - v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" - v[2] = parseInt(v[2], 10) || 0; - return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; - } - - /* Cross-browser dynamic CSS creation - - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php - */ - function createCSS(sel, decl, media, newStyle) { - if (ua.ie && ua.mac) { return; } - var h = doc.getElementsByTagName("head")[0]; - if (!h) { return; } // to also support badly authored HTML pages that lack a head element - var m = (media && typeof media == "string") ? media : "screen"; - if (newStyle) { - dynamicStylesheet = null; - dynamicStylesheetMedia = null; - } - if (!dynamicStylesheet || dynamicStylesheetMedia != m) { - // create dynamic stylesheet + get a global reference to it - var s = createElement("style"); - s.setAttribute("type", "text/css"); - s.setAttribute("media", m); - dynamicStylesheet = h.appendChild(s); - if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { - dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; - } - dynamicStylesheetMedia = m; - } - // add style rule - if (ua.ie && ua.win) { - if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { - dynamicStylesheet.addRule(sel, decl); - } - } - else { - if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { - dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); - } - } - } - - function setVisibility(id, isVisible) { - if (!autoHideShow) { return; } - var v = isVisible ? "visible" : "hidden"; - if (isDomLoaded && getElementById(id)) { - getElementById(id).style.visibility = v; - } - else { - createCSS("#" + id, "visibility:" + v); - } - } - - /* Filter to avoid XSS attacks - */ - function urlEncodeIfNecessary(s) { - var regex = /[\\\"<>\.;]/; - var hasBadChars = regex.exec(s) != null; - return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; - } - - /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) - */ - var cleanup = function() { - if (ua.ie && ua.win) { - window.attachEvent("onunload", function() { - // remove listeners to avoid memory leaks - var ll = listenersArr.length; - for (var i = 0; i < ll; i++) { - listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); - } - // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect - var il = objIdArr.length; - for (var j = 0; j < il; j++) { - removeSWF(objIdArr[j]); - } - // cleanup library's main closures to avoid memory leaks - for (var k in ua) { - ua[k] = null; - } - ua = null; - for (var l in swfobject) { - swfobject[l] = null; - } - swfobject = null; - }); - } - }(); - - return { - /* Public API - - Reference: http://code.google.com/p/swfobject/wiki/documentation - */ - registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { - if (ua.w3 && objectIdStr && swfVersionStr) { - var regObj = {}; - regObj.id = objectIdStr; - regObj.swfVersion = swfVersionStr; - regObj.expressInstall = xiSwfUrlStr; - regObj.callbackFn = callbackFn; - regObjArr[regObjArr.length] = regObj; - setVisibility(objectIdStr, false); - } - else if (callbackFn) { - callbackFn({success:false, id:objectIdStr}); - } - }, - - getObjectById: function(objectIdStr) { - if (ua.w3) { - return getObjectById(objectIdStr); - } - }, - - embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { - var callbackObj = {success:false, id:replaceElemIdStr}; - if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { - setVisibility(replaceElemIdStr, false); - addDomLoadEvent(function() { - widthStr += ""; // auto-convert to string - heightStr += ""; - var att = {}; - if (attObj && typeof attObj === OBJECT) { - for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs - att[i] = attObj[i]; - } - } - att.data = swfUrlStr; - att.width = widthStr; - att.height = heightStr; - var par = {}; - if (parObj && typeof parObj === OBJECT) { - for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs - par[j] = parObj[j]; - } - } - if (flashvarsObj && typeof flashvarsObj === OBJECT) { - for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + k + "=" + flashvarsObj[k]; - } - else { - par.flashvars = k + "=" + flashvarsObj[k]; - } - } - } - if (hasPlayerVersion(swfVersionStr)) { // create SWF - var obj = createSWF(att, par, replaceElemIdStr); - if (att.id == replaceElemIdStr) { - setVisibility(replaceElemIdStr, true); - } - callbackObj.success = true; - callbackObj.ref = obj; - } - else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install - att.data = xiSwfUrlStr; - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - return; - } - else { // show alternative content - setVisibility(replaceElemIdStr, true); - } - if (callbackFn) { callbackFn(callbackObj); } - }); - } - else if (callbackFn) { callbackFn(callbackObj); } - }, - - switchOffAutoHideShow: function() { - autoHideShow = false; - }, - - ua: ua, - - getFlashPlayerVersion: function() { - return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; - }, - - hasFlashPlayerVersion: hasPlayerVersion, - - createSWF: function(attObj, parObj, replaceElemIdStr) { - if (ua.w3) { - return createSWF(attObj, parObj, replaceElemIdStr); - } - else { - return undefined; - } - }, - - showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { - if (ua.w3 && canExpressInstall()) { - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - } - }, - - removeSWF: function(objElemIdStr) { - if (ua.w3) { - removeSWF(objElemIdStr); - } - }, - - createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { - if (ua.w3) { - createCSS(selStr, declStr, mediaStr, newStyleBoolean); - } - }, - - addDomLoadEvent: addDomLoadEvent, - - addLoadEvent: addLoadEvent, - - getQueryParamValue: function(param) { - var q = doc.location.search || doc.location.hash; - if (q) { - if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark - if (param == null) { - return urlEncodeIfNecessary(q); - } - var pairs = q.split("&"); - for (var i = 0; i < pairs.length; i++) { - if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { - return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); - } - } - } - return ""; - }, - - // For internal usage only - expressInstallCallback: function() { - if (isExpressInstallActive) { - var obj = getElementById(EXPRESS_INSTALL_ID); - if (obj && storedAltContent) { - obj.parentNode.replaceChild(storedAltContent, obj); - if (storedAltContentId) { - setVisibility(storedAltContentId, true); - if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } - } - if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } - } - isExpressInstallActive = false; - } - } - }; -}(); diff --git a/src/Flash/org.moonsharp.debugger.client/html-template/index.template.html b/src/Flash/org.moonsharp.debugger.client/html-template/index.template.html deleted file mode 100644 index c3ebcb5a..00000000 --- a/src/Flash/org.moonsharp.debugger.client/html-template/index.template.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
-

- To view this page ensure that Adobe Flash Player version - 11.1.0 or greater is installed. -

- -
- - - - diff --git a/src/Flash/org.moonsharp.debugger.client/html-template/playerProductInstall.swf b/src/Flash/org.moonsharp.debugger.client/html-template/playerProductInstall.swf deleted file mode 100644 index bdc34378..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/html-template/playerProductInstall.swf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/html-template/swfobject.js b/src/Flash/org.moonsharp.debugger.client/html-template/swfobject.js deleted file mode 100644 index bf35c07c..00000000 --- a/src/Flash/org.moonsharp.debugger.client/html-template/swfobject.js +++ /dev/null @@ -1,777 +0,0 @@ -/*! SWFObject v2.2 - is released under the MIT License -*/ - -var swfobject = function() { - - var UNDEF = "undefined", - OBJECT = "object", - SHOCKWAVE_FLASH = "Shockwave Flash", - SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", - FLASH_MIME_TYPE = "application/x-shockwave-flash", - EXPRESS_INSTALL_ID = "SWFObjectExprInst", - ON_READY_STATE_CHANGE = "onreadystatechange", - - win = window, - doc = document, - nav = navigator, - - plugin = false, - domLoadFnArr = [main], - regObjArr = [], - objIdArr = [], - listenersArr = [], - storedAltContent, - storedAltContentId, - storedCallbackFn, - storedCallbackObj, - isDomLoaded = false, - isExpressInstallActive = false, - dynamicStylesheet, - dynamicStylesheetMedia, - autoHideShow = true, - - /* Centralized function for browser feature detection - - User agent string detection is only used when no good alternative is possible - - Is executed directly for optimal performance - */ - ua = function() { - var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, - u = nav.userAgent.toLowerCase(), - p = nav.platform.toLowerCase(), - windows = p ? /win/.test(p) : /win/.test(u), - mac = p ? /mac/.test(p) : /mac/.test(u), - webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit - ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html - playerVersion = [0,0,0], - d = null; - if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { - d = nav.plugins[SHOCKWAVE_FLASH].description; - if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ - plugin = true; - ie = false; // cascaded feature detection for Internet Explorer - d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); - playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); - playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); - playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; - } - } - else if (typeof win.ActiveXObject != UNDEF) { - try { - var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); - if (a) { // a will return null when ActiveX is disabled - d = a.GetVariable("$version"); - if (d) { - ie = true; // cascaded feature detection for Internet Explorer - d = d.split(" ")[1].split(","); - playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - } - catch(e) {} - } - return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; - }(), - - /* Cross-browser onDomLoad - - Will fire an event as soon as the DOM of a web page is loaded - - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ - - Regular onload serves as fallback - */ - onDomLoad = function() { - if (!ua.w3) { return; } - if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically - callDomLoadFunctions(); - } - if (!isDomLoaded) { - if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); - } - if (ua.ie && ua.win) { - doc.attachEvent(ON_READY_STATE_CHANGE, function() { - if (doc.readyState == "complete") { - doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); - callDomLoadFunctions(); - } - }); - if (win == top) { // if not inside an iframe - (function(){ - if (isDomLoaded) { return; } - try { - doc.documentElement.doScroll("left"); - } - catch(e) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - } - if (ua.wk) { - (function(){ - if (isDomLoaded) { return; } - if (!/loaded|complete/.test(doc.readyState)) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - addLoadEvent(callDomLoadFunctions); - } - }(); - - function callDomLoadFunctions() { - if (isDomLoaded) { return; } - try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early - var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); - t.parentNode.removeChild(t); - } - catch (e) { return; } - isDomLoaded = true; - var dl = domLoadFnArr.length; - for (var i = 0; i < dl; i++) { - domLoadFnArr[i](); - } - } - - function addDomLoadEvent(fn) { - if (isDomLoaded) { - fn(); - } - else { - domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ - } - } - - /* Cross-browser onload - - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ - - Will fire an event as soon as a web page including all of its assets are loaded - */ - function addLoadEvent(fn) { - if (typeof win.addEventListener != UNDEF) { - win.addEventListener("load", fn, false); - } - else if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("load", fn, false); - } - else if (typeof win.attachEvent != UNDEF) { - addListener(win, "onload", fn); - } - else if (typeof win.onload == "function") { - var fnOld = win.onload; - win.onload = function() { - fnOld(); - fn(); - }; - } - else { - win.onload = fn; - } - } - - /* Main function - - Will preferably execute onDomLoad, otherwise onload (as a fallback) - */ - function main() { - if (plugin) { - testPlayerVersion(); - } - else { - matchVersions(); - } - } - - /* Detect the Flash Player version for non-Internet Explorer browsers - - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: - a. Both release and build numbers can be detected - b. Avoid wrong descriptions by corrupt installers provided by Adobe - c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports - - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available - */ - function testPlayerVersion() { - var b = doc.getElementsByTagName("body")[0]; - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - var t = b.appendChild(o); - if (t) { - var counter = 0; - (function(){ - if (typeof t.GetVariable != UNDEF) { - var d = t.GetVariable("$version"); - if (d) { - d = d.split(" ")[1].split(","); - ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - else if (counter < 10) { - counter++; - setTimeout(arguments.callee, 10); - return; - } - b.removeChild(o); - t = null; - matchVersions(); - })(); - } - else { - matchVersions(); - } - } - - /* Perform Flash Player and SWF version matching; static publishing only - */ - function matchVersions() { - var rl = regObjArr.length; - if (rl > 0) { - for (var i = 0; i < rl; i++) { // for each registered object element - var id = regObjArr[i].id; - var cb = regObjArr[i].callbackFn; - var cbObj = {success:false, id:id}; - if (ua.pv[0] > 0) { - var obj = getElementById(id); - if (obj) { - if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! - setVisibility(id, true); - if (cb) { - cbObj.success = true; - cbObj.ref = getObjectById(id); - cb(cbObj); - } - } - else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported - var att = {}; - att.data = regObjArr[i].expressInstall; - att.width = obj.getAttribute("width") || "0"; - att.height = obj.getAttribute("height") || "0"; - if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } - if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } - // parse HTML object param element's name-value pairs - var par = {}; - var p = obj.getElementsByTagName("param"); - var pl = p.length; - for (var j = 0; j < pl; j++) { - if (p[j].getAttribute("name").toLowerCase() != "movie") { - par[p[j].getAttribute("name")] = p[j].getAttribute("value"); - } - } - showExpressInstall(att, par, id, cb); - } - else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF - displayAltContent(obj); - if (cb) { cb(cbObj); } - } - } - } - else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) - setVisibility(id, true); - if (cb) { - var o = getObjectById(id); // test whether there is an HTML object element or not - if (o && typeof o.SetVariable != UNDEF) { - cbObj.success = true; - cbObj.ref = o; - } - cb(cbObj); - } - } - } - } - } - - function getObjectById(objectIdStr) { - var r = null; - var o = getElementById(objectIdStr); - if (o && o.nodeName == "OBJECT") { - if (typeof o.SetVariable != UNDEF) { - r = o; - } - else { - var n = o.getElementsByTagName(OBJECT)[0]; - if (n) { - r = n; - } - } - } - return r; - } - - /* Requirements for Adobe Express Install - - only one instance can be active at a time - - fp 6.0.65 or higher - - Win/Mac OS only - - no Webkit engines older than version 312 - */ - function canExpressInstall() { - return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); - } - - /* Show the Adobe Express Install dialog - - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 - */ - function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { - isExpressInstallActive = true; - storedCallbackFn = callbackFn || null; - storedCallbackObj = {success:false, id:replaceElemIdStr}; - var obj = getElementById(replaceElemIdStr); - if (obj) { - if (obj.nodeName == "OBJECT") { // static publishing - storedAltContent = abstractAltContent(obj); - storedAltContentId = null; - } - else { // dynamic publishing - storedAltContent = obj; - storedAltContentId = replaceElemIdStr; - } - att.id = EXPRESS_INSTALL_ID; - if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } - if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } - doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; - var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", - fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + fv; - } - else { - par.flashvars = fv; - } - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - if (ua.ie && ua.win && obj.readyState != 4) { - var newObj = createElement("div"); - replaceElemIdStr += "SWFObjectNew"; - newObj.setAttribute("id", replaceElemIdStr); - obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - createSWF(att, par, replaceElemIdStr); - } - } - - /* Functions to abstract and display alternative content - */ - function displayAltContent(obj) { - if (ua.ie && ua.win && obj.readyState != 4) { - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - var el = createElement("div"); - obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content - el.parentNode.replaceChild(abstractAltContent(obj), el); - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.replaceChild(abstractAltContent(obj), obj); - } - } - - function abstractAltContent(obj) { - var ac = createElement("div"); - if (ua.win && ua.ie) { - ac.innerHTML = obj.innerHTML; - } - else { - var nestedObj = obj.getElementsByTagName(OBJECT)[0]; - if (nestedObj) { - var c = nestedObj.childNodes; - if (c) { - var cl = c.length; - for (var i = 0; i < cl; i++) { - if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { - ac.appendChild(c[i].cloneNode(true)); - } - } - } - } - } - return ac; - } - - /* Cross-browser dynamic SWF creation - */ - function createSWF(attObj, parObj, id) { - var r, el = getElementById(id); - if (ua.wk && ua.wk < 312) { return r; } - if (el) { - if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content - attObj.id = id; - } - if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML - var att = ""; - for (var i in attObj) { - if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries - if (i.toLowerCase() == "data") { - parObj.movie = attObj[i]; - } - else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - att += ' class="' + attObj[i] + '"'; - } - else if (i.toLowerCase() != "classid") { - att += ' ' + i + '="' + attObj[i] + '"'; - } - } - } - var par = ""; - for (var j in parObj) { - if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries - par += ''; - } - } - el.outerHTML = '' + par + ''; - objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) - r = getElementById(attObj.id); - } - else { // well-behaving browsers - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - for (var m in attObj) { - if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries - if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - o.setAttribute("class", attObj[m]); - } - else if (m.toLowerCase() != "classid") { // filter out IE specific attribute - o.setAttribute(m, attObj[m]); - } - } - } - for (var n in parObj) { - if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element - createObjParam(o, n, parObj[n]); - } - } - el.parentNode.replaceChild(o, el); - r = o; - } - } - return r; - } - - function createObjParam(el, pName, pValue) { - var p = createElement("param"); - p.setAttribute("name", pName); - p.setAttribute("value", pValue); - el.appendChild(p); - } - - /* Cross-browser SWF removal - - Especially needed to safely and completely remove a SWF in Internet Explorer - */ - function removeSWF(id) { - var obj = getElementById(id); - if (obj && obj.nodeName == "OBJECT") { - if (ua.ie && ua.win) { - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - removeObjectInIE(id); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.removeChild(obj); - } - } - } - - function removeObjectInIE(id) { - var obj = getElementById(id); - if (obj) { - for (var i in obj) { - if (typeof obj[i] == "function") { - obj[i] = null; - } - } - obj.parentNode.removeChild(obj); - } - } - - /* Functions to optimize JavaScript compression - */ - function getElementById(id) { - var el = null; - try { - el = doc.getElementById(id); - } - catch (e) {} - return el; - } - - function createElement(el) { - return doc.createElement(el); - } - - /* Updated attachEvent function for Internet Explorer - - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks - */ - function addListener(target, eventType, fn) { - target.attachEvent(eventType, fn); - listenersArr[listenersArr.length] = [target, eventType, fn]; - } - - /* Flash Player and SWF content version matching - */ - function hasPlayerVersion(rv) { - var pv = ua.pv, v = rv.split("."); - v[0] = parseInt(v[0], 10); - v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" - v[2] = parseInt(v[2], 10) || 0; - return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; - } - - /* Cross-browser dynamic CSS creation - - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php - */ - function createCSS(sel, decl, media, newStyle) { - if (ua.ie && ua.mac) { return; } - var h = doc.getElementsByTagName("head")[0]; - if (!h) { return; } // to also support badly authored HTML pages that lack a head element - var m = (media && typeof media == "string") ? media : "screen"; - if (newStyle) { - dynamicStylesheet = null; - dynamicStylesheetMedia = null; - } - if (!dynamicStylesheet || dynamicStylesheetMedia != m) { - // create dynamic stylesheet + get a global reference to it - var s = createElement("style"); - s.setAttribute("type", "text/css"); - s.setAttribute("media", m); - dynamicStylesheet = h.appendChild(s); - if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { - dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; - } - dynamicStylesheetMedia = m; - } - // add style rule - if (ua.ie && ua.win) { - if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { - dynamicStylesheet.addRule(sel, decl); - } - } - else { - if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { - dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); - } - } - } - - function setVisibility(id, isVisible) { - if (!autoHideShow) { return; } - var v = isVisible ? "visible" : "hidden"; - if (isDomLoaded && getElementById(id)) { - getElementById(id).style.visibility = v; - } - else { - createCSS("#" + id, "visibility:" + v); - } - } - - /* Filter to avoid XSS attacks - */ - function urlEncodeIfNecessary(s) { - var regex = /[\\\"<>\.;]/; - var hasBadChars = regex.exec(s) != null; - return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; - } - - /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) - */ - var cleanup = function() { - if (ua.ie && ua.win) { - window.attachEvent("onunload", function() { - // remove listeners to avoid memory leaks - var ll = listenersArr.length; - for (var i = 0; i < ll; i++) { - listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); - } - // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect - var il = objIdArr.length; - for (var j = 0; j < il; j++) { - removeSWF(objIdArr[j]); - } - // cleanup library's main closures to avoid memory leaks - for (var k in ua) { - ua[k] = null; - } - ua = null; - for (var l in swfobject) { - swfobject[l] = null; - } - swfobject = null; - }); - } - }(); - - return { - /* Public API - - Reference: http://code.google.com/p/swfobject/wiki/documentation - */ - registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { - if (ua.w3 && objectIdStr && swfVersionStr) { - var regObj = {}; - regObj.id = objectIdStr; - regObj.swfVersion = swfVersionStr; - regObj.expressInstall = xiSwfUrlStr; - regObj.callbackFn = callbackFn; - regObjArr[regObjArr.length] = regObj; - setVisibility(objectIdStr, false); - } - else if (callbackFn) { - callbackFn({success:false, id:objectIdStr}); - } - }, - - getObjectById: function(objectIdStr) { - if (ua.w3) { - return getObjectById(objectIdStr); - } - }, - - embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { - var callbackObj = {success:false, id:replaceElemIdStr}; - if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { - setVisibility(replaceElemIdStr, false); - addDomLoadEvent(function() { - widthStr += ""; // auto-convert to string - heightStr += ""; - var att = {}; - if (attObj && typeof attObj === OBJECT) { - for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs - att[i] = attObj[i]; - } - } - att.data = swfUrlStr; - att.width = widthStr; - att.height = heightStr; - var par = {}; - if (parObj && typeof parObj === OBJECT) { - for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs - par[j] = parObj[j]; - } - } - if (flashvarsObj && typeof flashvarsObj === OBJECT) { - for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + k + "=" + flashvarsObj[k]; - } - else { - par.flashvars = k + "=" + flashvarsObj[k]; - } - } - } - if (hasPlayerVersion(swfVersionStr)) { // create SWF - var obj = createSWF(att, par, replaceElemIdStr); - if (att.id == replaceElemIdStr) { - setVisibility(replaceElemIdStr, true); - } - callbackObj.success = true; - callbackObj.ref = obj; - } - else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install - att.data = xiSwfUrlStr; - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - return; - } - else { // show alternative content - setVisibility(replaceElemIdStr, true); - } - if (callbackFn) { callbackFn(callbackObj); } - }); - } - else if (callbackFn) { callbackFn(callbackObj); } - }, - - switchOffAutoHideShow: function() { - autoHideShow = false; - }, - - ua: ua, - - getFlashPlayerVersion: function() { - return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; - }, - - hasFlashPlayerVersion: hasPlayerVersion, - - createSWF: function(attObj, parObj, replaceElemIdStr) { - if (ua.w3) { - return createSWF(attObj, parObj, replaceElemIdStr); - } - else { - return undefined; - } - }, - - showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { - if (ua.w3 && canExpressInstall()) { - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - } - }, - - removeSWF: function(objElemIdStr) { - if (ua.w3) { - removeSWF(objElemIdStr); - } - }, - - createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { - if (ua.w3) { - createCSS(selStr, declStr, mediaStr, newStyleBoolean); - } - }, - - addDomLoadEvent: addDomLoadEvent, - - addLoadEvent: addLoadEvent, - - getQueryParamValue: function(param) { - var q = doc.location.search || doc.location.hash; - if (q) { - if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark - if (param == null) { - return urlEncodeIfNecessary(q); - } - var pairs = q.split("&"); - for (var i = 0; i < pairs.length; i++) { - if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { - return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); - } - } - } - return ""; - }, - - // For internal usage only - expressInstallCallback: function() { - if (isExpressInstallActive) { - var obj = getElementById(EXPRESS_INSTALL_ID); - if (obj && storedAltContent) { - obj.parentNode.replaceChild(storedAltContent, obj); - if (storedAltContentId) { - setVisibility(storedAltContentId, true); - if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } - } - if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } - } - isExpressInstallActive = false; - } - } - }; -}(); diff --git a/src/Flash/org.moonsharp.debugger.client/org.moonsharp.debugger.client.as3proj b/src/Flash/org.moonsharp.debugger.client/org.moonsharp.debugger.client.as3proj deleted file mode 100644 index 377d886d..00000000 --- a/src/Flash/org.moonsharp.debugger.client/org.moonsharp.debugger.client.as3proj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/AboutBox.mxml b/src/Flash/org.moonsharp.debugger.client/src/AboutBox.mxml deleted file mode 100644 index c4b1f91f..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/AboutBox.mxml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/CustomButtonSkin.mxml b/src/Flash/org.moonsharp.debugger.client/src/CustomButtonSkin.mxml deleted file mode 100644 index 9068d4b5..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/CustomButtonSkin.mxml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/CustomDataGridSkin.mxml b/src/Flash/org.moonsharp.debugger.client/src/CustomDataGridSkin.mxml deleted file mode 100644 index b12a96ed..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/CustomDataGridSkin.mxml +++ /dev/null @@ -1,342 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - 0)) - { - dataGrid.styleManager.getColorNames(colors); // lazily replace color names with ints - rowBackgroundFillColor.color = colors[rowIndex % colors.length]; - } - else - { - // This should be the same as bgFill.color. - rowBackgroundFillColor.color = 0xFFFFFF; - } - } - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/DebuggerViewLogic.as b/src/Flash/org.moonsharp.debugger.client/src/DebuggerViewLogic.as deleted file mode 100644 index 2697f85a..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/DebuggerViewLogic.as +++ /dev/null @@ -1,299 +0,0 @@ -package -{ - import flash.display.LoaderInfo; - import flash.events.*; - import flash.external.ExternalInterface; - import flash.net.XMLSocket; - import flash.system.Security; - import flash.system.System; - import flash.utils.Dictionary; - - import mx.collections.ArrayList; - import mx.controls.Alert; - import mx.controls.List; - import mx.core.FlexGlobals; - import mx.managers.BrowserManager; - import mx.managers.IBrowserManager; - import mx.utils.URLUtil; - - public class DebuggerViewLogic - { - private var m_View : Main; - private var m_Socket : XMLSocket; - - private var m_Sources : Dictionary = new Dictionary(); - private var m_SourceList : ArrayList = new ArrayList(); - - private var m_InstructionPtrHighlight : Highlight = null; - - private var m_ErrorRx:String; - - - public function DebuggerViewLogic(view : Main, loaderInfo: LoaderInfo) - { - m_View = view; - - var domain:String = getDomain(); - var port:int = 1; - - if (domain == null) - { - domain = "127.0.0.1"; - port = 2006; - logMessage("Running under Flex debugger ? Assuming default host/port."); - } - else - { - var portstr:String = FlexGlobals.topLevelApplication.parameters.port; - - logMessage(portstr); - port = int(portstr); - } - - logMessage("Connecting to: " + domain + ":" + port); - - m_Socket = new XMLSocket(domain, port); - - m_Socket.addEventListener(Event.CLOSE, closeHandler); - m_Socket.addEventListener(Event.CONNECT, connectHandler); - m_Socket.addEventListener(DataEvent.DATA, dataHandler); - m_Socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); - m_Socket.addEventListener(ProgressEvent.PROGRESS, progressHandler); - m_Socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); - } - - public function getDomain():String - { - var domain:String = Security.pageDomain; - if (domain == null) return null; - - return URLUtil.getServerName(domain); - } - - - - private function closeHandler(event:Event):void { - onFatalError("Connection closed."); - } - - private function connectHandler(event:Event):void { - trace("connectHandler: " + event); - logMessage("Connection with host established."); - m_Socket.send(); - } - - private function dataHandler(event:DataEvent):void { - - var xml:XML = new XML(event.data); - - var cmd:String = xml.name(); - var list:ArrayList; - - if (cmd == "welcome") - { - m_View.welcome(xml.@app, xml.@moonsharpver); - refresh(); - } - else if (cmd == "source-code") - { - var s : SourceCode = new SourceCode(xml); - m_Sources[s.getId()] = s; - m_SourceList.addItem(s); - m_View.refreshSourceCode(s, m_SourceList); - } - else if (cmd == "source-loc") - { - m_InstructionPtrHighlight = parseHighlight(xml); - m_View.refreshInstructionPtrHighlight(true); - } - else if (cmd == "execution-completed") - { - m_InstructionPtrHighlight = null; - m_View.refreshInstructionPtrHighlight(true); - logMessage("Execution completed."); - } - else if (cmd == "callstack") - { - list = parseWatchData(xml); - m_View.refreshCallStack(list); - } - else if (cmd == "watches") - { - list = parseWatchData(xml); - m_View.refreshWatches(list); - } - else if (cmd == "message") - { - logMessage(xml.toString()); - } - else if (cmd == "breakpoints") - { - refreshBreakpoints(xml); - } - else if (cmd == "error_rx") - { - m_ErrorRx = xml.@arg; - } - } - - public function getInstructionPtrHighlight():Highlight - { - return m_InstructionPtrHighlight; - } - - private function parseWatchData(xml:XML):ArrayList - { - var list:ArrayList = new ArrayList(); - - var items : XMLList = xml.elements(); - - for each (var item : XML in items) - { - var watch:WatchItem = new WatchItem(item); - list.addItem(watch); - } - - return list; - } - - - private function parseHighlight(xml:XML):Highlight - { - var srcid:int = xml.@srcid; - var cf:int = xml.@cf; - var ct:int = xml.@ct; - var lf:int = xml.@lf; - var lt:int = xml.@lt; - - if (m_Sources.hasOwnProperty(srcid)) - { - var src:SourceCode = m_Sources[srcid] as SourceCode; - - var from:int = src.flattenLocation(lf, cf); - var to:int = src.flattenLocation(lt, ct); - - return new Highlight(src, from, to); - } - else - { - logMessage("ERROR: Highlighted source " + srcid.toString() + " not found in sources list."); - return null; - } - } - - public function logMessage(text : String) : void - { - m_View.appendMessage(text); - } - - - private function onFatalError(text : String) : void - { - logMessage(text); - - Alert.show("An error occurred while communicating with the scripting host.\n\nPress OK to reload and retry.\n\nError was:" + text, "Error", Alert.OK, m_View, function():void - { - ExternalInterface.call("document.location.reload", true); - }); - } - - private function ioErrorHandler(event:IOErrorEvent):void { - onFatalError("IO Error : " + event.text); - } - - private function progressHandler(event:ProgressEvent):void { - // trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal); - } - - private function securityErrorHandler(event:SecurityErrorEvent):void { - onFatalError("IO Error : " + event.text); - } - - private function refreshBreakpoints(xml : XML): void - { - for(var i:int = 0; i < m_SourceList.length; i++) - m_SourceList.getItemAt(i).Breakpoints= new Vector.(); - - for each(var x:XML in xml.elements()) - { - var hl:Highlight = parseHighlight(x); - - if (hl != null) - hl.Source.Breakpoints.push(hl); - } - - m_View.refreshBreakpoints(); - } - - public function refresh() : void - { - m_Socket.send(); - } - - public function stepIn() : void - { - m_Socket.send(); - } - - public function stepOut() : void - { - m_Socket.send(); - } - - public function stepOver() : void - { - m_Socket.send(); - } - - public function run() : void - { - m_Socket.send(); - } - - public function pause() : void - { - m_Socket.send(); - } - - public function addWatch(varNames : String) : void - { - var cmd:XML = ; - cmd.@arg = varNames; - m_Socket.send(cmd); - } - - public function removeWatch(varNames : String) : void - { - var cmd:XML = ; - cmd.@arg = varNames; - m_Socket.send(cmd); - } - - - public function toggleBreakpoint(src:int, line:int, col:int, action:String) : void - { - var cmd:XML = ; - cmd.@arg = action; - cmd.@src = src; - cmd.@line = line; - cmd.@col = col; - m_Socket.send(cmd); - } - - public function getErrorRx():String - { - return m_ErrorRx; - } - - public function setErrorRx(val:String):void - { - m_ErrorRx = val; - var cmd:XML = ; - cmd.@arg = val; - m_Socket.send(cmd); - } - - - - } -} \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/Highlight.as b/src/Flash/org.moonsharp.debugger.client/src/Highlight.as deleted file mode 100644 index 1e15de9c..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/Highlight.as +++ /dev/null @@ -1,17 +0,0 @@ -package -{ - public class Highlight - { - public function Highlight(source:SourceCode, from:int, to:int) - { - Source = source; - From = from; - To = to; - } - - public var From:int; - public var To:int; - public var Source:SourceCode; - - } -} \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/InputBox.mxml b/src/Flash/org.moonsharp.debugger.client/src/InputBox.mxml deleted file mode 100644 index a7d388da..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/InputBox.mxml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - 0); - } - - protected function btnOK_clickHandler(event:MouseEvent):void - { - if (!m_Closed) PopUpManager.removePopUp(this); - m_Closed = true; - m_CallBackFunc(txtText.text); - } - - protected function btnCancel_clickHandler(event:MouseEvent):void - { - if (!m_Closed) PopUpManager.removePopUp(this); - m_Closed = true; - - m_CallBackFunc(null); - } - - protected function onLoaded(event:FlexEvent):void - { - txtText.text = m_Default; - lblHelp.text = m_Label; - btnOK.enabled = (txtText.text.length > 0); - txtText.selectAll(); - focusManager.setFocus(txtText); - } - - ]]> - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/MXFTEText.css b/src/Flash/org.moonsharp.debugger.client/src/MXFTEText.css deleted file mode 100644 index 64b9d7c3..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/MXFTEText.css +++ /dev/null @@ -1,237 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* - This style sheet configures many -- but not all -- MX components - to use the new Flash Text Engine (FTE) and Text Layout Framework (TLF) - to display and edit text, rather than using the older TextField class. - - If you are using the command-line MXML compiler, you should apply - this style sheet as one of the themes for your application: - - mxmlc -theme+=frameworks/projects/spark/MXFTEText.css MyApp.mxml - - FTE and TLF provide text rendering and editing - with high-quality international typography and layout. - They support displaying left-to-right (ltr) text such as French, - right-to-left (rtl) text such as Arabic, and bidirectional text - such as a French phrase inside of an Arabic sentence. - FTE and TLF are used for all text rendering in Spark components. - - By using this style sheet, your MX and Spark components can use - the same embedded font; otherwise, you have to embed a font twice, - once with embedAsCFF="true" for Spark components using FTE/TLF - and once with embedAsCFF="false" for MX components using TextField. - - Note: The , , and - components are not supported by this style sheet, because the - FTETextField class does not support all the functionality - that TextField supports. - You should use the , , and - components instead if you require FTE/TLF text. - - You should not modify this file. -*/ - -@namespace charts "mx.charts.chartClasses.*"; -@namespace mx "library://ns.adobe.com/flex/mx"; -@namespace mxair "mx.core.windowClasses.*"; -@namespace olap "mx.controls.olapDataGridClasses.*"; -@namespace s "library://ns.adobe.com/flex/spark"; - -mx|AlertForm -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|Button -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|CalendarLayout -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ColorPicker -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|ComboBox -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|DataGrid -{ - defaultDataGridItemEditor: ClassReference("mx.controls.MXFTETextInput"); - defaultDataGridItemRenderer: ClassReference("mx.controls.dataGridClasses.FTEDataGridItemRenderer"); -} - -mx|DateChooser -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|DateField -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -s|FTEDataGridItemRenderer -{ - paddingLeft: 5 /* to match DataGridItemRenderer in the MX defaults.css */ -} - -mx|Label -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|List -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|ListItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|MenuBarItem -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|MenuItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -s|MXFTETextInput -{ - skinClass: ClassReference("spark.skins.spark.TextInputSkin"); -} - -mx|NumericStepper -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|Panel -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ProgressBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|SwatchPanel -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|TileListItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|TreeItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ToolTip -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGrid -{ - defaultDataGridItemEditor: ClassReference("mx.controls.MXFTETextInput"); - defaultDataGridItemRenderer: ClassReference("mx.controls.advancedDataGridClasses.FTEAdvancedDataGridItemRenderer"); -} - -mx|AdvancedDataGridGroupItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGridHeaderRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGridSortItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mxair|StatusBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mxair|TitleBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|ChartLabel -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|DataTip -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|DualStyleObject -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|Series -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|LegendItem -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -olap|OLAPDataGridGroupRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -s|FTEAdvancedDataGridItemRenderer -{ - paddingLeft: 5 /* to match AdvancedDataGridItemRenderer in the MX defaults.css */ -} - diff --git a/src/Flash/org.moonsharp.debugger.client/src/Main.css b/src/Flash/org.moonsharp.debugger.client/src/Main.css deleted file mode 100644 index 08dfdfa1..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/Main.css +++ /dev/null @@ -1,154 +0,0 @@ -@namespace s "library://ns.adobe.com/flex/spark"; -@namespace mx "library://ns.adobe.com/flex/mx"; - -@font-face -{ - src: url("assets/Ubuntu-R.ttf"); - fontFamily: Ubuntu; - fontStyle: normal; - fontWeight: normal; - embed-as-cff: true; - advancedAntiAliasing: false; -} - -@font-face -{ - src: url("assets/Ubuntu-B.ttf"); - fontFamily: Ubuntu; - fontStyle: normal; - fontWeight: bold; - embed-as-cff: true; - advancedAntiAliasing: false; -} - -@font-face -{ - src: url("assets/UbuntuMono-R.ttf"); - fontFamily: UbuntuMono; - fontStyle: normal; - fontWeight: normal; - advancedAntiAliasing: true; -} - -global -{ - fontFamily: Ubuntu; - contentBackgroundColor: #555555; - chrome-color: #333333; - color: #EEEEEE; - symbol-color: #000000; - roll-over-color: #777777; - selection-color: #B1AEFA; - accent-color: #8C8C8C; - focus-color: #B1AEFA; - focusAlpha: 1; -} - -mx|Alert, mx|TitleWindow, mx|MenuBar, mx|Panel -{ - /* fontFamily: UbuntuMx; */ -} - - -mx|CheckBox,s|CheckBox -{ - symbolColor: #b1aefa; -} - - -s|List -{ - roll-over-color: #777777; - selection-color: #B1AEFA; -} - -s|Button -{ - cornerRadius: 0; - skinClass:ClassReference("CustomButtonSkin"); - borderWeight: 1; - borderColor: #000000; -} - -s|Button:over -{ - chrome-color: #999999; - borderColor: #b1aefa; - borderWeight: 1; - cornerRadius: 0; -} - -s|Button:down -{ - chrome-color: #222222; - borderColor: #b1aefa; - borderWeight: 1; - cornerRadius: 0; -} - -/* // mx|TabNavigator,mx|SwatchPanel */ - -s|Panel,mx|TitleWindow -{ - background-color: #666666; -} - -s|TextArea -{ - color: #CCCCCC; - background-color: #555555; - contentBackgroundColor: #555555; -} - -s|Panel -{ - chrome-color: #222222; - borderAlpha: 0.5; - borderColor: 0; - cornerRadius: 0; - dropShadowVisible: true; - background-color: #484848; -} - -s|RichEditableText -{ - focusedTextSelectionColor: #777777; - unfocusedTextSelectionColor: #777777; -} - - -mx|Accordion -{ - openDuration: 320; - chrome-color: #222222; -} - -s|DropDownList -{ - borderVisible : false; - contentBackgroundColor: #555555; -} - -s|DataGrid -{ - alternatingRowColors : #505050, #555555; - skinClass: ClassReference("CustomDataGridSkin") -} - -mx|ToolTip -{ - color: #000000; -} - - -mx|MenuBar -{ - selectionColor: #B1AEFA; - leading: 0; - contentBackgroundColor: #777777; - roll-over-color: #B1AEFA; -} - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/Main.mxml b/src/Flash/org.moonsharp.debugger.client/src/Main.mxml deleted file mode 100644 index c438dd6e..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/Main.mxml +++ /dev/null @@ -1,449 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; - - private function initializeApp():void { - menuBarCollection = new XMLListCollection(menubarXML); - } - - private function menuHandler(evt:MenuEvent):void - { - var cmd : String = evt.item.@data; - - if (cmd != "top") exec(cmd); - } - - - private var m_Debugger : DebuggerViewLogic; - - protected function application_applicationCompleteHandler(event:FlexEvent):void - { - m_Debugger = new DebuggerViewLogic(this, this.loaderInfo); - systemManager.addEventListener(KeyboardEvent.KEY_UP, shortcutListener, true); - } - - private function shortcutListener(e:KeyboardEvent):void - { - if (m_DisableKeys) return; - - switch(e.keyCode) - { - case 73: - exec("stepin"); - break; - case 79: - exec("stepover"); - break; - case 85: - exec("stepout"); - break; - case 82: - exec("run"); - break; - case 80: - exec("pause"); - break; - case 66: - exec("breakpoint"); - break; - case 71: - exec("step_current"); - break; - case 45: - exec("add"); - break; - case 46: - exec("remove"); - break; - case 87: - exec("watch"); - break; - } - - - } - - public function refreshSourceCode(s : SourceCode, l : ArrayList) : void - { - var sel:int = lstSources.selectedIndex; - - lstSources.dataProvider = l; - - if (sel >= 0) - { - lstSources.selectedIndex = sel; - lstSources_changeHandler(null); - } - else - { - lstSources.selectedIndex = 0; - lstSources_changeHandler(null); - } - } - - public function refreshInstructionPtrHighlight(switchToSource:Boolean) : void - { - var hl:Highlight = m_Debugger.getInstructionPtrHighlight(); - - if (switchToSource && hl !== null && hl.Source !== m_CurrentSrc) - { - selectSource(hl.Source); - } - - var tlf:TextLayoutFormat = new TextLayoutFormat(); - tlf.backgroundColor = 0x444444; - - txtCode.setFormatOfRange(tlf, 0, txtCode.text.length - 1); - - if (hl !== null && hl.Source === m_CurrentSrc) - { - var tlf2:TextLayoutFormat = new TextLayoutFormat(); - tlf2.backgroundColor = 0x645ef5; - - txtCode.setFormatOfRange(tlf2, hl.From, hl.To); - moveCaret(hl.To); - } - } - - public function refreshBreakpoints() : void - { - if (m_CurrentSrc == null) return; - - var tlf:TextLayoutFormat = new TextLayoutFormat(); - tlf.color = 0xEEEEEE; - - txtCode.setFormatOfRange(tlf, 0, txtCode.text.length - 1); - - var tlf2:TextLayoutFormat = new TextLayoutFormat(); - tlf2.color = 0xff0000; - - for(var i:int = 0; i < m_CurrentSrc.Breakpoints.length; i++) - { - var hl:Highlight = m_CurrentSrc.Breakpoints[i]; - txtCode.setFormatOfRange(tlf2, hl.From, hl.To); - } - } - - private var m_CurrentSrc:SourceCode = null; - - public function refreshCallStack(l : ArrayList):void - { - gridStack.dataProvider = l; - } - - public function refreshWatches(l : ArrayList):void - { - gridWatches.dataProvider = l; - } - - private function selectSource(S : SourceCode) : void - { - lstSources.selectedItem = S; - lstSources_changeHandler(null); - } - - protected function lstSources_changeHandler(event:IndexChangeEvent):void - { - var S : SourceCode = (SourceCode)(lstSources.selectedItem); - txtCode.text = S.getText(); - m_CurrentSrc = S; - refreshInstructionPtrHighlight(false); - refreshBreakpoints(); - updateCaretLabel(); - } - - protected function getSourceName(o : Object) : String - { - var S : SourceCode = o as SourceCode; - return S.getId() + " : " + S.getName(); - } - - public function welcome(appName : String, ver : String): void - { - titleBar.text = "MoonSharp Remote Debugger - [" + appName + "] - v" + ver; - } - - public function appendMessage(text : String) : void - { - textOutput.text += text + "\n"; - textOutput.scrollToRange(int.MAX_VALUE, int.MAX_VALUE); - } - - protected function txtCode_changingHandler(event:TextOperationEvent):void - { - event.preventDefault(); - } - - protected function toggleBreakpoint(cmdType:String) : void - { - if (m_CurrentSrc == null) return; - - var cursor:int = txtCode.selectionActivePosition; - var line:int = m_CurrentSrc.inflateLocationLine(cursor); - var col:int = m_CurrentSrc.inflateLocationColumn(cursor, line); - - m_Debugger.toggleBreakpoint(m_CurrentSrc.getId(), line, col, cmdType); - } - - protected function moveCaret(where : int) : void - { - txtCode.setFocus(); - txtCode.selectRange(where, where); - txtCode.scrollToRange(where, where); - updateCaretLabel(); - } - - protected function updateCaretLabel() : void - { - if (m_CurrentSrc == null) return; - - var cursor:int = txtCode.selectionActivePosition; - var line:int = m_CurrentSrc.inflateLocationLine(cursor); - var col:int = m_CurrentSrc.inflateLocationColumn(cursor, line); - - txtCaret.text = m_CurrentSrc.getName() + ":" + line.toString() + ","+col.toString(); - } - - - public function exec(cmd:String) : void - { - var wi:WatchItem; - - if (cmd == "about") AboutBox.show(this); - else if (cmd == "stepin") m_Debugger.stepIn(); - else if (cmd == "stepout") m_Debugger.stepOut(); - else if (cmd == "stepover") m_Debugger.stepOver(); - else if (cmd == "run") m_Debugger.run(); - else if (cmd == "pause") m_Debugger.pause(); - else if (cmd == "step_current") refreshInstructionPtrHighlight(true); - else if (cmd == "breakpoint") toggleBreakpoint("toggle"); - else if (cmd == "set_breakpoint") toggleBreakpoint("set"); - else if (cmd == "clear_breakpoint") toggleBreakpoint("clear"); - else if (cmd == "error_rx") - { - m_DisableKeys = true; - - InputBox.show(this, "Error RegEx", - "Insert a regular expression which matches error messages you want to stop on.", m_Debugger.getErrorRx(), - - function(str:String):void - { - m_DisableKeys = false; - - if (str !== null && str !== "") - m_Debugger.setErrorRx(str); - }); - } - else if (cmd == "add") - { - m_DisableKeys = true; - - InputBox.show(this, "Add watch...", "Enter the name of the variables you want to watch, separated by ',' if more than one is desired", "", function(str:String):void - { - m_DisableKeys = false; - - if (str !== null && str !== "") - m_Debugger.addWatch(str); - }); - } - else if (cmd == "remove") - { - var str:String = ""; - - for each(wi in gridWatches.selectedItems) - { - if (str.length > 0) - str += ","; - - str += wi.Name; - } - - if (str.length > 0) - m_Debugger.removeWatch(str); - } - else if (cmd == "watch") - { - wi = gridWatches.selectedItem as WatchItem; - - if (wi != null) - { - Alert.show("Value = " + wi.Value + "\n" + - "Type = " + wi.Type + "\n" + - "Scope = " + wi.LValue, wi.Name); - } - } - else - { - Alert.show("Unknown command " + cmd, "Error", Alert.OK, this); - } - } - - - - - - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/Resource.as b/src/Flash/org.moonsharp.debugger.client/src/Resource.as deleted file mode 100644 index df153d9a..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/Resource.as +++ /dev/null @@ -1,11 +0,0 @@ -package -{ - public final class Resource - { - public function Resource() - { - } - - - } -} \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/SourceCode.as b/src/Flash/org.moonsharp.debugger.client/src/SourceCode.as deleted file mode 100644 index d328c743..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/SourceCode.as +++ /dev/null @@ -1,83 +0,0 @@ -package -{ - public class SourceCode - { - private var m_Id : int; - private var m_Name : String; - private var m_Lines : Number; - private var m_Text : String; - private var m_CumulativeLength : Vector. = new Vector.(); - - public var Breakpoints : Vector. = new Vector.(); - - public function SourceCode(xml: XML) - { - m_Id = xml.@id; - m_Name = xml.@name.toString(); - - var lines : XMLList = xml.elements(); - - m_Text = ""; - - for each (var line : XML in lines) - { - m_CumulativeLength.push(m_Text.length); - m_Text += line.toString() + "\n"; - m_Lines += 1; - } - } - - public function getId() : int - { - return m_Id; - } - - public function getName() : String - { - return m_Name; - } - - public function getText() : String - { - return m_Text; - } - - public function flattenLocation(line: int, col: int) : int - { - return m_CumulativeLength[line] + col; - } - - - public function inflateLocationLine(pos : int) : int - { - for(var line:int = 0; line < m_CumulativeLength.length; line++) - { - if (pos < m_CumulativeLength[line]) - return line - 1; - } - - return m_CumulativeLength.length - 1; - } - - public function inflateLocationColumn(pos : int, line : int) : int - { - if (line <= 0) return pos; - return pos - m_CumulativeLength[line]; - } - - } -} - - - - - - - - - - - - - - diff --git a/src/Flash/org.moonsharp.debugger.client/src/Version.as b/src/Flash/org.moonsharp.debugger.client/src/Version.as deleted file mode 100644 index 9ba55302..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/Version.as +++ /dev/null @@ -1,12 +0,0 @@ -package -{ - public final class Version - { - public static var Version : String = "0.8.0.0"; - - - public function Version() - { - } - } -} \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/WatchItem.as b/src/Flash/org.moonsharp.debugger.client/src/WatchItem.as deleted file mode 100644 index 1028ca33..00000000 --- a/src/Flash/org.moonsharp.debugger.client/src/WatchItem.as +++ /dev/null @@ -1,34 +0,0 @@ -package -{ - public final class WatchItem - { - [Bindable] - public var Name : String; - [Bindable] - public var Value : String; - [Bindable] - public var Type : String; - [Bindable] - public var Address : String; - [Bindable] - public var BasePtr : String; - [Bindable] - public var RetAddress : String; - [Bindable] - public var LValue : String; - - - public function WatchItem(xml :XML) - { - Name = xml.@name; - Value = xml.@value; - Type = xml.@type; - Address = xml.@address; - BasePtr = xml.@baseptr; - RetAddress = xml.@retaddress; - LValue = xml.@lvalue; - } - - - } -} \ No newline at end of file diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-B.ttf b/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-B.ttf deleted file mode 100644 index c0142fea..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-B.ttf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-R.ttf b/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-R.ttf deleted file mode 100644 index 45a038ba..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/Ubuntu-R.ttf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/UbuntuMono-R.ttf b/src/Flash/org.moonsharp.debugger.client/src/assets/UbuntuMono-R.ttf deleted file mode 100644 index fdd309d7..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/UbuntuMono-R.ttf and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/add.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/add.gif deleted file mode 100644 index 252d7ebc..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/add.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/breakpoint.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/breakpoint.gif deleted file mode 100644 index f529c5a4..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/breakpoint.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/moonsharp.png b/src/Flash/org.moonsharp.debugger.client/src/assets/moonsharp.png deleted file mode 100644 index cceedb3e..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/moonsharp.png and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/pause.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/pause.gif deleted file mode 100644 index d645fa5c..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/pause.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/remove.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/remove.gif deleted file mode 100644 index b6922ac1..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/remove.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/run.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/run.gif deleted file mode 100644 index d6b3bdcc..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/run.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/step_current.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/step_current.gif deleted file mode 100644 index e3a7cc76..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/step_current.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/stepin.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/stepin.gif deleted file mode 100644 index 75d165bc..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/stepin.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/stepout.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/stepout.gif deleted file mode 100644 index 4c2f2193..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/stepout.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/stepover.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/stepover.gif deleted file mode 100644 index 1ec36ae2..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/stepover.gif and /dev/null differ diff --git a/src/Flash/org.moonsharp.debugger.client/src/assets/watch.gif b/src/Flash/org.moonsharp.debugger.client/src/assets/watch.gif deleted file mode 100644 index c55cb584..00000000 Binary files a/src/Flash/org.moonsharp.debugger.client/src/assets/watch.gif and /dev/null differ diff --git a/src/Flash/readme.md b/src/Flash/readme.md deleted file mode 100644 index 5cefbb93..00000000 --- a/src/Flash/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Flash -This folder contains all things around MoonSharp done in Flash/Flex.. which basically means the remote debugger. - -There's no intention of doing anything else in Flash, and actually it would be good if the debugger could be ported to HTML5, one day. diff --git a/src/MoonSharp.Documentation/Content/VersionHistory/VersionHistory.aml b/src/MoonSharp.Documentation/Content/VersionHistory/VersionHistory.aml deleted file mode 100644 index a4f2fc8f..00000000 --- a/src/MoonSharp.Documentation/Content/VersionHistory/VersionHistory.aml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - The topics in this section describe the various changes made to the [TODO: Project Title] over the -life of the project. - - -
- Version History - - Select a version below to see a description of its changes. - - - - - - - - [TODO: Add links to each specific version page] - - - - - -
- - - - - -
-
diff --git a/src/MoonSharp.Documentation/Content/VersionHistory/v1.0.0.0.aml b/src/MoonSharp.Documentation/Content/VersionHistory/v1.0.0.0.aml deleted file mode 100644 index aa75ff17..00000000 --- a/src/MoonSharp.Documentation/Content/VersionHistory/v1.0.0.0.aml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Version [TODO: Version] was released on [TODO: Date]. - - - -
- Changes in This Release - - - - - [TODO: Add change items here] - - - - - -
- - - - - -
-
diff --git a/src/MoonSharp.Documentation/Content/Walkthrough.aml b/src/MoonSharp.Documentation/Content/Walkthrough.aml deleted file mode 100644 index 40ae2e3e..00000000 --- a/src/MoonSharp.Documentation/Content/Walkthrough.aml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - Required introduction - - - - - - - Procedure title - - - - First step - - - - - Second step - - - - - - - -
- Optional section title - - - Procedure #2 - - - - First step - - - - - Second step - - - - - - -
- - - - - - -
-
diff --git a/src/MoonSharp.Documentation/Content/Welcome.aml b/src/MoonSharp.Documentation/Content/Welcome.aml deleted file mode 100644 index ec88b074..00000000 --- a/src/MoonSharp.Documentation/Content/Welcome.aml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - This is the API reference for the MoonSharp.Interpreter assembly. - To get started, please visit - the MoonSharp homepage - MoonSharp homepage - http://www.moonsharp.org - . - - - diff --git a/src/MoonSharp.Documentation/ContentLayout.content b/src/MoonSharp.Documentation/ContentLayout.content deleted file mode 100644 index 713cbd98..00000000 --- a/src/MoonSharp.Documentation/ContentLayout.content +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/MoonSharp.Documentation/MoonSharp.Documentation.shfbproj b/src/MoonSharp.Documentation/MoonSharp.Documentation.shfbproj deleted file mode 100644 index 74bbce11..00000000 --- a/src/MoonSharp.Documentation/MoonSharp.Documentation.shfbproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - 26b3033c-d1e2-4188-870c-d197e95a7f6b - 2015.6.5.0 - - MoonSharp.Documentation - MoonSharp.Documentation - MoonSharp.Documentation - - .NET Framework 4.5 - .\Help\ - MoonSharp.Reference.Documentation - en-US - - - - - - - - - - OnlyErrors - HtmlHelp1 - False - True - False - False - True - - - - - 2 - False - Standard - Blank - False - VS2013 - False - MemberName - MoonSharp Reference Guide - AboveNamespaces - info%40moonsharp.org - info%40moonsharp.org - Summary, Parameter, AutoDocumentCtors, Namespace, TypeParameter, AutoDocumentDispose - - - - - - - - - - - - - - - - - - - - bin\Dev\ - - - bin\Devp4\ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Documentation/icons/Help.png b/src/MoonSharp.Documentation/icons/Help.png deleted file mode 100644 index 945e89fb..00000000 Binary files a/src/MoonSharp.Documentation/icons/Help.png and /dev/null differ diff --git a/src/MoonSharp.Hardwire/Generators/ArrayMemberDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/ArrayMemberDescriptorGenerator.cs index 4dc01a8b..5556a3cd 100644 --- a/src/MoonSharp.Hardwire/Generators/ArrayMemberDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/ArrayMemberDescriptorGenerator.cs @@ -18,10 +18,10 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.ArrayMemberDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members) { - string className = "AIDX_" + Guid.NewGuid().ToString("N"); string name = table.Get("name").String; + string className = "AIDX_" + IdGen.Create($"{parent ?? "null"}:array:{name}"); bool setter = table.Get("setter").Boolean; CodeTypeDeclaration classCode = new CodeTypeDeclaration(className); diff --git a/src/MoonSharp.Hardwire/Generators/Base/AssignableMemberDescriptorGeneratorBase.cs b/src/MoonSharp.Hardwire/Generators/Base/AssignableMemberDescriptorGeneratorBase.cs index 0615214a..befb34a3 100644 --- a/src/MoonSharp.Hardwire/Generators/Base/AssignableMemberDescriptorGeneratorBase.cs +++ b/src/MoonSharp.Hardwire/Generators/Base/AssignableMemberDescriptorGeneratorBase.cs @@ -19,7 +19,7 @@ abstract class AssignableMemberDescriptorGeneratorBase: IHardwireGenerator protected abstract string GetPrefix(); - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { bool isStatic = table.Get("static").Boolean; string memberType = table.Get("type").String; @@ -43,7 +43,7 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene access = access | MemberDescriptorAccess.CanRead; - string className = GetPrefix() + "_" + Guid.NewGuid().ToString("N"); + string className = GetPrefix() + "_" + IdGen.Create($"{parent ?? null}:assignable:{name}:{memberType}:{isStatic}:{decltype}:{declvtype}:{canWrite}:{canRead}"); CodeTypeDeclaration classCode = new CodeTypeDeclaration(className); diff --git a/src/MoonSharp.Hardwire/Generators/DynValueMemberDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/DynValueMemberDescriptorGenerator.cs index 4d4bef35..99d16455 100644 --- a/src/MoonSharp.Hardwire/Generators/DynValueMemberDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/DynValueMemberDescriptorGenerator.cs @@ -16,7 +16,7 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.DynValueMemberDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members) { string className = "DVAL_" + Guid.NewGuid().ToString("N"); DynValue kval = table.Get("value"); diff --git a/src/MoonSharp.Hardwire/Generators/MethodMemberDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/MethodMemberDescriptorGenerator.cs index adcf263f..c585284b 100644 --- a/src/MoonSharp.Hardwire/Generators/MethodMemberDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/MethodMemberDescriptorGenerator.cs @@ -30,7 +30,7 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.MethodMemberDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { bool isArray = table.Get("arraytype").IsNotNil(); string memberName = table.Get("name").String; @@ -42,8 +42,19 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene return null; } + // Create the parameters + List paramDescs = HardwireParameterDescriptor.LoadDescriptorsFromTable(table.Get("params").Table); + + int paramNum = paramDescs.Count; + int optionalNum = paramDescs.Where(p => p.HasDefaultValue).Count(); + // Create the descriptor class - string className = m_Prefix + "_" + Guid.NewGuid().ToString("N"); + var idstr = $"{parent}$method${table.Get("static").Boolean || table.Get("ctor").Boolean}:{memberName}"; + foreach (var p in paramDescs) + { + idstr += $"#{p.ParamType}::{p.IsOut}::{p.IsRef}"; + } + string className = m_Prefix + "_" + IdGen.Create(idstr); CodeTypeDeclaration classCode = new CodeTypeDeclaration(className); classCode.TypeAttributes = System.Reflection.TypeAttributes.NestedPrivate | System.Reflection.TypeAttributes.Sealed; @@ -54,11 +65,7 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene ctor.Attributes = MemberAttributes.Assembly; classCode.Members.Add(ctor); - // Create the parameters - List paramDescs = HardwireParameterDescriptor.LoadDescriptorsFromTable(table.Get("params").Table); - - int paramNum = paramDescs.Count; - int optionalNum = paramDescs.Where(p => p.HasDefaultValue).Count(); + // Add initialize call to ctor List initParams = new List(); diff --git a/src/MoonSharp.Hardwire/Generators/NullGenerator.cs b/src/MoonSharp.Hardwire/Generators/NullGenerator.cs index 3d878a67..07989403 100644 --- a/src/MoonSharp.Hardwire/Generators/NullGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/NullGenerator.cs @@ -25,7 +25,7 @@ public string ManagedType private set; } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { generator.Error("Missing code generator for '{0}'.", ManagedType); diff --git a/src/MoonSharp.Hardwire/Generators/OverloadedMethodMemberDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/OverloadedMethodMemberDescriptorGenerator.cs index 883e9033..d578edd2 100644 --- a/src/MoonSharp.Hardwire/Generators/OverloadedMethodMemberDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/OverloadedMethodMemberDescriptorGenerator.cs @@ -16,12 +16,12 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { List initializers = new List(); - generator.DispatchTablePairs(table.Get("overloads").Table, members, exp => + generator.DispatchTablePairs(parent, table.Get("overloads").Table, members, exp => { initializers.Add(exp); }); diff --git a/src/MoonSharp.Hardwire/Generators/StandardUserDataDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/StandardUserDataDescriptorGenerator.cs index 03df313d..af394833 100644 --- a/src/MoonSharp.Hardwire/Generators/StandardUserDataDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/StandardUserDataDescriptorGenerator.cs @@ -16,11 +16,11 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.StandardUserDataDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { string type = (string)table["$key"]; - string className = "TYPE_" + Guid.NewGuid().ToString("N"); + string className = "TYPE_" + IdGen.Create($"TYPE${type}"); CodeTypeDeclaration classCode = new CodeTypeDeclaration(className); @@ -42,7 +42,7 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene classCode.Members.Add(ctor); - generator.DispatchTablePairs(table.Get("members").Table, + generator.DispatchTablePairs(type, table.Get("members").Table, classCode.Members, (key, exp) => { var mname = new CodePrimitiveExpression(key); @@ -51,7 +51,7 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene new CodeThisReferenceExpression(), "AddMember", mname, exp)); }); - generator.DispatchTablePairs(table.Get("metamembers").Table, + generator.DispatchTablePairs(type, table.Get("metamembers").Table, classCode.Members, (key, exp) => { var mname = new CodePrimitiveExpression(key); diff --git a/src/MoonSharp.Hardwire/Generators/ValueTypeDefaultCtorMemberDescriptorGenerator.cs b/src/MoonSharp.Hardwire/Generators/ValueTypeDefaultCtorMemberDescriptorGenerator.cs index e28a5dfd..6912b952 100644 --- a/src/MoonSharp.Hardwire/Generators/ValueTypeDefaultCtorMemberDescriptorGenerator.cs +++ b/src/MoonSharp.Hardwire/Generators/ValueTypeDefaultCtorMemberDescriptorGenerator.cs @@ -16,7 +16,7 @@ public string ManagedType get { return "MoonSharp.Interpreter.Interop.ValueTypeDefaultCtorMemberDescriptor"; } } - public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) + public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members) { MethodMemberDescriptorGenerator mgen = new MethodMemberDescriptorGenerator("VTDC"); @@ -32,7 +32,7 @@ public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext gene mt["special"] = false; - return mgen.Generate(mt, generator, members); + return mgen.Generate(parent, mt, generator, members); } } } diff --git a/src/MoonSharp.Hardwire/HardwireCodeGenerationContext.cs b/src/MoonSharp.Hardwire/HardwireCodeGenerationContext.cs index ad42f548..8687cf94 100644 --- a/src/MoonSharp.Hardwire/HardwireCodeGenerationContext.cs +++ b/src/MoonSharp.Hardwire/HardwireCodeGenerationContext.cs @@ -47,7 +47,6 @@ internal HardwireCodeGenerationContext(string namespaceName, string entryClassNa CompileUnit.Namespaces.Add(m_Namespace); Comment("----------------------------------------------------------"); - Comment("Generated by MoonSharp.Hardwire v.{0}", Assembly.GetExecutingAssembly().GetName().Version); Comment("Compatible with MoonSharp v.{0} or equivalent", Script.VERSION); Comment("----------------------------------------------------------"); @@ -61,16 +60,8 @@ internal HardwireCodeGenerationContext(string namespaceName, string entryClassNa Comment("----------------------------------------------------------"); } - Comment("Code generated on {0}", DateTime.Now.ToString("O")); Comment("----------------------------------------------------------"); - - - - Comment(""); - Comment(""); - Comment(""); - GenerateKickstarter(entryClassName); } @@ -82,7 +73,7 @@ internal void GenerateCode(Table table) { try { - DispatchTablePairs(table, m_KickstarterClass.Members, + DispatchTablePairs(null, table, m_KickstarterClass.Members, exp => m_InitStatements.Add(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(UserData)), "RegisterType", exp))); } catch (Exception ex) @@ -94,12 +85,13 @@ internal void GenerateCode(Table table) /// /// Used by generators to dispatch a table of types /// + /// Parent name (can be null) /// The table. /// The members. /// The action to be performed, or null. - public void DispatchTablePairs(Table table, CodeTypeMemberCollection members, Action action = null) + public void DispatchTablePairs(string parent, Table table, CodeTypeMemberCollection members, Action action = null) { - foreach (var pair in table.Pairs) + foreach (var pair in table.Pairs.OrderBy(x => x.Key.ToString(), StringComparer.Ordinal)) { var key = pair.Key; var value = pair.Value; @@ -122,7 +114,7 @@ public void DispatchTablePairs(Table table, CodeTypeMemberCollection members, Ac continue; } - var exp = DispatchTable(key.String, value.Table, members); + var exp = DispatchTable(parent, key.String, value.Table, members); if (action != null && exp != null) foreach (var e in exp) @@ -153,9 +145,9 @@ public string GetStackTrace() /// The table. /// The members. /// The action to be performed, or null. - public void DispatchTablePairs(Table table, CodeTypeMemberCollection members, Action action) + public void DispatchTablePairs(string parent, Table table, CodeTypeMemberCollection members, Action action) { - DispatchTablePairs(table, members, (_, e) => action(e)); + DispatchTablePairs(parent, table, members, (_, e) => action(e)); } @@ -167,7 +159,7 @@ public void DispatchTablePairs(Table table, CodeTypeMemberCollection members, Ac /// The members. /// /// table cannot be dispatched as it has no class or class of invalid type. - public CodeExpression[] DispatchTable(string key, Table table, CodeTypeMemberCollection members) + public CodeExpression[] DispatchTable(string parent, string key, Table table, CodeTypeMemberCollection members) { DynValue d = table.Get("class"); if (d.Type != DataType.String) @@ -180,7 +172,7 @@ public CodeExpression[] DispatchTable(string key, Table table, CodeTypeMemberCol table.Set("$key", DynValue.NewString(key)); var gen = HardwireGeneratorRegistry.GetGenerator(d.String); - var result = gen.Generate(table, this, members); + var result = gen.Generate(parent, table, this, members); m_NestStack.Pop(); diff --git a/src/MoonSharp.Hardwire/IHardwireGenerator.cs b/src/MoonSharp.Hardwire/IHardwireGenerator.cs index 4bb2db86..4ba0d282 100644 --- a/src/MoonSharp.Hardwire/IHardwireGenerator.cs +++ b/src/MoonSharp.Hardwire/IHardwireGenerator.cs @@ -24,7 +24,7 @@ public interface IHardwireGenerator /// The generator context. /// The CodeTypeMemberCollection which can be used to add newly defined types. /// Zero or more expressions which can be used by the parent generator to use the generated code. - CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members); + CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members); } } diff --git a/src/MoonSharp.Hardwire/IdGen.cs b/src/MoonSharp.Hardwire/IdGen.cs new file mode 100644 index 00000000..64d7e691 --- /dev/null +++ b/src/MoonSharp.Hardwire/IdGen.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Numerics; +using System.Text; +using System.Security.Cryptography; + +namespace MoonSharp.Hardwire +{ + static class IdGen + { + private const string ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"; + public static string Create(string str) + { + using (MD5 md5Hash = MD5.Create()) + { + var bLen = BitConverter.GetBytes((ushort) str.Length); + byte[] bytes = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(str)); + return Encode(new BigInteger(bLen.Concat(bytes).Append((byte)0).ToArray())); + } + } + static string Encode(BigInteger number) + { + if(number < 0) + throw new ArgumentException(); + var builder = new StringBuilder(); + var divisor = new BigInteger(ALPHABET.Length); + while (number > 0) + { + number = BigInteger.DivRem(number, divisor, out var rem); + builder.Append(ALPHABET[(int) rem]); + } + return new string(builder.ToString().Reverse().ToArray()); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Hardwire/MoonSharp.Hardwire.csproj b/src/MoonSharp.Hardwire/MoonSharp.Hardwire.csproj new file mode 100644 index 00000000..e289e07c --- /dev/null +++ b/src/MoonSharp.Hardwire/MoonSharp.Hardwire.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0 + + + + + + + + + diff --git a/src/MoonSharp.Hardwire/MoonSharp.Hardwire.net35-client.csproj b/src/MoonSharp.Hardwire/MoonSharp.Hardwire.net35-client.csproj deleted file mode 100644 index 3c2247b7..00000000 --- a/src/MoonSharp.Hardwire/MoonSharp.Hardwire.net35-client.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Debug - AnyCPU - {B25A2316-6897-4CAA-BE0E-E784071D8199} - Library - Properties - MoonSharp.Hardwire - MoonSharp.Hardwire - v3.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - - - keypair.snk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Hardwire/Properties/AssemblyInfo.cs b/src/MoonSharp.Hardwire/Properties/AssemblyInfo.cs deleted file mode 100644 index 8462329d..00000000 --- a/src/MoonSharp.Hardwire/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Hardwire")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Hardwire")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("67210a72-3276-46db-b263-96e3197b1f78")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Hardwire/keypair.snk b/src/MoonSharp.Hardwire/keypair.snk deleted file mode 100644 index 13c53af5..00000000 Binary files a/src/MoonSharp.Hardwire/keypair.snk and /dev/null differ diff --git a/src/MoonSharp.HardwireGen/ExtraClassList.cs b/src/MoonSharp.HardwireGen/ExtraClassList.cs new file mode 100644 index 00000000..cf873dca --- /dev/null +++ b/src/MoonSharp.HardwireGen/ExtraClassList.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Xml.Serialization; + +namespace MoonSharp.HardwireGen +{ + [XmlRoot("MoonSharp")] + public class ExtraClassList + { + [XmlElement] + public string[] ExtraType; + [XmlElement] + public string[] BlacklistType; + private static XmlSerializer cl = new XmlSerializer(typeof(ExtraClassList)); + public static ExtraClassList Get(string file) + { + string text; + if ((text = ReadAllText(file)) != null) + { + try + { + return (ExtraClassList) cl.Deserialize(new StringReader(text)); + } + catch (Exception) + { + return null; + } + } + return null; + } + + static string ReadAllText(string file) + { + try + { + using (var reader = new StreamReader(file)) + { + char[] buffer = new char[256]; + var c = reader.ReadBlock(buffer, 0, buffer.Length); + if (c == -1) return null; + var str = new string(buffer, 0, c); + if (str.TrimStart().StartsWith("<")) + { + return str + reader.ReadToEnd(); + } + } + return null; + } + catch (Exception) + { + return null; + } + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/IdGen.cs b/src/MoonSharp.HardwireGen/IdGen.cs new file mode 100644 index 00000000..823a0c5a --- /dev/null +++ b/src/MoonSharp.HardwireGen/IdGen.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Numerics; +using System.Text; +using System.Security.Cryptography; + +namespace MoonSharp.HardwireGen +{ + static class IdGen + { + private const string ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"; + public static string Create(string str) + { + using (MD5 md5Hash = MD5.Create()) + { + var bLen = BitConverter.GetBytes((ushort) str.Length); + byte[] bytes = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(str)); + return Encode(new BigInteger(bLen.Concat(bytes).Append((byte)0).ToArray())); + } + } + static string Encode(BigInteger number) + { + if(number < 0) + throw new ArgumentException(); + var builder = new StringBuilder(); + var divisor = new BigInteger(ALPHABET.Length); + while (number > 0) + { + number = BigInteger.DivRem(number, divisor, out var rem); + builder.Append(ALPHABET[(int) rem]); + } + return new string(builder.ToString().Reverse().ToArray()); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/MoonSharp.HardwireGen.csproj b/src/MoonSharp.HardwireGen/MoonSharp.HardwireGen.csproj new file mode 100644 index 00000000..a5987d27 --- /dev/null +++ b/src/MoonSharp.HardwireGen/MoonSharp.HardwireGen.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + 9 + + + + + + diff --git a/src/MoonSharp.HardwireGen/SourceGenerator.ClassNames.cs b/src/MoonSharp.HardwireGen/SourceGenerator.ClassNames.cs new file mode 100644 index 00000000..001b6d8c --- /dev/null +++ b/src/MoonSharp.HardwireGen/SourceGenerator.ClassNames.cs @@ -0,0 +1,23 @@ +namespace MoonSharp.HardwireGen +{ + public partial class HardwireSourceGenerator + { + private const string CLS_USERDATA = + "MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor"; + + private const string CLS_OVERLOAD = "MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor"; + + private const string CLS_OVERLOAD_MEMBER = + "MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor"; + + private const string CLS_PROP_FIELD = + "MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor"; + + private const string CLS_METHOD = + "MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor"; + + private const string CLS_PARAMETER = "MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor"; + + + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/SourceGenerator.cs b/src/MoonSharp.HardwireGen/SourceGenerator.cs new file mode 100644 index 00000000..8cf6a55e --- /dev/null +++ b/src/MoonSharp.HardwireGen/SourceGenerator.cs @@ -0,0 +1,657 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MoonSharp.HardwireGen +{ + [Generator] + public partial class HardwireSourceGenerator : ISourceGenerator + { + private static DiagnosticDescriptor ByRefWarning = new("MS1001", + "ByRef parameters can't be generated", + "Method '{0}' has ref/out parameters and won't be described, mark with MoonSharpHiddenAttribute.", + "MoonSharp.HardwireGen", DiagnosticSeverity.Warning, true); + + private static DiagnosticDescriptor NoFilesWarning = new("MS1002", + "AdditionalFiles has no types listed", + "File '{0}' has no additional types listed.", + "MoonSharp.HardwireGen", DiagnosticSeverity.Warning, true); + + private static DiagnosticDescriptor TypeResolveWarning = new("MS1003", + "Type could not be resolved", + "Type '{0}' from AdditionalFile '{1}' could not be resolved.", + "MoonSharp.HardwireGen", DiagnosticSeverity.Warning, true); + + private static DiagnosticDescriptor Timing = new("MS9999", "Generation duration", + "Hardwire generation took '{0}'ms", "MoonSharp.HardwireGen", DiagnosticSeverity.Info, true); + + public void Initialize(GeneratorInitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new UserDataSyntaxReceiver()); + } + + static string Sanitize(string t) + { + return t.Replace(".", "_").Replace(",", "__").Replace("<", "___").Replace(">", "___"); + } + + + private static string[] SkipTypes = + { + "System.Object", "System.Type" + }; + + TypeGenQueue types = new TypeGenQueue(); + private List generatedClasses = new List(); + private HashSet blacklist = new HashSet(); + + static IEnumerable GenericParts(string input) + { + var s = ""; + int bC = 0; + for (int i = 0; i < input.Length; i++) + { + if (input[i] == '<') + bC++; + if (input[i] == '>') + bC--; + if (bC == 0 && input[i] == ',') + { + yield return s; + s = ""; + } + else + { + s += input[i]; + } + } + + if (s != "") + yield return s; + } + + static ITypeSymbol GetTypeFromName(ref GeneratorExecutionContext context, string type) + { + if (string.IsNullOrWhiteSpace(type)) return null; + if (type.Contains("<")) + { + var startIndex = type.IndexOf('<') + 1; + var endIndex = type.LastIndexOf('>'); + if (endIndex == -1) return null; + var generics = type.Substring(startIndex, endIndex - startIndex); + var parts = GenericParts(generics).ToArray(); + var baseName = type.Substring(0, startIndex - 1) + "`" + parts.Length; + INamedTypeSymbol ts = context.Compilation.GetTypeByMetadataName(baseName); + if (ts == null) return null; + ITypeSymbol[] parameters = new ITypeSymbol[parts.Length]; + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = GetTypeFromName(ref context, parts[i]); + if (parameters[i] == null) return null; + } + + return ts.Construct(parameters); + } + else + { + return context.Compilation.GetTypeByMetadataName(type); + } + } + + void ProcessAdditionalFile(ref GeneratorExecutionContext context, AdditionalText file) + { + ExtraClassList ec; + if ((ec = ExtraClassList.Get(file.Path)) != null) + { + if (ec.ExtraType != null && ec.ExtraType.Length > 0) + { + foreach (var t in ec.ExtraType) + { + var x = t.Trim(); + var ts = GetTypeFromName(ref context, x); + if (ts == null) + { + context.ReportDiagnostic(Diagnostic.Create(TypeResolveWarning, null, x, file.Path)); + } + else + { + types.Enqueue(ts); + } + } + } + else + { + context.ReportDiagnostic(Diagnostic.Create(NoFilesWarning, null, file.Path)); + } + + if (ec.BlacklistType != null && ec.BlacklistType.Length > 0) + { + foreach (var t in ec.BlacklistType) + { + var x = t.Trim(); + var ts = GetTypeFromName(ref context, x); + if (ts == null) + { + context.ReportDiagnostic(Diagnostic.Create(TypeResolveWarning, null, x, file.Path)); + } + else + { + blacklist.Add(ts.TypeName()); + } + } + } + } + } + + public void Execute(GeneratorExecutionContext context) + { + var sw = Stopwatch.StartNew(); + try + { + var receiver = (UserDataSyntaxReceiver) context.SyntaxReceiver; + var name = context.Compilation.Assembly.Name; + if (string.IsNullOrEmpty(name)) + name = IdGen.Create(context.Compilation.Assembly.NamespaceNames.FirstOrDefault() ?? + "_MoonSharp"); + name = "LuaHardwire_" + Sanitize(name); + + foreach (var classDeclaration in receiver.Candidates) + { + var model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree, true); + var type = ModelExtensions.GetDeclaredSymbol(model, classDeclaration) as ITypeSymbol; + if (type is null || !IsUserData(type)) + continue; + types.Enqueue(type); + } + + foreach (var file in context.AdditionalFiles) + { + ProcessAdditionalFile(ref context, file); + } + + while (types.Count > 0) + { + TryGenerate(ref context, name, types.Dequeue()); + } + + var writer = new TabbedWriter(); + writer.AppendLine("// "); + writer.Append("partial class ").AppendLine(name); + writer.AppendLine("{").Indent(); + writer.AppendLine("public static void Initialize()"); + writer.AppendLine("{").Indent(); + foreach (var str in generatedClasses) + { + writer.Append("MoonSharp.Interpreter.UserData.RegisterType(new ").Append(str).AppendLine("());"); + } + + writer.UnIndent().AppendLine("}"); + writer.UnIndent().AppendLine("}"); + context.AddSource($"{name}.g.cs", writer.ToString()); + sw.Stop(); + context.ReportDiagnostic(Diagnostic.Create(Timing, null, sw.Elapsed.TotalMilliseconds)); + } + catch (Exception e) + { + sw.Stop(); + throw new Exception(e.Message + "> " + e.StackTrace.Replace('\n', ';')); + } + } + + static bool IsUserData(ITypeSymbol type) + { + return type.GetAttributes() + .Any(a => a.AttributeClass?.ToString() == "MoonSharp.Interpreter.MoonSharpUserDataAttribute"); + } + + static bool IsHidden(ISymbol symbol) + { + foreach (var attr in symbol.GetAttributes()) + { + if (attr.AttributeClass?.ToString() == "MoonSharp.Interpreter.MoonSharpHiddenAttribute") + return true; + if (attr.AttributeClass?.ToString() == "MoonSharp.Interpreter.MoonSharpVisibleAttribute") + { + if (attr.ConstructorArguments[0].Value is false) + return true; + } + } + + return false; + } + + static string TypeName(ITypeSymbol type) + { + return type.ToDisplayString(new SymbolDisplayFormat( + SymbolDisplayGlobalNamespaceStyle.Omitted, + SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, + SymbolDisplayGenericsOptions.IncludeTypeParameters, + miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable + )); + } + + + void TryGenerate(ref GeneratorExecutionContext context, string containingName, ITypeSymbol type) + { + //skip blacklisted + if (blacklist.Any(x => x == type.TypeName())) return; + if (SkipTypes.Any(x => x == type.ToString())) return; + //gen + GenerateCode(ref context, containingName, type); + } + + static bool IsUnsupported(ITypeSymbol type) + { + if (type.IsRefLikeType || type.TypeKind == TypeKind.Pointer || + type.TypeKind == TypeKind.FunctionPointer) return true; + return false; + } + + void GenerateCode(ref GeneratorExecutionContext context, string containingName, ITypeSymbol type) + { + var builder = new TabbedWriter(); + var typeName = TypeName(type); + string classname = "T_" + IdGen.Create(typeName); + generatedClasses.Add(classname); + Dictionary methods = new Dictionary(); + Dictionary fields = new Dictionary(); + builder.AppendLine("// "); + builder.Append("// UserData description for: ").AppendLine(typeName); + + builder.Append("internal partial class ").Append(containingName).AppendLine().AppendLine("{").Indent(); + + builder.Append("public sealed class ").Append(classname).Append(" : ").AppendLine(CLS_USERDATA); + builder.AppendLine("{").Indent(); + + foreach (var m in type.GetPublicMembers()) + { + if (IsHidden(m.symbol)) + { + builder.AppendLine("//Hidden Symbol: " + m.symbol.ToDisplayString()); + continue; + } + + if (m.symbol.IsStatic) continue; + if (m.symbol is IMethodSymbol method) + { + if (method.MethodKind == MethodKind.Ordinary || + (method.MethodKind == MethodKind.Constructor && m.level == 0)) + { + if (method.IsGenericMethod) continue; + bool byref = method.ReturnsByRef || method.ReturnsByRefReadonly; + foreach (var p in method.Parameters) + { + if (p.RefKind == RefKind.Ref || p.RefKind == RefKind.Out || + p.RefKind == RefKind.RefReadOnly) + { + byref = true; + break; + } + } + + bool unsupportedTypes = false; + foreach (var p in method.Parameters) + { + if (IsUnsupported(p.Type)) + { + unsupportedTypes = true; + break; + } + } + + if (unsupportedTypes) continue; + if (byref) + { + if (m.level == 0) + context.ReportDiagnostic(Diagnostic.Create(ByRefWarning, + method.Locations.FirstOrDefault(), method.ToString())); + continue; + } + + if (method.MethodKind == MethodKind.Constructor) + { + if (!methods.ContainsKey("__new")) + methods.Add("__new", new TypeMethod() {Constructor = true}); + methods["__new"].AddMethod(0, method); + } + else + { + if (!methods.ContainsKey(method.Name)) methods.Add(method.Name, new TypeMethod()); + methods[method.Name].AddMethod(m.level, method); + } + } + } + + if (m.symbol is IPropertySymbol property) + { + if (IsUnsupported(property.Type)) continue; + if (property.RefKind == RefKind.Ref) + { + continue; + } + + if (property.IsIndexer) + { + continue; //name is this[] + } + + TypeFieldDesc desc = new TypeFieldDesc() {Type = property.Type}; + if (property.GetMethod != null) + { + desc.Read = true; + var name = "get_" + property.Name; + if (!methods.ContainsKey(name)) + methods.Add(name, new TypeMethod() + { + Property = true, + PropertyName = property.Name + }); + methods[name].SetName(name); + methods[name].AddMethod(m.level, property.GetMethod); + } + if (property.SetMethod != null) + { + desc.Write = true; + var name = "set_" + property.Name; + if (!methods.ContainsKey(name)) + methods.Add(name, new TypeMethod() + { + Property = true, + PropertyName = property.Name, + }); + methods[name].SetName(name); + methods[name].AddMethod(m.level, property.SetMethod); + } + if (!fields.ContainsKey(property.Name)) + fields.Add(property.Name, new TypeField() {Name = property.Name}); + fields[property.Name].Set(m.level, desc); + } + + if (m.symbol is IFieldSymbol field) + { + if (IsUnsupported(field.Type)) continue; + TypeFieldDesc desc = new TypeFieldDesc() {Type = field.Type}; + desc.Read = true; + desc.Write = !field.IsReadOnly; + if (!fields.ContainsKey(field.Name)) fields.Add(field.Name, new TypeField() {Name = field.Name}); + fields[field.Name].Set(m.level, desc); + } + } + + foreach (var m in methods.Values) + { + GenerateMethod(builder, typeName, m); + } + foreach(var f in fields.Values) + { + GenerateField(builder, typeName, f); + } + + //Constructor + builder.Append("internal ").Append(classname).Append("() : base(typeof(").Append(typeName).AppendLine("))"); + builder.AppendLine("{").Indent(); + foreach (var kv in methods) + { + builder.Append("this.AddMember("); + builder.Append(kv.Key.ToLiteral()); + //new OverloadedMethodMemberDescriptor(name, typeof(type), new IOverloadableMemberDescriptor[] { classes }); + builder.Append(", new ").Append(CLS_OVERLOAD).Append(" (").Append(kv.Key.ToLiteral()) + .Append(", typeof(").Append(typeName).Append("), new ").Append(CLS_OVERLOAD_MEMBER) + .AppendLine("[] { "); + builder.Indent(); + for (int i = 0; i < kv.Value.Overloads.Count; i++) + { + builder.Append("new ").Append(kv.Value.ClassName(i)).Append("()"); + if (i + 1 < kv.Value.Overloads.Count) + builder.AppendLine(","); + else + builder.AppendLine(); + } + + builder.UnIndent(); + builder.AppendLine("}));"); + } + foreach(var kv in fields) + { + builder.Append("this.AddMember("); + builder.Append(kv.Key.ToLiteral()); + builder.Append(", "); + builder.Append("new ").Append(kv.Value.ClassName()).AppendLine("());"); + } + + builder.UnIndent().AppendLine("}"); + builder.UnIndent().AppendLine("}"); + builder.UnIndent().AppendLine("}"); + context.AddSource($"{classname}.g.cs", builder.ToString()); + } + + void GenerateField(TabbedWriter builder, string typeName, TypeField f) + { + builder.Append("private sealed class ").Append(f.ClassName()).Append(" : ").AppendLine(CLS_PROP_FIELD); + builder.AppendLine("{").Indent(); + builder.Append("internal ").Append(f.ClassName()).AppendLine("() :"); + var access = 0; + if (f.Desc.Read) access += 1; //CanRead + if (f.Desc.Write) access += 2; //CanWrite + builder.Indent().Append("base(typeof(").Append(f.Desc.Type.TypeName()).Append("),") + .Append(f.Name.ToLiteral()).Append(",false,") + .Append("(MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)") + .Append(access.ToString()).AppendLine(")").UnIndent(); + builder.AppendLine("{"); + builder.AppendLine("}"); + if (f.Desc.Read) + { + builder.AppendLine( + "protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) {") + .Indent(); + builder.Append("var self = (").Append(typeName).AppendLine(")obj;"); + builder.Append("return (object)self.").Append(f.Name).AppendLine(";"); + builder.UnIndent().AppendLine("}"); + } + if (f.Desc.Write) + { + builder.AppendLine( + "protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) {") + .Indent(); + builder.Append("var self = (").Append(typeName).AppendLine(")obj;"); + builder.Append("self.").Append(f.Name).Append(" = (").Append(f.Desc.Type.TypeName()).AppendLine(")value;"); + builder.UnIndent().AppendLine("}"); + } + builder.UnIndent().AppendLine("}"); + } + void GenerateMethod(TabbedWriter builder, string typeName, TypeMethod m) + { + for (int i = 0; i < m.Overloads.Count; i++) + { + var method = m.Overloads[i]; + builder.Append("private sealed class ").Append(m.ClassName(i)).Append(" : ").AppendLine(CLS_METHOD); + builder.AppendLine("{").Indent(); + //ctor, add descriptors + builder.Append("internal ").Append(m.ClassName(i)).Append("()"); + builder.AppendLine("{").Indent(); + //funcName, isStatic, ParameterDescriptor[], isExtensionMethod + string isStatic = m.Constructor ? "true" : "false"; + builder.Append("this.Initialize(").Append(m.Name.ToLiteral()).Append($", {isStatic}, new ") + .Append(CLS_PARAMETER).AppendLine("[] {"); + builder.Indent(); + int j = 0; + foreach (var p in method.Parameters) + { + j++; + builder.Append("new ").Append(CLS_PARAMETER).Append("("); + builder.Append(p.Name.ToLiteral()).Append(", "); + builder.Append("typeof(").Append(TypeName(p.Type)).Append("), "); + builder.Append("false, "); //hasDefault + builder.Append("null, "); //default + builder.Append("false, "); //out + builder.Append("false, "); //ref + if (p.IsParams) builder.Append("true"); + else builder.Append("false"); + if (j < method.Parameters.Length) builder.AppendLine("),"); + else builder.AppendLine(")"); + } + + builder.UnIndent().AppendLine("}, false);"); + builder.UnIndent().AppendLine("}"); + //invoke + builder.AppendLine( + "protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount)"); + builder.AppendLine("{").Indent(); + if (!m.Constructor) + builder.Append("var self = (").Append(typeName).AppendLine(")obj;"); + if (!method.ReturnsVoid && !m.Constructor) + { + builder.Append("return (object)"); + } + + if (!m.Constructor) + { + builder.Append("self."); + builder.Append(m.PropertyName ?? method.Name); + } + else + { + builder.Append("return new "); + builder.Append(typeName); + } + + if (!m.Property) + { + builder.Append("("); + for (int k = 0; k < method.Parameters.Length; k++) + { + builder.Append("(").Append(TypeName(method.Parameters[k].Type)).Append(")"); + builder.Append("pars["); + builder.Append(k.ToString()); + builder.Append("]"); + if (k + 1 < method.Parameters.Length) builder.Append(", "); + } + + builder.AppendLine(");"); + } + else + { + if (method.Parameters.Length > 0) + { + builder.Append(" = (").Append(TypeName(method.Parameters[0].Type)).Append(")pars[0]"); + } + + builder.AppendLine(";"); + } + + if (method.ReturnsVoid && !m.Constructor) builder.AppendLine("return null;"); + builder.UnIndent().AppendLine("}"); + builder.UnIndent().AppendLine("}"); + } + } + + class TypeFieldDesc + { + public ITypeSymbol Type; + public bool Read; + public bool Write; + } + + class TypeField + { + public int CurrLevel = 1000; + public TypeFieldDesc Desc; + public string Name; + + public string ClassName() => "F_" + Name; + public void Set(int level, TypeFieldDesc desc) + { + if (level < CurrLevel) + { + CurrLevel = level; + Desc = desc; + } + } + } + + class TypeMethod + { + public List Overloads = new List(); + public int CurrentLevel = 1000; + public bool Constructor = false; + public bool Property = false; + public string PropertyName = null; + private string _name; + + public void SetName(string n) + { + _name = n; + } + + public string Name => _name ?? (Overloads.Count > 0 ? Overloads[0].Name : ""); + + public string ClassName(int overload) + { + return "M" + overload + "_" + Sanitize(Name); + } + + public override string ToString() + { + if (Overloads.Count < 0) return "[empty]"; + return Overloads[0].Name + " (" + + string.Join(";", Overloads.Select(x => x.ToDisplayString())) + ")"; + } + + public void AddMethod(int level, IMethodSymbol symbol) + { + if (level > CurrentLevel) return; + if (level < CurrentLevel) + { + Overloads = new List(); + CurrentLevel = level; + } + Overloads.Add(symbol); + } + } + } + + public class UserDataSyntaxReceiver : ISyntaxReceiver + { + public List Candidates { get; } = new(); + + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + { + if (syntaxNode is not AttributeSyntax attribute) + return; + + var name = ExtractName(attribute.Name); + + if (name != "MoonSharpUserData" && name != "MoonSharpUserDataAttribute") + return; + + // "attribute.Parent" is "AttributeListSyntax" + // "attribute.Parent.Parent" is a C# fragment the attribute is applied to + if (attribute.Parent?.Parent is ClassDeclarationSyntax classDeclaration) + Candidates.Add(classDeclaration); + } + + private static string ExtractName(TypeSyntax type) + { + while (type != null) + { + switch (type) + { + case IdentifierNameSyntax ins: + return ins.Identifier.Text; + + case QualifiedNameSyntax qns: + type = qns.Right; + break; + + default: + return null; + } + } + + return null; + } + } +} diff --git a/src/MoonSharp.HardwireGen/StringUtils.cs b/src/MoonSharp.HardwireGen/StringUtils.cs new file mode 100644 index 00000000..95316619 --- /dev/null +++ b/src/MoonSharp.HardwireGen/StringUtils.cs @@ -0,0 +1,14 @@ +using System; +using Microsoft.CodeAnalysis.CSharp; + +namespace MoonSharp.HardwireGen +{ + public static class StringUtils + { + public static string ToLiteral(this string input) + { + return SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(input)).ToFullString(); + } + + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/SymbolUtils.cs b/src/MoonSharp.HardwireGen/SymbolUtils.cs new file mode 100644 index 00000000..2e9cfa72 --- /dev/null +++ b/src/MoonSharp.HardwireGen/SymbolUtils.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis; + +namespace MoonSharp.HardwireGen +{ + public static class SymbolUtils + { + public static string TypeName(this ITypeSymbol type) + { + return type.ToDisplayString(new SymbolDisplayFormat( + SymbolDisplayGlobalNamespaceStyle.Omitted, + SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, + SymbolDisplayGenericsOptions.IncludeTypeParameters, + miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable + )); + } + public static IEnumerable<(int level,ISymbol symbol)> GetPublicMembers(this ITypeSymbol ts) + { + return IterateHierarchy(ts).SelectMany(n => + { + return n.Item2.GetMembers().Where(x => x.DeclaredAccessibility == Accessibility.Public) + .Select(y => (n.Item1, y)); + }); + } + public static IEnumerable<(int level, ITypeSymbol type)> IterateHierarchy(this ITypeSymbol type) + { + int i = 0; + var current = type; + while (current != null) + { + yield return (i++,current); + current = current.BaseType; + } + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/TabbedWriter.cs b/src/MoonSharp.HardwireGen/TabbedWriter.cs new file mode 100644 index 00000000..1e09f7b0 --- /dev/null +++ b/src/MoonSharp.HardwireGen/TabbedWriter.cs @@ -0,0 +1,61 @@ +using System; +using System.Text; +namespace MoonSharp.HardwireGen +{ + public class TabbedWriter + { + private StringBuilder builder = new StringBuilder(); + private int tabsCount = 0; + + public TabbedWriter Indent() + { + tabsCount++; + return this; + } + + public TabbedWriter UnIndent() + { + tabsCount--; + return this; + } + + private bool lineStarted = false; + + void StartLine() + { + if (!lineStarted) + { + lineStarted = true; + for (int i = 0; i < tabsCount; i++) builder.Append(" "); + } + } + + public TabbedWriter AppendLine(string line) + { + StartLine(); + builder.AppendLine(line); + lineStarted = false; + return this; + } + + public TabbedWriter AppendLine() + { + builder.AppendLine(); + lineStarted = false; + return this; + } + + + public TabbedWriter Append(string text) + { + StartLine(); + builder.Append(text); + return this; + } + + public override string ToString() + { + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.HardwireGen/TypeGenQueue.cs b/src/MoonSharp.HardwireGen/TypeGenQueue.cs new file mode 100644 index 00000000..2e67f127 --- /dev/null +++ b/src/MoonSharp.HardwireGen/TypeGenQueue.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis; + +namespace MoonSharp.HardwireGen +{ + public class TypeGenQueue + { + private HashSet hs = new HashSet(); + private Queue queue = new Queue(); + + public bool Enqueue(ITypeSymbol item) + { + if (hs.Contains(item.TypeName())) return false; + hs.Add(item.TypeName()); + queue.Enqueue(item); + return true; + } + + public int Count => queue.Count; + + public ITypeSymbol Dequeue() => queue.Dequeue(); + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/EmbeddableNUnitWrapper.cs b/src/MoonSharp.Interpreter.Tests/EmbeddableNUnitWrapper.cs deleted file mode 100755 index e4609fa7..00000000 --- a/src/MoonSharp.Interpreter.Tests/EmbeddableNUnitWrapper.cs +++ /dev/null @@ -1,97 +0,0 @@ -#if EMBEDTEST || UNITY_5 - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NUnit.Framework -{ - public class TestAttribute : Attribute - { } - - public class IgnoreAttribute : Attribute - { } - - public class TestFixtureAttribute : Attribute - { } - - public class ExpectedExceptionAttribute : Attribute - { - public Type ExpectedException { get; set; } - - public ExpectedExceptionAttribute(Type t) - { - ExpectedException = t; - } - } - - public static class Assert - { - public static void AreEqualNum(int expected, double other, string message = null) - { - Assert.IsTrue((double)expected == other, message ?? string.Format("{0} was expected, {1} was returned", expected, other)); - } - - public static void AreEqual(object expected, object other, string message = null) - { - if (expected is int && other is double) - AreEqualNum((int)expected, (double)other, message); - else if (expected != null) - Assert.IsTrue(expected.Equals(other), message ?? string.Format("{0} was expected, {1} was returned", expected, other)); - else - Assert.IsTrue(other == null, message ?? string.Format("null was expected, {0} was returned", other)); - } - - public static void IsTrue(bool condition, string message) - { - if (!condition) - throw new Exception("Test failed : " + message); - } - - public static void IsFalse(bool condition, string message) - { - IsTrue(!condition, message); - } - - internal static void IsNotNull(object o) - { - IsFalse(o == null, "Object is null"); - } - - internal static void IsNotNullOrEmpty(string p) - { - IsFalse(string.IsNullOrEmpty(p), "String is null or empty"); - } - - internal static void IsTrue(bool p) - { - IsTrue(p, "Value not true"); - } - - internal static void Catch(Action a) - { - try - { - a(); - } - catch(Exception e) - { - Assert.IsTrue(e is ET); - } - } - - - - internal static void Fail() - { - Assert.IsTrue(false); - } - } - - - -} - - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/BinaryDumpTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/BinaryDumpTests.cs deleted file mode 100644 index da69f091..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/BinaryDumpTests.cs +++ /dev/null @@ -1,335 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class BinaryDumpTests - { - private DynValue Script_RunString(string script) - { - Script s1 = new Script(); - DynValue v1 = s1.LoadString(script); - - using (MemoryStream ms = new MemoryStream()) - { - s1.Dump(v1, ms); - ms.Seek(0, SeekOrigin.Begin); - - Script s2 = new Script(); - DynValue func = s2.LoadStream(ms); - return func.Function.Call(); - } - } - - private DynValue Script_LoadFunc(string script, string funcname) - { - Script s1 = new Script(); - DynValue v1 = s1.DoString(script); - DynValue func = s1.Globals.Get(funcname); - - using (MemoryStream ms = new MemoryStream()) - { - s1.Dump(func, ms); - ms.Seek(0, SeekOrigin.Begin); - - Script s2 = new Script(); - return s2.LoadStream(ms); - } - } - - - [Test] - public void BinDump_ChunkDump() - { - string script = @" - local chunk = load('return 81;'); - local str = string.dump(chunk); - local fn = load(str); - return fn(9); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(81, res.Number); - } - - [Test] - public void BinDump_StringDump() - { - string script = @" - local str = string.dump(function(n) return n * n; end); - local fn = load(str); - return fn(9); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(81, res.Number); - } - - [Test] - public void BinDump_StandardDumpFunc() - { - string script = @" - function fact(n) - return n * 24; - end - - local str = string.dump(fact); - - "; - - DynValue fact = Script_LoadFunc(script, "fact"); - DynValue res = fact.Function.Call(5); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120, res.Number); - } - - - - [Test] - public void BinDump_FactorialDumpFunc() - { - string script = @" - function fact(n) - if (n == 0) then return 1; end - return fact(n - 1) * n; - end - "; - - DynValue fact = Script_LoadFunc(script, "fact"); - fact.Function.OwnerScript.Globals.Set("fact", fact); - DynValue res = fact.Function.Call(5); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120, res.Number); - } - - [Test] - public void BinDump_FactorialDumpFuncGlobal() - { - string script = @" - x = 0 - - function fact(n) - if (n == x) then return 1; end - return fact(n - 1) * n; - end - "; - - DynValue fact = Script_LoadFunc(script, "fact"); - fact.Function.OwnerScript.Globals.Set("fact", fact); - fact.Function.OwnerScript.Globals.Set("x", DynValue.NewNumber(0)); - DynValue res = fact.Function.Call(5); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120, res.Number); - } - - - [Test] - [ExpectedException(typeof(ArgumentException))] - public void BinDump_FactorialDumpFuncUpvalue() - { - string script = @" - local x = 0 - - function fact(n) - if (n == x) then return 1; end - return fact(n - 1) * n; - end - "; - - DynValue fact = Script_LoadFunc(script, "fact"); - fact.Function.OwnerScript.Globals.Set("fact", fact); - fact.Function.OwnerScript.Globals.Set("x", DynValue.NewNumber(0)); - DynValue res = fact.Function.Call(5); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120, res.Number); - } - - - - - - - - - - - - - - - - - - - - - - - - [Test] - public void BinDump_FactorialClosure() - { - string script = @" -local x = 5; - -function fact(n) - if (n == x) then return 1; end - return fact(n - 1) * n; -end - -x = 0; - -y = fact(5); - -x = 3; - -y = y + fact(5); - -return y; -"; - - DynValue res = Script_RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(140, res.Number); - } - - [Test] - public void BinDump_ClosureOnParam() - { - string script = @" - local function g (z) - local function f(a) - return a + z; - end - return f; - end - - return (g(3)(2));"; - - DynValue res = Script_RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(5, res.Number); - } - - [Test] - public void BinDump_NestedUpvalues() - { - string script = @" - local y = y; - - local x = 0; - local m = { }; - - function m:a() - self.t = { - dojob = function() - if (x == 0) then return 1; else return 0; end - end, - }; - end - - m:a(); - - return 10 * m.t.dojob(); - "; - - DynValue res = Script_RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - - [Test] - public void BinDump_NestedOutOfScopeUpvalues() - { - string script = @" - - function X() - local y = y; - - local x = 0; - local m = { }; - - function m:a() - self.t = { - dojob = function() - if (x == 0) then return 1; else return 0; end - end, - }; - end - - return m; - end - - Q = X(); - - Q:a(); - - return 10 * Q.t.dojob(); - "; - - DynValue res = Script_RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - - [Test] - public void Load_ChangeEnvWithDebugSetUpvalue() - { - List
list = new List
(); - - string script = @" - function print_env() - print(_ENV) - end - - function sandbox() - print(_ENV) -- prints: 'table: 0x100100610' - -- need to keep access to a few globals: - _ENV = { print = print, print_env = print_env, debug = debug, load = load } - print(_ENV) -- prints: 'table: 0x100105140' - print_env() -- prints: 'table: 0x100105140' - local code1 = load('print(_ENV)') - code1() -- prints: 'table: 0x100100610' - debug.setupvalue(code1, 0, _ENV) -- set our modified env - debug.setupvalue(code1, 1, _ENV) -- set our modified env - code1() -- prints: 'table: 0x100105140' - local code2 = load('print(_ENV)', nil, nil, _ENV) -- pass 'env' arg - code2() -- prints: 'table: 0x100105140' - end - - sandbox()"; - - Script S = new Script(CoreModules.Preset_Complete); - - S.Globals["print"] = (Action
)(t => list.Add(t)); - - S.DoString(script); - - Assert.AreEqual(6, list.Count); - - int[] eqs = new int[] { 0, 1, 1, 0, 1, 1 }; - - for (int i = 0; i < 6; i++) - Assert.AreEqual(list[eqs[i]], list[i]); - } - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/ConfigPropertyAssignerTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/ConfigPropertyAssignerTests.cs deleted file mode 100644 index b19342d8..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/ConfigPropertyAssignerTests.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class ConfigPropertyAssignerTests - { - private class MySubclass - { - [MoonSharpProperty] - public string MyString { get; set; } - - [MoonSharpProperty("number")] - public int MyNumber { get; private set; } - } - - private class MyClass - { - [MoonSharpProperty] - public string MyString { get; set; } - - [MoonSharpProperty("number")] - public int MyNumber { get; private set; } - - [MoonSharpProperty] - internal Table SomeTable { get; private set; } - - [MoonSharpProperty] - public DynValue NativeValue { get; private set; } - - [MoonSharpProperty] - public MySubclass SubObj { get; private set; } - } - - private MyClass Test(string tableDef) - { - Script s = new Script(CoreModules.None); - - DynValue table = s.DoString("return " + tableDef); - - Assert.AreEqual(DataType.Table, table.Type); - - PropertyTableAssigner pta = new PropertyTableAssigner("class"); - PropertyTableAssigner pta2 = new PropertyTableAssigner(); - - pta.SetSubassigner(pta2); - - MyClass o = new MyClass(); - - pta.AssignObject(o, table.Table); - - return o; - } - - [Test] - public void ConfigProp_SimpleAssign() - { - MyClass x = Test(@" - { - class = 'oohoh', - myString = 'ciao', - number = 3, - some_table = {}, - nativeValue = function() end, - subObj = { number = 15, myString = 'hi' }, - }"); - - Assert.AreEqual(x.MyNumber, 3); - Assert.AreEqual(x.MyString, "ciao"); - Assert.AreEqual(x.NativeValue.Type, DataType.Function); - Assert.AreEqual(x.SubObj.MyNumber, 15); - Assert.AreEqual(x.SubObj.MyString, "hi"); - Assert.IsNotNull(x.SomeTable); - - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void ConfigProp_ThrowsOnInvalid() - { - MyClass x = Test(@" - { - class = 'oohoh', - myString = 'ciao', - number = 3, - some_table = {}, - invalid = 3, - nativeValue = function() end, - }"); - - Assert.AreEqual(x.MyNumber, 3); - Assert.AreEqual(x.MyString, "ciao"); - Assert.AreEqual(x.NativeValue.Type, DataType.Function); - Assert.IsNotNull(x.SomeTable); - - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/CoroutineTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/CoroutineTests.cs deleted file mode 100644 index c8402487..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/CoroutineTests.cs +++ /dev/null @@ -1,293 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - class CoroutineTests - { - [Test] - public void Coroutine_Basic() - { - string script = @" - s = '' - - function foo() - for i = 1, 4 do - s = s .. i; - coroutine.yield(); - end - end - - function bar() - for i = 5, 9 do - s = s .. i; - coroutine.yield(); - end - end - - cf = coroutine.create(foo); - cb = coroutine.create(bar); - - for i = 1, 4 do - coroutine.resume(cf); - s = s .. '-'; - coroutine.resume(cb); - s = s .. ';'; - end - - return s; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1-5;2-6;3-7;4-8;", res.String); - } - - [Test] - public void Coroutine_Wrap() - { - string script = @" - s = '' - - function foo() - for i = 1, 4 do - s = s .. i; - coroutine.yield(); - end - end - - function bar() - for i = 5, 9 do - s = s .. i; - coroutine.yield(); - end - end - - cf = coroutine.wrap(foo); - cb = coroutine.wrap(bar); - - for i = 1, 4 do - cf(); - s = s .. '-'; - cb(); - s = s .. ';'; - end - - return s; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1-5;2-6;3-7;4-8;", res.String); - } - - [Test] - public void Coroutine_ClrBoundaryHandling() - { - string code = @" - function a() - callback(b) - end - - function b() - coroutine.yield(); - end - - c = coroutine.create(a); - - return coroutine.resume(c); - "; - - // Load the code and get the returned function - Script script = new Script(); - - script.Globals["callback"] = DynValue.NewCallback( - (ctx, args) => args[0].Function.Call() - ); - - DynValue ret = script.DoString(code); - - Assert.AreEqual(DataType.Tuple, ret.Type); - Assert.AreEqual(2, ret.Tuple.Length); - Assert.AreEqual(DataType.Boolean, ret.Tuple[0].Type); - Assert.AreEqual(false, ret.Tuple[0].Boolean); - Assert.AreEqual(DataType.String, ret.Tuple[1].Type); - Assert.IsTrue(ret.Tuple[1].String.EndsWith("attempt to yield across a CLR-call boundary")); - } - - [Test] - public void Coroutine_VariousErrorHandling() - { - string last = ""; - string code = @" - -function checkresume(step, ex, ey) - local x, y = coroutine.resume(c) - - assert(x == ex, 'Step ' .. step .. ': ' .. tostring(ex) .. ' was expected, got ' .. tostring(x)); - assert(y:endsWith(ey), 'Step ' .. step .. ': ' .. tostring(ey) .. ' was expected, got ' .. tostring(y)); -end - - -t = { } -m = { __tostring = function() print('2'); coroutine.yield(); print('3'); end } - -setmetatable(t, m); - - -function a() - checkresume(1, false, 'cannot resume non-suspended coroutine'); - coroutine.yield('ok'); - print(t); - coroutine.yield('ok'); -end - -c = coroutine.create(a); - -checkresume(2, true, 'ok'); -checkresume(3, false, 'attempt to yield across a CLR-call boundary'); -checkresume(4, false, 'cannot resume dead coroutine'); -checkresume(5, false, 'cannot resume dead coroutine'); -checkresume(6, false, 'cannot resume dead coroutine'); - - "; - - // Load the code and get the returned function - Script script = new Script(); - - script.Options.DebugPrint = (s) => last = s; - - script.DoString(code); - - Assert.AreEqual(last, "2"); - } - - [Test] - public void Coroutine_Direct_Resume() - { - string code = @" - return function() - local x = 0 - while true do - x = x + 1 - coroutine.yield(x) - if (x > 5) then - return 7 - end - end - end - "; - - // Load the code and get the returned function - Script script = new Script(); - DynValue function = script.DoString(code); - - // Create the coroutine in C# - DynValue coroutine = script.CreateCoroutine(function); - - // Loop the coroutine - string ret = ""; - while (coroutine.Coroutine.State != CoroutineState.Dead) - { - DynValue x = coroutine.Coroutine.Resume(); - ret = ret + x.ToString(); - } - - Assert.AreEqual("1234567", ret); - } - - - [Test] - public void Coroutine_Direct_AsEnumerable() - { - string code = @" - return function() - local x = 0 - while true do - x = x + 1 - coroutine.yield(x) - if (x > 5) then - return 7 - end - end - end - "; - - // Load the code and get the returned function - Script script = new Script(); - DynValue function = script.DoString(code); - - // Create the coroutine in C# - DynValue coroutine = script.CreateCoroutine(function); - - // Loop the coroutine - string ret = ""; - - foreach (DynValue x in coroutine.Coroutine.AsTypedEnumerable()) - { - ret = ret + x.ToString(); - } - - Assert.AreEqual("1234567", ret); - } - - - [Test] - public void Coroutine_AutoYield() - { - string code = @" - function fib(n) - if (n == 0 or n == 1) then - return 1; - else - return fib(n - 1) + fib(n - 2); - end - end - "; - - // Load the code and get the returned function - Script script = new Script(CoreModules.None); - script.DoString(code); - - // get the function - DynValue function = script.Globals.Get("fib"); - - // Create the coroutine in C# - DynValue coroutine = script.CreateCoroutine(function); - - // Set the automatic yield counter every 10 instructions. - // 10 is a too small! Use a much bigger value in your code to avoid interrupting too often! - coroutine.Coroutine.AutoYieldCounter = 10; - - int cycles = 0; - DynValue result = null; - - // Cycle until we get that the coroutine has returned something useful and not an automatic yield.. - for (result = coroutine.Coroutine.Resume(8); - result.Type == DataType.YieldRequest; - result = coroutine.Coroutine.Resume()) - { - cycles += 1; - } - - // Check the values of the operation - Assert.AreEqual(DataType.Number, result.Type); - Assert.AreEqual(34, result.Number); - - // Check the autoyield actually triggered - Assert.IsTrue(cycles > 10); - } - - - - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/GotoTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/GotoTests.cs deleted file mode 100644 index 932e0b7b..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/GotoTests.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class GotoTests - { - [Test] - public void Goto_Simple_Fwd() - { - string script = @" - function test() - x = 3 - goto skip - x = x + 2; - ::skip:: - return x; - end - - return test(); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - public void Goto_Simple_Bwd() - { - string script = @" - function test() - x = 5; - - ::jump:: - if (x == 3) then return x; end - - x = 3 - goto jump - - x = 4 - return x; - end - - return test(); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void Goto_UndefinedLabel() - { - string script = @" - goto there - "; - - Script.RunString(script); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void Goto_DoubleDefinedLabel() - { - string script = @" - ::label:: - ::label:: - "; - - Script.RunString(script); - } - - [Test] - public void Goto_RedefinedLabel() - { - string script = @" - ::label:: - do - ::label:: - end - "; - - Script.RunString(script); - } - - [Test] - public void Goto_RedefinedLabel_Goto() - { - string script = @" - ::label:: - do - goto label - do return 5 end - ::label:: - return 3 - end - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void Goto_UndefinedLabel_2() - { - string script = @" - goto label - do - do return 5 end - ::label:: - return 3 - end - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void Goto_VarInScope() - { - string script = @" - goto f - local x - ::f:: - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - - [Test] - public void Goto_JumpOutOfBlocks() - { - string script = @" - local u = 4 - - do - local x = 5 - - do - local y = 6 - - do - local z = 7 - end - - goto out - end - end - - do return 5 end - - ::out:: - - return 3 - "; - - DynValue res = Script.RunString(script); - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - public void Goto_JumpOutOfScopes() - { - string script = @" - local u = 4 - - do - local x = 5 - do - local y = 6 - do - goto out - local z = 7 - end - - end - end - - ::out:: - - do - local a - local b = 55 - - if (a == nil) then - b = b + 12 - end - - return b - end - - "; - - DynValue res = Script.RunString(script); - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(67, res.Number); - } - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs deleted file mode 100644 index c99bdd91..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs +++ /dev/null @@ -1,1556 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; -using NUnit.Framework; -using MoonSharp.Interpreter.Loaders; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class SimpleTests - { - [Test] - public void EmptyLongComment() - { - Script S = new Script(CoreModules.None); - DynValue res = S.DoString("--[[]]"); - } - - - [Test] - public void EmptyChunk() - { - Script S = new Script(CoreModules.None); - DynValue res = S.DoString(""); - } - - [Test] - public void CSharpStaticFunctionCallStatement() - { - IList args = null; - - string script = "print(\"hello\", \"world\");"; - - Script S = new Script(); - - S.Globals.Set("print", DynValue.NewCallback(new CallbackFunction((x, a) => - { - args = a.GetArray(); - return DynValue.NewNumber(1234.0); - }))); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Void, res.Type); - Assert.AreEqual(2, args.Count); - Assert.AreEqual(DataType.String, args[0].Type); - Assert.AreEqual("hello", args[0].String); - Assert.AreEqual(DataType.String, args[1].Type); - Assert.AreEqual("world", args[1].String); - } - - [Test] - public void CSharpStaticFunctionCallRedef() - { - IList args = null; - - string script = "local print = print; print(\"hello\", \"world\");"; - - var S = new Script(); - S.Globals.Set("print", DynValue.NewCallback(new CallbackFunction((_x, a) => { args = a.GetArray(); return DynValue.NewNumber(1234.0); }))); - - DynValue res = S.DoString(script); - - Assert.AreEqual(2, args.Count); - Assert.AreEqual(DataType.String, args[0].Type); - Assert.AreEqual("hello", args[0].String); - Assert.AreEqual(DataType.String, args[1].Type); - Assert.AreEqual("world", args[1].String); - Assert.AreEqual(DataType.Void, res.Type); - } - - [Test] - public void CSharpStaticFunctionCall4() - { - string script = "return callback()();"; - - var callback2 = DynValue.NewCallback(new CallbackFunction((_x, a) => { return DynValue.NewNumber(1234.0); })); - var callback = DynValue.NewCallback(new CallbackFunction((_x, a) => { return callback2; })); - - var S = new Script(); - S.Globals.Set("callback", callback); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234.0, res.Number); - } - - [Test] - public void CSharpStaticFunctionCall3() - { - string script = "return callback();"; - - var callback = DynValue.NewCallback(new CallbackFunction((_x, a) => { return DynValue.NewNumber(1234.0); })); - - var S = new Script(); - S.Globals.Set("callback", callback); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234.0, res.Number); - } - - [Test] - public void CSharpStaticFunctionCall2() - { - IList args = null; - - string script = "return callback 'hello';"; - - var S = new Script(); - S.Globals.Set("callback", DynValue.NewCallback(new CallbackFunction((_x, a) => { args = a.GetArray(); return DynValue.NewNumber(1234.0); }))); - - DynValue res = S.DoString(script); - - Assert.AreEqual(1, args.Count); - Assert.AreEqual(DataType.String, args[0].Type); - Assert.AreEqual("hello", args[0].String); - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234.0, res.Number); - } - - [Test] - public void CSharpStaticFunctionCall() - { - IList args = null; - - string script = "return print(\"hello\", \"world\");"; - - var S = new Script(); - S.Globals.Set("print", DynValue.NewCallback(new CallbackFunction((_x, a) => { args = a.GetArray(); return DynValue.NewNumber(1234.0); }))); - - DynValue res = S.DoString(script); - - Assert.AreEqual(2, args.Count); - Assert.AreEqual(DataType.String, args[0].Type); - Assert.AreEqual("hello", args[0].String); - Assert.AreEqual(DataType.String, args[1].Type); - Assert.AreEqual("world", args[1].String); - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234.0, res.Number); - } - - [Test] - //!!! DO NOT REFORMAT THIS METHOD !!! - public void LongStrings() - { - string script = @" - x = [[ - ciao - ]]; - - y = [=[ [[uh]] ]=]; - - z = [===[[==[[=[[[eheh]]=]=]]===] - - return x,y,z"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(3, res.Tuple.Length); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual(DataType.String, res.Tuple[1].Type); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("\t\t\t\t\tciao\n\t\t\t\t", res.Tuple[0].String); - Assert.AreEqual(" [[uh]] ", res.Tuple[1].String); - Assert.AreEqual("[==[[=[[[eheh]]=]=]", res.Tuple[2].String); - } - - - [Test] - public void UnicodeEscapeLua53Style() - { - string script = @" - x = 'ciao\u{41}'; - return x;"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("ciaoA", res.String); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void InvalidEscape() - { - string script = @" - x = 'ciao\k{41}'; - return x;"; - - DynValue res = Script.RunString(script); - } - - [Test] - public void KeywordsInStrings() - { - string keywrd = "and break do else elseif end false end for function end goto if ::in:: in local nil not [or][[][==][[]] repeat return { then 0 end return; }; then true (x != 5 or == * 3 - 5) x"; - - string script = string.Format(@" - x = '{0}'; - return x;", keywrd); - - DynValue res = Script.RunString(script); - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual(keywrd, res.String); - } - - - - [Test] - public void ParserErrorMessage() - { - bool caught = false; - string script = @" - return 'It's a wet floor warning saying wheat flour instead. \ - Probably, the cook thought it was funny. \ - He was wrong.'"; - - try - { - DynValue res = Script.RunString(script); - } - catch (SyntaxErrorException ex) - { - caught = true; - Assert.IsNotNullOrEmpty(ex.Message); - } - - Assert.IsTrue(caught); - } - - [Test] - public void StringsWithBackslashLineEndings2() - { - string script = @" - return 'a\ - b\ - c'"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - } - - [Test] - public void StringsWithBackslashLineEndings() - { - string script = @" - return 'It is a wet floor warning saying wheat flour instead. \ - Probably, the cook thought it was funny. \ - He was wrong.'"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - } - - [Test] - public void FunctionCallWrappers() - { - string script = @" - function boh(x) - return 1912 + x; - end - "; - - Script s = new Script(); - s.DoString(script); - - DynValue res = s.Globals.Get("boh").Function.Call(82); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - - [Test] - public void ReturnSimpleUnop() - { - string script = @"return -42"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(-42, res.Number); - } - - [Test] - public void ReturnSimple() - { - string script = @"return 42"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(42, res.Number); - } - - - [Test] - public void OperatorSimple() - { - string script = @"return 6*7"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(42, res.Number); - } - - - [Test] - public void SimpleBoolShortCircuit() - { - string script = @" - x = true or crash(); - y = false and crash(); - "; - - Script S = new Script(); - S.Globals.Set("crash", DynValue.NewCallback(new CallbackFunction((_x, a) => - { - throw new Exception("FAIL!"); - }))); - - S.DoString(script); - } - - [Test] - public void FunctionOrOperator() - { - string script = @" - loadstring = loadstring or load; - - return loadstring; - "; - - Script S = new Script(); - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.ClrFunction, res.Type); - - } - - - [Test] - public void SelectNegativeIndex() - { - string script = @" - return select(-1,'a','b','c'); - "; - - Script S = new Script(); - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("c", res.String); - } - - - - - - [Test] - public void BoolConversionAndShortCircuit() - { - string script = @" - i = 0; - - function f() - i = i + 1; - return '!'; - end - - x = false; - y = true; - - return false or f(), true or f(), false and f(), true and f(), i"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(5, res.Tuple.Length); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual(DataType.Boolean, res.Tuple[1].Type); - Assert.AreEqual(DataType.Boolean, res.Tuple[2].Type); - Assert.AreEqual(DataType.String, res.Tuple[3].Type); - Assert.AreEqual(DataType.Number, res.Tuple[4].Type); - Assert.AreEqual("!", res.Tuple[0].String); - Assert.AreEqual(true, res.Tuple[1].Boolean); - Assert.AreEqual(false, res.Tuple[2].Boolean); - Assert.AreEqual("!", res.Tuple[3].String); - Assert.AreEqual(2, res.Tuple[4].Number); - } - [Test] - public void HanoiTowersDontCrash() - { - string script = @" - function move(n, src, dst, via) - if n > 0 then - move(n - 1, src, via, dst) - move(n - 1, via, dst, src) - end - end - - move(4, 1, 2, 3) - "; - - DynValue res = Script.RunString(script); - } - - [Test] - public void Factorial() - { - string script = @" - -- defines a factorial function - function fact (n) - if (n == 0) then - return 1 - else - return n*fact(n - 1) - end - end - - return fact(5)"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120.0, res.Number); - } - - [Test] - public void IfStatmWithScopeCheck() - { - string script = @" - x = 0 - - if (x == 0) then - local i = 3; - x = i * 2; - end - - return i, x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(6, res.Tuple[1].Number); - } - - [Test] - public void ScopeBlockCheck() - { - string script = @" - local x = 6; - - do - local i = 33; - end - - return i, x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(6, res.Tuple[1].Number); - } - - [Test] - public void ForLoopWithBreak() - { - string script = @" - x = 0 - - for i = 1, 10 do - x = i - break; - end - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1, res.Number); - } - - - [Test] - public void ForEachLoopWithBreak() - { - string script = @" - x = 0 - y = 0 - - t = { 2, 4, 6, 8, 10, 12 }; - - function iter (a, ii) - ii = ii + 1 - local v = a[ii] - if v then - return ii, v - end - end - - function ipairslua (a) - return iter, a, 0 - end - - for i,j in ipairslua(t) do - x = x + i - y = y + j - - if (i >= 3) then - break - end - end - - return x, y"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(6, res.Tuple[0].Number); - Assert.AreEqual(12, res.Tuple[1].Number); - } - - - [Test] - public void ForEachLoop() - { - string script = @" - x = 0 - y = 0 - - t = { 2, 4, 6, 8, 10, 12 }; - - function iter (a, ii) - ii = ii + 1 - local v = a[ii] - if v then - return ii, v - end - end - - function ipairslua (a) - return iter, a, 0 - end - - for i,j in ipairslua(t) do - x = x + i - y = y + j - end - - return x, y"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(21, res.Tuple[0].Number); - Assert.AreEqual(42, res.Tuple[1].Number); - } - - [Test] - public void LengthOperator() - { - string script = @" - x = 'ciao' - y = { 1, 2, 3 } - - return #x, #y"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(4, res.Tuple[0].Number); - Assert.AreEqual(3, res.Tuple[1].Number); - } - - - [Test] - public void ForLoopWithBreakAndScopeCheck() - { - string script = @" - x = 0 - - for i = 1, 10 do - x = x + i - - if (i == 3) then - break - end - end - - return i, x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(6, res.Tuple[1].Number); - } - - [Test] - public void FactorialWithOneReturn() - { - string script = @" - -- defines a factorial function - function fact (n) - if (n == 0) then - return 1 - end - return n*fact(n - 1) - end - - return fact(5)"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120.0, res.Number); - } - - [Test] - public void VeryBasic() - { - string script = @"return 7"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(7, res.Number); - } - - [Test] - public void OperatorPrecedence1() - { - string script = @"return 1+2*3"; - - Script s = new Script(CoreModules.None); - DynValue res = s.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(7, res.Number); - } - [Test] - public void OperatorPrecedence2() - { - string script = @"return 2*3+1"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(7, res.Number); - } - - [Test] - public void OperatorAssociativity() - { - string script = @"return 2^3^2"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(512, res.Number); - } - - [Test] - public void OperatorPrecedence3() - { - string script = @"return 5-3-2"; - Script S = new Script(CoreModules.None); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(0, res.Number); - } - - [Test] - public void OperatorPrecedence4() - { - string script = @"return 3 + -1"; - Script S = new Script(CoreModules.None); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(2, res.Number); - } - - [Test] - public void OperatorPrecedence5() - { - string script = @"return 3 * -1 + 5 * 3"; - Script S = new Script(CoreModules.None); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(12, res.Number); - } - - [Test] - public void OperatorPrecedence6() - { - string script = @"return -2^2"; - Script S = new Script(CoreModules.None); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(-4, res.Number); - } - - [Test] - public void OperatorPrecedence7() - { - string script = @"return -7 / 0.5"; - Script S = new Script(CoreModules.None); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(-14, res.Number); - } - - [Test] - public void OperatorPrecedenceAndAssociativity() - { - string script = @"return 5+3*7-2*5+2^3^2"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(528, res.Number); - } - - [Test] - public void OperatorParenthesis() - { - string script = @"return (5+3)*7-2*5+(2^3)^2"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(110, res.Number); - } - - [Test] - public void GlobalVarAssignment() - { - string script = @"x = 1; return x;"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1, res.Number); - } - [Test] - public void TupleAssignment1() - { - string script = @" - function y() - return 2, 3 - end - - function x() - return 1, y() - end - - w, x, y, z = 0, x() - - return w+x+y+z"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(6, res.Number); - } - - [Test] - public void IterativeFactorialWithWhile() - { - string script = @" - function fact (n) - local result = 1; - while(n > 0) do - result = result * n; - n = n - 1; - end - return result; - end - - return fact(5)"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120.0, res.Number); - } - - - - [Test] - public void IterativeFactorialWithRepeatUntilAndScopeCheck() - { - string script = @" - function fact (n) - local result = 1; - repeat - local checkscope = 1; - result = result * n; - n = n - 1; - until (n == 0 and checkscope == 1) - return result; - end - - return fact(5)"; - - Script s = new Script(CoreModules.None); - DynValue res = s.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120.0, res.Number); - } - - [Test] - - public void SimpleForLoop() - { - string script = @" - x = 0 - for i = 1, 3 do - x = x + i; - end - - return x; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(6.0, res.Number); - } - - [Test] - public void SimpleFunc() - { - string script = @" - function fact (n) - return 3; - end - - return fact(3)"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - public void IterativeFactorialWithFor() - { - string script = @" - -- defines a factorial function - function fact (n) - x = 1 - for i = n, 1, -1 do - x = x * i; - end - - return x; - end - - return fact(5)"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(120.0, res.Number); - } - - - [Test] - public void LocalFunctionsObscureScopeRule() - { - string script = @" - local function fact() - return fact; - end - - return fact(); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Function, res.Type); - } - - [Test] - public void FunctionWithStringArg2() - { - string script = @" - x = 0; - - fact = function(y) - x = y - end - - fact 'ciao'; - - return x; - "; - - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("ciao", res.String); - } - - [Test] - public void FunctionWithStringArg() - { - string script = @" - x = 0; - - function fact(y) - x = y - end - - fact 'ciao'; - - return x; - "; - - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("ciao", res.String); - - } - - [Test] - public void FunctionWithTableArg() - { - string script = @" - x = 0; - - function fact(y) - x = y - end - - fact { 1,2,3 }; - - return x; - "; - - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Table, res.Type); - - } - - - [Test] - public void TupleAssignment2() - { - string script = @" - function boh() - return 1, 2; - end - - x,y,z = boh(), boh() - - return x,y,z; - "; - - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(DataType.Number, res.Tuple[2].Type); - Assert.AreEqual(1, res.Tuple[0].Number); - Assert.AreEqual(1, res.Tuple[1].Number); - Assert.AreEqual(2, res.Tuple[2].Number); - } - [Test] - public void LoopWithReturn() - { - string script = @"function Allowed( ) - for i = 1, 20 do - return false - end - return true - end - Allowed(); - "; - - DynValue res = Script.RunString(script); - - } - [Test] - public void IfWithLongExpr() - { - string script = @"function Allowed( ) - for i = 1, 20 do - if ( false ) or ( true and true ) or ( 7+i <= 9 and false ) then - return false - end - end - return true - end - Allowed(); - "; - - DynValue res = Script.RunString(script); - - } - - [Test] - public void IfWithLongExprTbl() - { - string script = @" - t = { {}, {} } - - function Allowed( ) - for i = 1, 20 do - if ( t[1][3] ) or ( i <= 17 and t[1][1] ) or ( 7+i <= 9 and t[1][1] ) then - return false - end - end - return true - end - Allowed(); - "; - - DynValue res = Script.RunString(script); - - } - - [Test] - public void ExpressionReducesTuples() - { - string script = @" - function x() - return 1,2 - end - - do return (x()); end - do return x(); end - "; - - DynValue res = (new Script(CoreModules.None)).DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1, res.Number); - } - - - [Test] - public void ExpressionReducesTuples2() - { - string script = @" - function x() - return 3,4 - end - - return 1,x(),x() - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(4, res.Tuple.Length); - } - - - [Test] - public void ArgsDoNotChange() - { - string script = @" - local a = 1; - local b = 2; - - function x(c, d) - c = c + 3; - d = d + 4; - return c + d; - end - - return x(a, b+1), a, b; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(3, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(DataType.Number, res.Tuple[2].Type); - Assert.AreEqual(11, res.Tuple[0].Number); - Assert.AreEqual(1, res.Tuple[1].Number); - Assert.AreEqual(2, res.Tuple[2].Number); - } - - - [Test] - public void VarArgsNoError() - { - string script = @" - function x(...) - - end - - function y(a, ...) - - end - - return 1; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1, res.Number); - } - - [Test] - public void VarArgsSum() - { - string script = @" - function x(...) - local t = pack(...); - local sum = 0; - - for i = 1, #t do - sum = sum + t[i]; - end - - return sum; - end - - return x(1,2,3,4); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - [Test] - public void VarArgsSum2() - { - string script = @" - function x(m, ...) - local t = pack(...); - local sum = 0; - - for i = 1, #t do - sum = sum + t[i]; - end - - return sum * m; - end - - return x(5,1,2,3,4); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(50, res.Number); - } - - [Test] - public void VarArgsSumTb() - { - string script = @" - function x(...) - local t = {...}; - local sum = 0; - - for i = 1, #t do - sum = sum + t[i]; - end - - return sum; - end - - return x(1,2,3,4); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - [Test] - public void SwapPattern() - { - string script = @" - local n1 = 1 - local n2 = 2 - local n3 = 3 - local n4 = 4 - n1,n2,n3,n4 = n4,n3,n2,n1 - - return n1,n2,n3,n4; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(4, res.Tuple.Length); - Assert.AreEqual(4, res.Tuple[0].Number); - Assert.AreEqual(3, res.Tuple[1].Number); - Assert.AreEqual(2, res.Tuple[2].Number); - Assert.AreEqual(1, res.Tuple[3].Number); - } - - [Test] - public void SwapPatternGlobal() - { - string script = @" - n1 = 1 - n2 = 2 - n3 = 3 - n4 = 4 - n1,n2,n3,n4 = n4,n3,n2,n1 - - return n1,n2,n3,n4; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(4, res.Tuple.Length); - Assert.AreEqual(4, res.Tuple[0].Number); - Assert.AreEqual(3, res.Tuple[1].Number); - Assert.AreEqual(2, res.Tuple[2].Number); - Assert.AreEqual(1, res.Tuple[3].Number); - } - - [Test] - public void EnvTestSuite() - { - string script = @" - local RES = { } - - RES.T1 = (_ENV == _G) - - a = 1 - - local function f(t) - local _ENV = t - - RES.T2 = (getmetatable == nil) - - a = 2 -- create a new entry in t, doesn't touch the original 'a' global - b = 3 -- create a new entry in t - end - - local t = {} - f(t) - - RES.T3 = a; - RES.T4 = b; - RES.T5 = t.a; - RES.T6 = t.b; - - return RES; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Table, res.Type); - - Table T = res.Table; - - Assert.AreEqual(DataType.Boolean, T.Get("T1").Type, "T1-Type"); - Assert.AreEqual(true, T.Get("T1").Boolean, "T1-Val"); - - Assert.AreEqual(DataType.Boolean, T.Get("T2").Type, "T2-Type"); - Assert.AreEqual(true, T.Get("T2").Boolean, "T2-Val"); - - Assert.AreEqual(DataType.Number, T.Get("T3").Type, "T3-Type"); - Assert.AreEqual(1, T.Get("T3").Number, "T3-Val"); - - Assert.AreEqual(DataType.Nil, T.Get("T4").Type, "T4"); - - Assert.AreEqual(DataType.Number, T.Get("T5").Type, "T5-Type"); - Assert.AreEqual(2, T.Get("T5").Number, "T5-Val"); - - Assert.AreEqual(DataType.Number, T.Get("T6").Type, "T6-Type"); - Assert.AreEqual(3, T.Get("T6").Number, "T6-Val"); - } - - [Test] - public void TupleToOperator() - { - string script = @" - function x() - return 3, 'xx'; - end - - return x() == 3; - "; - - Script S = new Script(CoreModules.None); - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Boolean, res.Type); - Assert.AreEqual(true, res.Boolean); - } - - - [Test] - public void LiteralExpands() - { - string script = @" - x = 'a\65\66\67z'; - return x; - "; - - Script S = new Script(CoreModules.None); - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("aABCz", res.String); - } - - [Test] - public void HomonymArguments() - { - string script = @" - function test(_,value,_) return _; end - - return test(1, 2, 3); - "; - - Script S = new Script(CoreModules.None); - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(3, res.Number); - } - - [Test] - public void VarArgsSumMainChunk() - { - string script = @" - local t = pack(...); - local sum = 0; - - for i = 1, #t do - sum = sum + t[i]; - end - - return sum; - "; - - DynValue fn = new Script().LoadString(script); - - DynValue res = fn.Function.Call(1, 2, 3, 4); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - [Test] - [ExpectedException(typeof(SyntaxErrorException))] - public void VarArgsInNoVarArgsReturnsError() - { - string script = @" - function x() - local t = {...}; - local sum = 0; - - for i = 1, #t do - sum = sum + t[i]; - end - - return sum; - end - - return x(1,2,3,4); - "; - - DynValue res = Script.RunString(script); - } - - [Test] - public void HexFloats_1() - { - string script = "return 0x0.1E"; - DynValue result = Script.RunString(script); - Assert.AreEqual((double)0x1E / (double)0x100, result.Number); - } - - [Test] - public void HexFloats_2() - { - string script = "return 0xA23p-4"; - DynValue result = Script.RunString(script); - Assert.AreEqual((double)0xA23 / 16.0, result.Number); - } - - [Test] - public void HexFloats_3() - { - string script = "return 0X1.921FB54442D18P+1"; - DynValue result = Script.RunString(script); - Assert.AreEqual((1 + (double)0x921FB54442D18 / (double)0x10000000000000) * 2, result.Number); - } - - [Test] - public void Simple_Delegate_Interop_1() - { - int a = 3; - var script = new Script(); - script.Globals["action"] = new Action(() => a = 5); - script.DoString("action()"); - Assert.AreEqual(5, a); - } - - [Test] - public void Simple_Delegate_Interop_2() - { - var oldPolicy = UserData.RegistrationPolicy; - - try - { - UserData.RegistrationPolicy = Interop.InteropRegistrationPolicy.Automatic; - - int a = 3; - var script = new Script(); - script.Globals["action"] = new Action(() => a = 5); - script.DoString("action()"); - Assert.AreEqual(5, a); - } - finally - { - UserData.RegistrationPolicy = oldPolicy; - } - } - - [Test] - public void MissingArgsDefaultToNil() - { - Script S = new Script(CoreModules.None); - DynValue res = S.DoString(@" - function test(a) - return a; - end - - test(); - "); - } - - [Test] - public void ParsingTest() - { - Script S = new Script(CoreModules.None); - DynValue res = S.LoadString(@" - t = {'a', 'b', 'c', ['d'] = 'f', ['e'] = 5, [65] = true, [true] = false} - function myFunc() - return 'one', 'two' - end - - print('Table Test 1:') - for k,v in pairs(t) do - print(tostring(k) .. ' / ' .. tostring(v)) - end - print('Table Test 2:') - for X,X in pairs(t) do - print(tostring(X) .. ' / ' .. tostring(X)) - end - print('Function Test 1:') - v1,v2 = myFunc() - print(v1) - print(v2) - print('Function Test 2:') - v,v = myFunc() - print(v) - print(v) - "); - } - - -// [Test] -// public void TestModulesLoadingWithoutCrash() -// { -//#if !PCL -// var basePath = AppDomain.CurrentDomain.BaseDirectory; -// var scriptPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts\\test"); -// Script script = new Script(); - -// ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new[] -// { -// System.IO.Path.Combine(basePath, "scripts\\test\\test.lua"), -// }; -// var obj = script.LoadFile(System.IO.Path.Combine(scriptPath, "test.lua")); -// obj.Function.Call(); -//#endif -// } - - [Test] - public void NumericConversionFailsIfOutOfBounds() - { - Script S = new Script(); - - S.Globals["my_function_takes_byte"] = (Action)(p => { }); - - try - { - S.DoString("my_function_takes_byte(2010191) -- a huge number that is definitely not a byte"); - - Assert.Fail(); // ScriptRuntimeException should have been thrown, if it doesn't Assert.Fail should execute - } - catch (ScriptRuntimeException e) - { - //Assert.Pass(e.DecoratedMessage); - } - } - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/StringLibTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/StringLibTests.cs deleted file mode 100644 index e20c93a1..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/StringLibTests.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class StringLibTests - { - [Test] - public void String_GMatch_1() - { - string script = @" - t = ''; - - for word in string.gmatch('Hello Lua user', '%a+') do - t = t .. word; - end - - return (t); - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("HelloLuauser", res.String); - } - - [Test] - public void String_Find_1() - { - string script = @"return string.find('Hello Lua user', 'Lua');"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, 7, 9); - } - - [Test] - public void String_Find_2() - { - string script = @"return string.find('Hello Lua user', 'banana');"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, null); - } - - [Test] - public void String_Find_3() - { - string script = @"return string.find('Hello Lua user', 'Lua', 1);"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, 7, 9); - } - - [Test] - public void String_Find_4() - { - string script = @"return string.find('Hello Lua user', 'Lua', 8);"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, null); - } - - [Test] - public void String_Find_5() - { - string script = @"return string.find('Hello Lua user', 'e', -5);"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, 13, 13); - } - - [Test] - public void String_Find_6() - { - string script = @"return string.find('Hello Lua user', '%su');"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, 10, 11); - } - - [Test] - public void String_Find_7() - { - string script = @"return string.find('Hello Lua user', '%su', 1);"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, 10, 11); - } - - [Test] - public void String_Find_8() - { - string script = @"return string.find('Hello Lua user', '%su', 1, true);"; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, null); - } - [Test] - public void String_Find_9() - { - string script = @" - s = 'Deadline is 30/05/1999, firm' - date = '%d%d/%d%d/%d%d%d%d'; - return s:sub(s:find(date)); - "; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, "30/05/1999"); - } - - [Test] - public void String_Find_10() - { - string script = @" - s = 'Deadline is 30/05/1999, firm' - date = '%f[%S]%d%d/%d%d/%d%d%d%d'; - return s:sub(s:find(date)); - "; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, "30/05/1999"); - } - - [Test] - public void String_Find_11() - { - string script = @" - s = 'Deadline is 30/05/1999, firm' - date = '%f[%s]%d%d/%d%d/%d%d%d%d'; - return s:find(date); - "; - DynValue res = Script.RunString(script); - Assert.IsTrue(res.IsNil()); - } - - [Test] - public void String_Format_1() - { - string script = @" - d = 5; m = 11; y = 1990 - return string.format('%02d/%02d/%04d', d, m, y) - "; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, "05/11/1990"); - } - - [Test] - public void String_GSub_1() - { - string script = @" - s = string.gsub('hello world', '(%w+)', '%1 %1') - return s, s == 'hello hello world world' - "; - DynValue res = Script.RunString(script); - Assert.AreEqual(res.Tuple[0].String, "hello hello world world"); - Assert.AreEqual(res.Tuple[1].Boolean, true); - } - - [Test] - public void PrintTest1() - { - string script = @" - print('ciao', 1); - "; - string printed = null; - - Script S = new Script(); - DynValue main = S.LoadString(script); - - S.Options.DebugPrint = s => - { - printed = s; - }; - - S.Call(main); - - Assert.AreEqual("ciao\t1", printed); - } - - [Test] - public void PrintTest2() - { - string script = @" - t = {}; - m = {}; - - function m.__tostring() - return 'ciao'; - end - - setmetatable(t, m); - - print(t, 1); - "; - string printed = null; - - Script S = new Script(); - DynValue main = S.LoadString(script); - - S.Options.DebugPrint = s => - { - printed = s; - }; - - S.Call(main); - - Assert.AreEqual("ciao\t1", printed); - } - - [Test] - public void ToStringTest() - { - string script = @" - t = {} - mt = {} - a = nil - function mt.__tostring () a = 'yup' end - setmetatable(t, mt) - return tostring(t), a; - "; - DynValue res = Script.RunString(script); - Utils.DynAssert(res, DataType.Void, "yup"); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void String_GSub_2() - { - string script = @" - string.gsub('hello world', '%w+', '%e') - "; - DynValue res = Script.RunString(script); - } - - [Test] - public void String_GSub_3() - { - Script S = new Script(); - S.Globals["a"] = @" 'C:\temp\test.lua:68: bad argument #1 to 'date' (invalid conversion specifier '%Ja')' - doesn't match '^[^:]+:%d+: bad argument #1 to 'date' %(invalid conversion specifier '%%Ja'%)'"; - - string script = @" - string.gsub(a, '\n', '\n #') - "; - DynValue res = S.DoString(script); - } - - [Test] - public void String_Match_1() - { - string s = @"test.lua:185: field 'day' missing in date table"; - string p = @"^[^:]+:%d+: field 'day' missing in date table"; - - TestMatch(s, p, true); - } - - private void TestMatch(string s, string p, bool expected) - { - Script S = new Script(CoreModules.String); - S.Globals["s"] = s; - S.Globals["p"] = p; - DynValue res = S.DoString("return string.match(s, p)"); - - Assert.AreEqual(expected, !res.IsNil()); - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs deleted file mode 100644 index 4cdbb9a5..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs +++ /dev/null @@ -1,567 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Execution; -using NUnit.Framework; -using MoonSharp.Interpreter.CoreLib; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class TableTests - { - [Test] - public void TableAccessAndEmptyCtor() - { - string script = @" - a = { } - - a[1] = 1; - - return a[1]"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1, res.Number); - } - - - - [Test] - public void TableAccessAndCtor() - { - string script = @" - a = { 55, 2, 3, aurevoir=6, [false] = 7 } - - a[1] = 1; - a.ciao = 4; - a['hello'] = 5; - - return a[1], a[2], a[3], a['ciao'], a.hello, a.aurevoir, a[false]"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(7, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(DataType.Number, res.Tuple[2].Type); - Assert.AreEqual(DataType.Number, res.Tuple[3].Type); - Assert.AreEqual(DataType.Number, res.Tuple[4].Type); - Assert.AreEqual(DataType.Number, res.Tuple[5].Type); - Assert.AreEqual(DataType.Number, res.Tuple[6].Type); - Assert.AreEqual(1, res.Tuple[0].Number); - Assert.AreEqual(2, res.Tuple[1].Number); - Assert.AreEqual(3, res.Tuple[2].Number); - Assert.AreEqual(4, res.Tuple[3].Number); - Assert.AreEqual(5, res.Tuple[4].Number); - Assert.AreEqual(6, res.Tuple[5].Number); - Assert.AreEqual(7, res.Tuple[6].Number); - } - - [Test] - public void TableMethod1() - { - string script = @" - x = 0 - - a = - { - value = 1912, - - val = function(self, num) - x = self.value + num - end - } - - a.val(a, 82); - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - [Test] - public void TableMethod2() - { - string script = @" - x = 0 - - a = - { - value = 1912, - - val = function(self, num) - x = self.value + num - end - } - - a:val(82); - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - [Test] - public void TableMethod3() - { - string script = @" - x = 0 - - a = - { - value = 1912, - } - - function a.val(self, num) - x = self.value + num - end - - a:val(82); - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - - [Test] - public void TableMethod4() - { - string script = @" - x = 0 - - local a = - { - value = 1912, - } - - function a:val(num) - x = self.value + num - end - - a:val(82); - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - [Test] - public void TableMethod5() - { - string script = @" - x = 0 - - a = - { - value = 1912, - } - - b = { tb = a }; - c = { tb = b }; - - function c.tb.tb:val(num) - x = self.value + num - end - - a:val(82); - - return x"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1994, res.Number); - } - - - [Test] - public void TableMethod6() - { - string script = @" - do - local a = {x=0} - function a:add (x) self.x, a.y = self.x+x, 20; return self end - return (a:add(10):add(20):add(30).x == 60 and a.y == 20) - end"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Boolean, res.Type); - Assert.AreEqual(true, res.CastToBool()); - } - - [Test] - public void TableNextWithChangeInCollection() - { - string script = @" - x = { } - - function copy(k, v) - x[k] = v; - end - - - t = - { - a = 1, - b = 2, - c = 3, - d = 4, - e = 5 - } - - k,v = next(t, nil); - copy(k, v); - - k,v = next(t, k); - copy(k, v); - v = nil; - - k,v = next(t, k); - copy(k, v); - - k,v = next(t, k); - copy(k, v); - - k,v = next(t, k); - copy(k, v); - - s = x.a .. '|' .. x.b .. '|' .. x.c .. '|' .. x.d .. '|' .. x.e - - return s;"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1|2|3|4|5", res.String); - } - - - [Test] - public void TablePairsWithoutMetatable() - { - string script = @" - V = 0 - K = '' - - t = - { - a = 1, - b = 2, - c = 3, - d = 4, - e = 5 - } - - for k, v in pairs(t) do - K = K .. k; - V = V + v; - end - - return K, V;"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(5, res.Tuple[0].String.Length); - Assert.AreEqual(15, res.Tuple[1].Number); - } - - [Test] - public void TableIPairsWithoutMetatable() - { - string script = @" - x = 0 - y = 0 - - t = { 2, 4, 6, 8, 10, 12 }; - - for i,j in ipairs(t) do - x = x + i - y = y + j - - if (i >= 3) then - break - end - end - - return x, y"; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(6, res.Tuple[0].Number); - Assert.AreEqual(12, res.Tuple[1].Number); - } - - [Test] - public void TestLoadSyntaxError() - { - string script = @" - function reader () - i = i + 1 - return t[i] - end - - - t = { [[?syntax error?]] } - i = 0 - f, msg = load(reader, 'errorchunk') - - return f, msg; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.String, res.Tuple[1].Type); - } - - - [Test] - public void TableSimplifiedAccess1() - { - string script = @" - t = { - ciao = 'hello' - } - - return t; - "; - - Script s = new Script(); - DynValue t = s.DoString(script); - - Assert.AreEqual("hello", t.Table["ciao"]); - } - - [Test] - public void TableSimplifiedAccess2() - { - string script = @" - t = { - ciao = x - } - - return t; - "; - - Script s = new Script(); - s.Globals["x"] = "hello"; - DynValue t = s.DoString(script); - - Assert.AreEqual("hello", t.Table["ciao"]); - } - - [Test] - public void TableSimplifiedAccess3() - { - string script = @" - t = { - } - - return t; - "; - - Script s = new Script(); - DynValue t = s.DoString(script); - - s.Globals["t", "ciao"] = "hello"; - - Assert.AreEqual("hello", t.Table["ciao"]); - } - - [Test] - public void TableSimplifiedAccess4() - { - string script = @" - t = { - } - "; - - Script s = new Script(); - s.DoString(script); - - s.Globals["t", "ciao"] = "hello"; - - Assert.AreEqual("hello", s.Globals["t", "ciao"]); - } - - - [Test] - public void TableSimplifiedAccess5() - { - string script = @" - t = { - ciao = 'hello' - } - "; - - Script s = new Script(); - s.DoString(script); - - Assert.AreEqual("hello", s.Globals["t", "ciao"]); - } - - [Test] - public void TableSimplifiedAccess6() - { - string script = @" - t = { - ciao = - { 'hello' } - } - "; - - Script s = new Script(CoreModules.None); - s.DoString(script); - - Assert.AreEqual("hello", s.Globals["t", "ciao", 1]); - } - - - [Test] - public void TestNilRemovesEntryForPairs() - { - string script = @" - str = '' - - function showTable(t) - for i, j in pairs(t) do - str = str .. i; - end - str = str .. '$' - end - - tb = {} - tb['id'] = 3 - - showTable(tb) - - tb['id'] = nil - - showTable(tb) - - return str - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("id$$", res.String); - } - - [Test] - public void TestUnpack() - { - string script = @" - return unpack({3,4}) - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(2, res.Tuple.Length); - Assert.AreEqual(3, res.Tuple[0].Number); - Assert.AreEqual(4, res.Tuple[1].Number); - } - - [Test] - public void PrimeTable_1() - { - string script = @" - t = ${ - ciao = 'hello' - } - "; - - Script s = new Script(); - s.DoString(script); - - Assert.AreEqual("hello", s.Globals["t", "ciao"]); - Assert.IsTrue(s.Globals.Get("t").Table.OwnerScript == null); - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void PrimeTable_2() - { - string script = @" - t = ${ - ciao = function() end - } - "; - - Script s = new Script(); - s.DoString(script); - - Assert.Fail(); - } - - - [Test] - public void Table_Length_Calculations() - { - Table T = new Table(null); - - Assert.AreEqual(0, T.Length, "A"); - - T.Set(1, DynValue.True); - - Assert.AreEqual(1, T.Length, "B"); - - T.Set(2, DynValue.True); - T.Set(3, DynValue.True); - T.Set(4, DynValue.True); - - Assert.AreEqual(4, T.Length, "C"); - - T.Set(3, DynValue.Nil); - - Assert.AreEqual(2, T.Length, "D"); - - T.Set(3, DynValue.True); - - Assert.AreEqual(4, T.Length, "E"); - - T.Set(3, DynValue.Nil); - - Assert.AreEqual(2, T.Length, "F"); - - T.Append(DynValue.True); - - Assert.AreEqual(4, T.Length, "G"); - - T.Append(DynValue.True); - - Assert.AreEqual(5, T.Length, "H"); - - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataFieldsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataFieldsTests.cs deleted file mode 100644 index d7fd9c8c..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataFieldsTests.cs +++ /dev/null @@ -1,589 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ -#pragma warning disable 169 // unused private field - - [TestFixture] - public class UserDataFieldsTests - { - public class SomeClass - { - public int IntProp; - public const int ConstIntProp = 115; - public readonly int RoIntProp = 123; - public int? NIntProp; - public object ObjProp; - public static string StaticProp; - private string PrivateProp; - } - - public void Test_ConstIntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.ConstIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(115, res.Number); - } - - public void Test_ReadOnlyIntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.RoIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(123, res.Number); - } - - public void Test_ConstIntFieldSetter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.ConstIntProp = 1; - return myobj.ConstIntProp;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(115, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - public void Test_ReadOnlyIntFieldSetter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.RoIntProp = 1; - return myobj.RoIntProp;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(123, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - - - public void Test_IntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.IntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(321, res.Number); - } - - public void Test_NIntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.NIntProp; - y = myobj2.NIntProp; - return x,y;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(321.0, res.Tuple[0].Number); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Nil, res.Tuple[1].Type); - } - - public void Test_ObjFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.ObjProp; - y = myobj2.ObjProp; - z = myobj2.ObjProp.ObjProp; - return x,y,z;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual("ciao", res.Tuple[0].String); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("ciao", res.Tuple[2].String); - Assert.AreEqual(DataType.UserData, res.Tuple[1].Type); - Assert.AreEqual(obj1, res.Tuple[1].UserData.Object); - } - - public void Test_IntFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = 19;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_NIntFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj1.NIntProp = nil; - myobj2.NIntProp = 19;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual(321, obj1.NIntProp); - Assert.AreEqual(null, obj2.NIntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(null, obj1.NIntProp); - Assert.AreEqual(19, obj2.NIntProp); - } - - public void Test_ObjFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj1.ObjProp = myobj2; - myobj2.ObjProp = 'hello';"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual("ciao", obj1.ObjProp); - Assert.AreEqual(obj1, obj2.ObjProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(obj2, obj1.ObjProp); - Assert.AreEqual("hello", obj2.ObjProp); - } - - public void Test_InvalidFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = '19';"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_StaticFieldAccess(InteropAccessMode opt) - { - string script = @" - static.StaticProp = 'asdasd' .. static.StaticProp;"; - - Script S = new Script(); - - SomeClass.StaticProp = "qweqwe"; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - - Assert.AreEqual("qweqwe", SomeClass.StaticProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual("asdasdqweqwe", SomeClass.StaticProp); - } - - [Test] - public void Interop_IntFieldGetter_None() - { - Test_IntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_IntFieldGetter_Lazy() - { - Test_IntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_IntFieldGetter_Precomputed() - { - Test_IntFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_NIntFieldGetter_None() - { - Test_NIntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_NIntFieldGetter_Lazy() - { - Test_NIntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_NIntFieldGetter_Precomputed() - { - Test_NIntFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ObjFieldGetter_None() - { - Test_ObjFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ObjFieldGetter_Lazy() - { - Test_ObjFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ObjFieldGetter_Precomputed() - { - Test_ObjFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_IntFieldSetter_None() - { - Test_IntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_IntFieldSetter_Lazy() - { - Test_IntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_IntFieldSetter_Precomputed() - { - Test_IntFieldSetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_NIntFieldSetter_None() - { - Test_NIntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_NIntFieldSetter_Lazy() - { - Test_NIntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_NIntFieldSetter_Precomputed() - { - Test_NIntFieldSetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ObjFieldSetter_None() - { - Test_ObjFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ObjFieldSetter_Lazy() - { - Test_ObjFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ObjFieldSetter_Precomputed() - { - Test_ObjFieldSetter(InteropAccessMode.Preoptimized); - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidFieldSetter_None() - { - Test_InvalidFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidFieldSetter_Lazy() - { - Test_InvalidFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidFieldSetter_Precomputed() - { - Test_InvalidFieldSetter(InteropAccessMode.Preoptimized); - } - - - [Test] - public void Interop_StaticFieldAccess_None() - { - Test_StaticFieldAccess(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_StaticFieldAccess_Lazy() - { - Test_StaticFieldAccess(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_StaticFieldAccess_Precomputed() - { - Test_StaticFieldAccess(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void Interop_IntFieldSetterWithSimplifiedSyntax() - { - string script = @" - myobj.IntProp = 19;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals["myobj"] = obj; - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(obj, S.Globals["myobj"]); - Assert.AreEqual(19, obj.IntProp); - } - - - - - [Test] - public void Interop_ConstIntFieldGetter_None() - { - Test_ConstIntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConstIntFieldGetter_Lazy() - { - Test_ConstIntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConstIntFieldGetter_Precomputed() - { - Test_ConstIntFieldGetter(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void Interop_ConstIntFieldSetter_None() - { - Test_ConstIntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConstIntFieldSetter_Lazy() - { - Test_ConstIntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConstIntFieldSetter_Precomputed() - { - Test_ConstIntFieldSetter(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void Interop_ReadOnlyIntFieldGetter_None() - { - Test_ReadOnlyIntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ReadOnlyIntFieldGetter_Lazy() - { - Test_ReadOnlyIntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ReadOnlyIntFieldGetter_Precomputed() - { - Test_ReadOnlyIntFieldGetter(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void Interop_ReadOnlyIntFieldSetter_None() - { - Test_ReadOnlyIntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ReadOnlyIntFieldSetter_Lazy() - { - Test_ReadOnlyIntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ReadOnlyIntFieldSetter_Precomputed() - { - Test_ReadOnlyIntFieldSetter(InteropAccessMode.Preoptimized); - } - - - - - - - - - - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataIndexerTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataIndexerTests.cs deleted file mode 100644 index 9ad1003e..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataIndexerTests.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class UserDataIndexerTests - { - public class IndexerTestClass - { - Dictionary mymap = new Dictionary(); - - public int this[int idx] - { - get { return mymap[idx]; } - set { mymap[idx] = value; } - } - - public int this[int idx1, int idx2, int idx3] - { - get { int idx = (idx1 + idx2) * idx3; return mymap[idx]; } - set { int idx = (idx1 + idx2) * idx3; mymap[idx] = value; } - } - } - - private void IndexerTest(string code, int expected) - { - Script S = new Script(); - - IndexerTestClass obj = new IndexerTestClass(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.Create(obj)); - - DynValue v = S.DoString(code); - - Assert.AreEqual(DataType.Number, v.Type); - Assert.AreEqual(expected, v.Number); - } - - [Test] - public void Interop_SingleSetterOnly() - { - string script = @"o[1] = 1; return 13"; - IndexerTest(script, 13); - } - - - [Test] - public void Interop_SingleIndexerGetSet() - { - string script = @"o[5] = 19; return o[5];"; - IndexerTest(script, 19); - } - - [Test] - public void Interop_MultiIndexerGetSet() - { - string script = @"o[1,2,3] = 47; return o[1,2,3];"; - IndexerTest(script, 47); - } - - [Test] - public void Interop_MultiIndexerMetatableGetSet() - { - string script = @" - m = { - __index = o, - __newindex = o - } - - t = { } - - setmetatable(t, m); - - t[10,11,12] = 1234; return t[10,11,12];"; - IndexerTest(script, 1234); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_MultiIndexerMetamethodGetSet() - { - string script = @" - m = { - __index = function() end, - __newindex = function() end - } - - t = { } - - setmetatable(t, m); - - t[10,11,12] = 1234; return t[10,11,12];"; - IndexerTest(script, 1234); - } - - - - - - [Test] - public void Interop_MixedIndexerGetSet() - { - string script = @"o[3,2,3] = 119; return o[15];"; - IndexerTest(script, 119); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_ExpListIndexingCompilesButNotRun1() - { - string script = @" - x = { 99, 98, 97, 96 } - return x[2,3]; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(98, res.Number); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_ExpListIndexingCompilesButNotRun2() - { - string script = @" - x = { 99, 98, 97, 96 } - x[2,3] = 5; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(98, res.Number); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs deleted file mode 100755 index 09d4ebfc..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs +++ /dev/null @@ -1,1080 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class UserDataMethodsTests - { - public class SomeClass_NoRegister : IComparable - { - public string ManipulateString(string input, ref string tobeconcat, out string lowercase) - { - tobeconcat = input + tobeconcat; - lowercase = input.ToLower(); - return input.ToUpper(); - } - - public string ConcatNums(int p1, int p2) - { - return string.Format("{0}%{1}", p1, p2); - } - - public int SomeMethodWithLongName(int i) - { - return i * 2; - } - - public static StringBuilder SetComplexRecursive(List intList) - { - StringBuilder sb = new StringBuilder(); - - foreach (int[] arr in intList) - { - sb.Append(string.Join(",", arr.Select(s => s.ToString()).ToArray())); - sb.Append("|"); - } - - return sb; - } - - public static StringBuilder SetComplexTypes(List strlist, IList intlist, Dictionary map, - string[] strarray, int[] intarray) - { - StringBuilder sb = new StringBuilder(); - - sb.Append(string.Join(",", strlist.ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", intlist.Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Keys.OrderBy(x => x).Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Values.OrderBy(x => x).Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", strarray)); - - sb.Append("|"); - - sb.Append(string.Join(",", intarray.Select(i => i.ToString()).ToArray())); - - return sb; - } - - - public static StringBuilder ConcatS(int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass_NoRegister p9, int p10 = 1994) - { - p7.Append(p1); - p7.Append(p2); - p7.Append(p3); - p7.Append(p4); - - p7.Append("|"); - foreach (var o in p5) p7.Append(o); - p7.Append("|"); - foreach (var o in p6) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Keys.OrderBy(x => x.ToString())) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Values.OrderBy(x => x.ToString())) p7.Append(o); - p7.Append("|"); - - p7.Append(p9); - p7.Append(p10); - - return p7; - } - - public string Format(string s, params object[] args) - { - return string.Format(s, args); - } - - public StringBuilder ConcatI(Script s, int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass_NoRegister p9, int p10 = 1912) - { - Assert.IsNotNull(s); - return ConcatS(p1, p2, p3, p4, p5, p6, p7, p8, this, p10); - } - - public override string ToString() - { - return "!SOMECLASS!"; - } - - public List MkList(int from, int to) - { - List l = new List(); - for (int i = from; i <= to; i++) - l.Add(i); - return l; - } - - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - } - - - public class SomeClass : IComparable - { - public string ManipulateString(string input, ref string tobeconcat, out string lowercase) - { - tobeconcat = input + tobeconcat; - lowercase = input.ToLower(); - return input.ToUpper(); - } - - public string ConcatNums(int p1, int p2) - { - return string.Format("{0}%{1}", p1, p2); - } - - public int SomeMethodWithLongName(int i) - { - return i * 2; - } - - public static StringBuilder SetComplexRecursive(List intList) - { - StringBuilder sb = new StringBuilder(); - - foreach (int[] arr in intList) - { - sb.Append(string.Join(",", arr.Select(s => s.ToString()).ToArray())); - sb.Append("|"); - } - - return sb; - } - - public static StringBuilder SetComplexTypes(List strlist, IList intlist, Dictionary map, - string[] strarray, int[] intarray) - { - StringBuilder sb = new StringBuilder(); - - sb.Append(string.Join(",", strlist.ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", intlist.Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Values.OrderBy(x => x).Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", strarray)); - - sb.Append("|"); - - sb.Append(string.Join(",", intarray.Select(i => i.ToString()).ToArray())); - - return sb; - } - - - public static StringBuilder ConcatS(int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass p9, int p10 = 1994) - { - p7.Append(p1); - p7.Append(p2); - p7.Append(p3); - p7.Append(p4); - - p7.Append("|"); - foreach (var o in p5) p7.Append(o); - p7.Append("|"); - foreach (var o in p6) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - - p7.Append(p9); - p7.Append(p10); - - return p7; - } - - public string Format(string s, params object[] args) - { - return string.Format(s, args); - } - - public StringBuilder ConcatI(Script s, int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass p9, int p10 = 1912) - { - Assert.IsNotNull(s); - return ConcatS(p1, p2, p3, p4, p5, p6, p7, p8, this, p10); - } - - public override string ToString() - { - return "!SOMECLASS!"; - } - - public List MkList(int from, int to) - { - List l = new List(); - for (int i = from; i <= to; i++) - l.Add(i); - return l; - } - - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - } - - public interface Interface1 - { - string Test1(); - } - - public interface Interface2 - { - string Test2(); - } - - - public class SomeOtherClass - { - public string Test1() - { - return "Test1"; - } - - public string Test2() - { - return "Test2"; - } - } - - - public class SomeOtherClassCustomDescriptor - { - } - - public class CustomDescriptor : IUserDataDescriptor - { - public string Name - { - get { return "ciao"; } - } - - public Type Type - { - get { return typeof(SomeOtherClassCustomDescriptor); } - } - - public DynValue Index(Script script, object obj, DynValue index, bool dummy) - { - return DynValue.NewNumber(index.Number * 4); - } - - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool dummy) - { - throw new NotImplementedException(); - } - - public string AsString(object obj) - { - return null; - } - - public DynValue MetaIndex(Script script, object obj, string metaname) - { - return null; - } - - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } - - - - - public class SelfDescribingClass : IUserDataType - { - public DynValue Index(Script script, DynValue index, bool isNameIndex) - { - return DynValue.NewNumber(index.Number * 3); - } - - public bool SetIndex(Script script, DynValue index, DynValue value, bool isNameIndex) - { - throw new NotImplementedException(); - } - - public DynValue MetaIndex(Script script, string metaname) - { - throw new NotImplementedException(); - } - } - - public class SomeOtherClassWithDualInterfaces : Interface1, Interface2 - { - public string Test1() - { - return "Test1"; - } - - public string Test2() - { - return "Test2"; - } - } - - public void Test_VarArgs(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - return myobj.format('{0}.{1}@{2}:{3}', 1, 2, 'ciao', true);"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1.2@ciao:True", res.String); - } - - - public void Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode opt) - { - try - { - UserData.UnregisterType(); - - string script = @" - strlist = { 'ciao', 'hello', 'aloha' }; - intlist = { }; - dictry = { ciao = 39, hello = 78, aloha = 128 }; - - x = static.SetComplexTypes(strlist, intlist, dictry, strlist, intlist); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - Script.GlobalOptions.CustomConverters.Clear(); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(List), - v => null); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(IList), - v => new List() { 42, 77, 125, 13 }); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(int[]), - v => new int[] { 43, 78, 126, 14 }); - - Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion( - (_s, v) => DynValue.NewString(v.ToString().ToUpper())); - - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("CIAO,HELLO,ALOHA|42,77,125,13|ALOHA,CIAO,HELLO|39,78,128|CIAO,HELLO,ALOHA|43,78,126,14", res.String); - } - finally - { - Script.GlobalOptions.CustomConverters.Clear(); - } - } - - - public void Test_ConcatMethodStaticComplex(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - strlist = { 'ciao', 'hello', 'aloha' }; - intlist = { 42, 77, 125, 13 }; - dictry = { ciao = 39, hello = 78, aloha = 128 }; - - x = static.SetComplexTypes(strlist, intlist, dictry, strlist, intlist); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("ciao,hello,aloha|42,77,125,13|aloha,ciao,hello|39,78,128|ciao,hello,aloha|42,77,125,13", res.String); - } - - public void Test_ConcatMethodStaticComplexRec(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - array = { { 1, 2, 3 }, { 11, 35, 77 }, { 16, 42, 64 }, {99, 76, 17 } }; - - x = static.SetComplexRecursive(array); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1,2,3|11,35,77|16,42,64|99,76,17|", res.String); - } - - - public void Test_RefOutParams(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - x, y, z = myobj:manipulateString('CiAo', 'hello'); - return x, y, z;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(3, res.Tuple.Length); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual(DataType.String, res.Tuple[1].Type); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("CIAO", res.Tuple[0].String); - Assert.AreEqual("CiAohello", res.Tuple[1].String); - Assert.AreEqual("ciao", res.Tuple[2].String); - } - - - - - public void Test_ConcatMethodStatic(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = static.ConcatS(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1994", res.String); - } - - public void Test_ConcatMethod(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj.ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - public void Test_ConcatMethodSemicolon(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj:ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - public void Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - myobj = mytype.__new(); - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj:ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals["mytype"] = typeof(SomeClass); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - - - public void Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = static.ConcatS(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals["static"] = typeof(SomeClass); - S.Globals["myobj"] = obj; - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1994", res.String); - } - - public void Test_DelegateMethod(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - x = concat(1, 2); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - S.Globals["concat"] = CallbackFunction.FromDelegate(S, (Func)obj.ConcatNums, opt); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1%2", res.String); - } - - public void Test_ListMethod(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - x = mklist(1, 4); - sum = 0; - - for _, v in ipairs(x) do - sum = sum + v; - end - - return sum;"; - - Script S = new Script(); - - SomeClass_NoRegister obj = new SomeClass_NoRegister(); - - S.Globals["mklist"] = CallbackFunction.FromDelegate(S, (Func>)obj.MkList, opt); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - - [Test] - public void Interop_ConcatMethod_None() - { - Test_ConcatMethod(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethod_Lazy() - { - Test_ConcatMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethod_Precomputed() - { - Test_ConcatMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ConcatMethodSemicolon_None() - { - Test_ConcatMethodSemicolon(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodSemicolon_Lazy() - { - Test_ConcatMethodSemicolon(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodSemicolon_Precomputed() - { - Test_ConcatMethodSemicolon(InteropAccessMode.Preoptimized); - } - - - [Test] - public void Interop_ConstructorAndConcatMethodSemicolon_None() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConstructorAndConcatMethodSemicolon_Lazy() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConstructorAndConcatMethodSemicolon_Precomputed() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplxCustomConv_None() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodStaticCplxCustomConv_Lazy() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplxCustomConv_Precomputed() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplx_None() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodStaticCplx_Lazy() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplx_Precomputed() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplxRec_None() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodStaticCplxRec_Lazy() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodStaticCplxRec_Precomputed() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ConcatMethodStatic_None() - { - Test_ConcatMethodStatic(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodStatic_Lazy() - { - Test_ConcatMethodStatic(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodStatic_Precomputed() - { - Test_ConcatMethodStatic(InteropAccessMode.Preoptimized); - } - - - [Test] - public void Interop_ConcatMethodStaticSimplifiedSyntax_None() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ConcatMethodStaticSimplifiedSyntax_Lazy() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ConcatMethodStaticSimplifiedSyntax_Precomputed() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_VarArgs_None() - { - Test_VarArgs(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_VarArgs_Lazy() - { - Test_VarArgs(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_VarArgs_Precomputed() - { - Test_VarArgs(InteropAccessMode.Preoptimized); - } - - - [Test] - public void Interop_DelegateMethod_None() - { - Test_DelegateMethod(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_DelegateMethod_Lazy() - { - Test_DelegateMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_DelegateMethod_Precomputed() - { - Test_DelegateMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_OutRefParams_None() - { - Test_RefOutParams(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_OutRefParams_Lazy() - { - Test_RefOutParams(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_OutRefParams_Precomputed() - { - Test_RefOutParams(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ListMethod_None() - { - Test_ListMethod(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ListMethod_Lazy() - { - Test_ListMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ListMethod_Precomputed() - { - Test_ListMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_TestAutoregisterPolicy() - { - var oldPolicy = UserData.RegistrationPolicy; - - try - { - string script = @"return myobj:Test1()"; - - UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; - - Script S = new Script(); - - SomeOtherClass obj = new SomeOtherClass(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Test1", res.String); - } - finally - { - UserData.RegistrationPolicy = oldPolicy; - } - } - - [Test] - public void Interop_DualInterfaces() - { - string script = @"return myobj:Test1() .. myobj:Test2()"; - - Script S = new Script(); - - UserData.UnregisterType(); - UserData.UnregisterType(); - UserData.RegisterType(); - UserData.RegisterType(); - - SomeOtherClassWithDualInterfaces obj = new SomeOtherClassWithDualInterfaces(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Test1Test2", res.String); - } - - [Test] - public void Interop_TestNamesCamelized() - { - UserData.UnregisterType(); - - string script = @" - a = myobj:SomeMethodWithLongName(1); - b = myobj:someMethodWithLongName(2); - c = myobj:some_method_with_long_name(3); - d = myobj:Some_method_withLong_name(4); - - return a + b + c + d; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(20, res.Number); - - } - - [Test] - public void Interop_TestSelfDescribingType() - { - UserData.UnregisterType(); - - string script = @" - a = myobj[1]; - b = myobj[2]; - c = myobj[3]; - - return a + b + c; - "; - - Script S = new Script(); - - SelfDescribingClass obj = new SelfDescribingClass(); - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(18, res.Number); - } - - [Test] - public void Interop_TestCustomDescribedType() - { - UserData.UnregisterType(); - - string script = @" - a = myobj[1]; - b = myobj[2]; - c = myobj[3]; - - return a + b + c; - "; - - Script S = new Script(); - - SomeOtherClassCustomDescriptor obj = new SomeOtherClassCustomDescriptor(); - - UserData.RegisterType(new CustomDescriptor()); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(24, res.Number); - } - - - [Test] - public void Interop_StaticInstanceAccessRaisesError() - { - try - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = mystatic.ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals.Set("mystatic", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.Fail(); - } - catch (Exception ex) - { - Assert.IsTrue(ex.Message.Contains("attempt to access instance member")); - } - } - - } -} - diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataNestedTypesTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataNestedTypesTests.cs deleted file mode 100644 index c5755854..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataNestedTypesTests.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class UserDataNestedTypesTests - { - public class SomeType - { - public enum SomeNestedEnum - { - Asdasdasd, - } - - public static SomeNestedEnum Get() - { - return SomeNestedEnum.Asdasdasd; - } - - public class SomeNestedType - { - public static string Get() - { - return "Ciao from SomeNestedType"; - } - } - - [MoonSharpUserData] - private class SomeNestedTypePrivate - { - public static string Get() - { - return "Ciao from SomeNestedTypePrivate"; - } - } - - private class SomeNestedTypePrivate2 - { - public static string Get() - { - return "Ciao from SomeNestedTypePrivate2"; - } - } - - } - - public struct VSomeType - { - public struct SomeNestedType - { - public static string Get() - { - return "Ciao from SomeNestedType"; - } - } - - [MoonSharpUserData] - private struct SomeNestedTypePrivate - { - public static string Get() - { - return "Ciao from SomeNestedTypePrivate"; - } - } - - private struct SomeNestedTypePrivate2 - { - public static string Get() - { - return "Ciao from SomeNestedTypePrivate2"; - } - } - - } - - [Test] - public void Interop_NestedTypes_Public_Enum() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o:Get()"); - - Assert.AreEqual(DataType.UserData, res.Type); - } - - - [Test] - public void Interop_NestedTypes_Public_Ref() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedType:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedType", res.String); - } - - - [Test] - public void Interop_NestedTypes_Private_Ref() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedTypePrivate:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedTypePrivate", res.String); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_NestedTypes_Private_Ref_2() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedTypePrivate2:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedTypePrivate2", res.String); - } - - [Test] - public void Interop_NestedTypes_Public_Val() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedType:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedType", res.String); - } - - - [Test] - public void Interop_NestedTypes_Private_Val() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedTypePrivate:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedTypePrivate", res.String); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_NestedTypes_Private_Val_2() - { - Script S = new Script(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.CreateStatic()); - - DynValue res = S.DoString("return o.SomeNestedTypePrivate2:Get()"); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Ciao from SomeNestedTypePrivate2", res.String); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataOverloadsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataOverloadsTests.cs deleted file mode 100755 index d55b5b9e..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataOverloadsTests.cs +++ /dev/null @@ -1,326 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop; -using MoonSharp.Interpreter.Loaders; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - public static class OverloadsExtMethods - { - public static string Method1(this UserDataOverloadsTests.OverloadsTestClass obj, string x, bool b) - { - return "X" + obj.Method1(); - } - - public static string Method3(this UserDataOverloadsTests.OverloadsTestClass obj) - { - obj.Method1(); - return "X3"; - } - } - public static class OverloadsExtMethods2 - { - public static string MethodXXX(this UserDataOverloadsTests.OverloadsTestClass obj, string x, bool b) - { - return "X!"; - } - } - - - [TestFixture] - public class UserDataOverloadsTests - { - public class OverloadsTestClass - { - public string MethodV(string fmt, params object[] args) - { - return "varargs:" + string.Format(fmt, args); - } - - public string MethodV(string fmt, int a, bool b) - { - return "exact:" + string.Format(fmt, a, b); - } - - public string Method1() - { - return "1"; - } - - public static string Method1(bool b) - { - return "s"; - } - - public string Method1(int a) - { - return "2"; - } - - public string Method1(double d) - { - return "3"; - } - - public string Method1(double d, string x = null) - { - return "4"; - } - - public string Method1(double d, string x, int y = 5) - { - return "5"; - } - - public string Method2(string x, string y) - { - return "v"; - } - - public string Method2(string x, ref string y) - { - return "r"; - } - - public string Method2(string x, ref string y, int z) - { - return "R"; - } - } - - private void RunTestOverload(string code, string expected, bool tupleExpected = false) - { - Script S = new Script(); - - OverloadsTestClass obj = new OverloadsTestClass(); - - UserData.RegisterType(); - - S.Globals.Set("s", UserData.CreateStatic()); - S.Globals.Set("o", UserData.Create(obj)); - - DynValue v = S.DoString("return " + code); - - if (tupleExpected) - { - Assert.AreEqual(DataType.Tuple, v.Type); - v = v.Tuple[0]; - } - - Assert.AreEqual(DataType.String, v.Type); - Assert.AreEqual(expected, v.String); - } - - - [Test] - public void Interop_OutParamInOverloadResolution() - { - UserData.RegisterType>(); - UserData.RegisterExtensionType(typeof(OverloadsExtMethods)); - - try - { - var lua = new Script(); - lua.Globals["DictionaryIntInt"] = typeof(Dictionary); - - var script = @"local dict = DictionaryIntInt.__new(); local res, v = dict.TryGetValue(0)"; - lua.DoString(script); - lua.DoString(script); - } - finally - { - UserData.UnregisterType>(); - } - } - - [Test] - public void Interop_Overloads_Varargs1() - { - RunTestOverload("o:methodV('{0}-{1}', 15, true)", "exact:15-True"); - } - - [Test] - public void Interop_Overloads_Varargs2() - { - RunTestOverload("o:methodV('{0}-{1}-{2}', 15, true, false)", "varargs:15-True-False"); - } - - - [Test] - public void Interop_Overloads_ByRef() - { - RunTestOverload("o:method2('x', 'y')", "v"); - } - - [Test] - public void Interop_Overloads_ByRef2() - { - RunTestOverload("o:method2('x', 'y', 5)", "R", true); - } - - [Test] - public void Interop_Overloads_NoParams() - { - RunTestOverload("o:method1()", "1"); - } - - [Test] - public void Interop_Overloads_NumDowncast() - { - RunTestOverload("o:method1(5)", "3"); - } - - [Test] - public void Interop_Overloads_NilSelectsNonOptional() - { - RunTestOverload("o:method1(5, nil)", "4"); - } - - [Test] - public void Interop_Overloads_FullDecl() - { - RunTestOverload("o:method1(5, nil, 0)", "5"); - } - - [Test] - public void Interop_Overloads_Static1() - { - RunTestOverload("s:method1(true)", "s"); - } - - [Test] - public void Interop_Overloads_ExtMethods() - { - UserData.RegisterExtensionType(typeof(OverloadsExtMethods)); - - RunTestOverload("o:method1('xx', true)", "X1"); - RunTestOverload("o:method3()", "X3"); - } - - [Test] - public void Interop_Overloads_Twice_ExtMethods1() - { - UserData.RegisterExtensionType(typeof(OverloadsExtMethods)); - - RunTestOverload("o:method1('xx', true)", "X1"); - - UserData.RegisterExtensionType(typeof(OverloadsExtMethods2)); - - RunTestOverload("o:methodXXX('xx', true)", "X!"); - } - - [Test] - public void Interop_Overloads_Twice_ExtMethods2() - { - UserData.RegisterExtensionType(typeof(OverloadsExtMethods)); - UserData.RegisterExtensionType(typeof(OverloadsExtMethods2)); - - RunTestOverload("o:method1('xx', true)", "X1"); - RunTestOverload("o:methodXXX('xx', true)", "X!"); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_Overloads_ExtMethods2() - { - UserData.RegisterExtensionType(typeof(OverloadsExtMethods)); - RunTestOverload("s:method3()", "X3"); - } - - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_Overloads_Static2() - { - // pollute cache - RunTestOverload("o:method1(5)", "3"); - // exec non static on static - RunTestOverload("s:method1(5)", "s"); - } - - [Test] - public void Interop_Overloads_Cache1() - { - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - } - - [Test] - public void Interop_Overloads_Cache2() - { - RunTestOverload("o:method1()", "1"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, nil)", "4"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5, 'x')", "4"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 'x', 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 5)", "4"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 5, 0)", "5"); - RunTestOverload("s:method1(true)", "s"); - } - - private int Method1() - { - return 1; - } - - private int Method1(int a) - { - return 5 + a; - } - -#if !DOTNET_CORE - [Test] - public void OverloadTest_WithoutObjects() - { - Script s = new Script(); - - // Create an instance of the overload resolver - var ov = new OverloadedMethodMemberDescriptor("Method1", this.GetType()); - - // Iterate over the two methods through reflection - foreach(var method in Framework.Do.GetMethods(this.GetType()) - .Where(mi => mi.Name == "Method1" && mi.IsPrivate && !mi.IsStatic)) - { - ov.AddOverload(new MethodMemberDescriptor(method)); - } - - // Creates the callback over the 'this' object - DynValue callback = DynValue.NewCallback(ov.GetCallbackFunction(s, this)); - s.Globals.Set("func", callback); - - // Execute and check the results. - DynValue result = s.DoString("return func(), func(17)"); - - Assert.AreEqual(DataType.Tuple, result.Type); - Assert.AreEqual(DataType.Number, result.Tuple[0].Type); - Assert.AreEqual(DataType.Number, result.Tuple[1].Type); - Assert.AreEqual(1, result.Tuple[0].Number); - Assert.AreEqual(22, result.Tuple[1].Number); - } -#endif - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataPropertiesTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataPropertiesTests.cs deleted file mode 100644 index 7a84aa72..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataPropertiesTests.cs +++ /dev/null @@ -1,865 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class UserDataPropertiesTests - { - public class SomeClass - { - public int IntProp { get; set; } - public int? NIntProp { get; set; } - public object ObjProp { get; set; } - public static string StaticProp { get; set; } - - public int RoIntProp { get { return 5; } } - public int RoIntProp2 { get; private set; } - - public int WoIntProp { set { IntProp = value; } } - public int WoIntProp2 { internal get; set; } - - [MoonSharpVisible(false)] - internal int AccessOverrProp - { - get; - [MoonSharpVisible(true)] - set; - } - - - public SomeClass() - { - RoIntProp2 = 1234; - WoIntProp2 = 1235; - } - - public static IEnumerable Numbers - { - get - { - for (int i = 1; i <= 4; i++) - yield return i; - } - } - } - - public void Test_IntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.IntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(321, res.Number); - } - - public void Test_NIntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.NIntProp; - y = myobj2.NIntProp; - return x,y;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(321.0, res.Tuple[0].Number); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Nil, res.Tuple[1].Type); - } - - public void Test_ObjPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.ObjProp; - y = myobj2.ObjProp; - z = myobj2.ObjProp.ObjProp; - return x,y,z;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual("ciao", res.Tuple[0].String); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("ciao", res.Tuple[2].String); - Assert.AreEqual(DataType.UserData, res.Tuple[1].Type); - Assert.AreEqual(obj1, res.Tuple[1].UserData.Object); - } - - public void Test_IntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = 19;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_NIntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj1.NIntProp = nil; - myobj2.NIntProp = 19;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual(321, obj1.NIntProp); - Assert.AreEqual(null, obj2.NIntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(null, obj1.NIntProp); - Assert.AreEqual(19, obj2.NIntProp); - } - - public void Test_ObjPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj1.ObjProp = myobj2; - myobj2.ObjProp = 'hello';"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual("ciao", obj1.ObjProp); - Assert.AreEqual(obj1, obj2.ObjProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(obj2, obj1.ObjProp); - Assert.AreEqual("hello", obj2.ObjProp); - } - - public void Test_InvalidPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = '19';"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_StaticPropertyAccess(InteropAccessMode opt) - { - string script = @" - static.StaticProp = 'asdasd' .. static.StaticProp;"; - - Script S = new Script(); - - SomeClass.StaticProp = "qweqwe"; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - - Assert.AreEqual("qweqwe", SomeClass.StaticProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual("asdasdqweqwe", SomeClass.StaticProp); - } - - public void Test_IteratorPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = 0; - for i in myobj.Numbers do - x = x + i; - end - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - public void Test_RoIntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.RoIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(5, res.Number); - } - - public void Test_RoIntProperty2Getter(InteropAccessMode opt) - { - string script = @" - x = myobj.RoIntProp2; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234, res.Number); - } - - public void Test_RoIntPropertySetter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.RoIntProp = 19; - return myobj.RoIntProp; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - public void Test_RoIntProperty2Setter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.RoIntProp2 = 19; - return myobj.RoIntProp2; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - public void Test_WoIntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.WoIntProp = 19; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_WoIntProperty2Setter(InteropAccessMode opt) - { - string script = @" - myobj.WoIntProp2 = 19; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.WoIntProp2); - } - - - public void Test_WoIntPropertyGetter(InteropAccessMode opt) - { - try - { - string script = @" - x = myobj.WoIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(5, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - public void Test_WoIntProperty2Getter(InteropAccessMode opt) - { - try - { - string script = @" - x = myobj.WoIntProp2; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - public void Test_PropertyAccessOverrides(InteropAccessMode opt) - { - SomeClass obj = new SomeClass(); - - try - { - string script = @" - myobj.AccessOverrProp = 19; - return myobj.AccessOverrProp; - "; - - Script S = new Script(); - - obj.AccessOverrProp = 13; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - Assert.AreEqual(19, obj.AccessOverrProp); - return; - } - - Assert.Fail(); - } - - - [Test] - public void Interop_IntPropertyGetter_None() - { - Test_IntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_IntPropertyGetter_Lazy() - { - Test_IntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_IntPropertyGetter_Precomputed() - { - Test_IntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_NIntPropertyGetter_None() - { - Test_NIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_NIntPropertyGetter_Lazy() - { - Test_NIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_NIntPropertyGetter_Precomputed() - { - Test_NIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ObjPropertyGetter_None() - { - Test_ObjPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ObjPropertyGetter_Lazy() - { - Test_ObjPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ObjPropertyGetter_Precomputed() - { - Test_ObjPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_IntPropertySetter_None() - { - Test_IntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_IntPropertySetter_Lazy() - { - Test_IntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_IntPropertySetter_Precomputed() - { - Test_IntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_NIntPropertySetter_None() - { - Test_NIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_NIntPropertySetter_Lazy() - { - Test_NIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_NIntPropertySetter_Precomputed() - { - Test_NIntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_ObjPropertySetter_None() - { - Test_ObjPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_ObjPropertySetter_Lazy() - { - Test_ObjPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_ObjPropertySetter_Precomputed() - { - Test_ObjPropertySetter(InteropAccessMode.Preoptimized); - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidPropertySetter_None() - { - Test_InvalidPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidPropertySetter_Lazy() - { - Test_InvalidPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void Interop_InvalidPropertySetter_Precomputed() - { - Test_InvalidPropertySetter(InteropAccessMode.Preoptimized); - } - - - [Test] - public void Interop_StaticPropertyAccess_None() - { - Test_StaticPropertyAccess(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_StaticPropertyAccess_Lazy() - { - Test_StaticPropertyAccess(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_StaticPropertyAccess_Precomputed() - { - Test_StaticPropertyAccess(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_IteratorPropertyGetter_None() - { - Test_IteratorPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_IteratorPropertyGetter_Lazy() - { - Test_IteratorPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_IteratorPropertyGetter_Precomputed() - { - Test_IteratorPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_RoIntPropertyGetter_None() - { - Test_RoIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_RoIntPropertyGetter_Lazy() - { - Test_RoIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_RoIntPropertyGetter_Precomputed() - { - Test_RoIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_RoIntProperty2Getter_None() - { - Test_RoIntProperty2Getter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_RoIntProperty2Getter_Lazy() - { - Test_RoIntProperty2Getter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_RoIntProperty2Getter_Precomputed() - { - Test_RoIntProperty2Getter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_RoIntPropertySetter_None() - { - Test_RoIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_RoIntPropertySetter_Lazy() - { - Test_RoIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_RoIntPropertySetter_Precomputed() - { - Test_RoIntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_RoIntProperty2Setter_None() - { - Test_RoIntProperty2Setter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_RoIntProperty2Setter_Lazy() - { - Test_RoIntProperty2Setter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_RoIntProperty2Setter_Precomputed() - { - Test_RoIntProperty2Setter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_WoIntPropertyGetter_None() - { - Test_WoIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_WoIntPropertyGetter_Lazy() - { - Test_WoIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_WoIntPropertyGetter_Precomputed() - { - Test_WoIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_WoIntProperty2Getter_None() - { - Test_WoIntProperty2Getter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_WoIntProperty2Getter_Lazy() - { - Test_WoIntProperty2Getter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_WoIntProperty2Getter_Precomputed() - { - Test_WoIntProperty2Getter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_WoIntPropertySetter_None() - { - Test_WoIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_WoIntPropertySetter_Lazy() - { - Test_WoIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_WoIntPropertySetter_Precomputed() - { - Test_WoIntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_WoIntProperty2Setter_None() - { - Test_WoIntProperty2Setter(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_WoIntProperty2Setter_Lazy() - { - Test_WoIntProperty2Setter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_WoIntProperty2Setter_Precomputed() - { - Test_WoIntProperty2Setter(InteropAccessMode.Preoptimized); - } - - [Test] - public void Interop_PropertyAccessOverrides_None() - { - Test_PropertyAccessOverrides(InteropAccessMode.Reflection); - } - - [Test] - public void Interop_PropertyAccessOverrides_Lazy() - { - Test_PropertyAccessOverrides(InteropAccessMode.LazyOptimized); - } - - [Test] - public void Interop_PropertyAccessOverrides_Precomputed() - { - Test_PropertyAccessOverrides(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void Interop_IntPropertySetterWithSimplifiedSyntax() - { - string script = @" - myobj.IntProp = 19;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals["myobj"] = obj; - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(obj, S.Globals["myobj"]); - Assert.AreEqual(19, obj.IntProp); - } - - [Test] - public void Interop_OutOfRangeNumber() - { - Script s = new Script(); - long big = long.MaxValue; - var v = DynValue.FromObject(s, big); - Assert.IsNotNull(v); - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataFieldsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataFieldsTests.cs deleted file mode 100644 index 127bd447..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataFieldsTests.cs +++ /dev/null @@ -1,470 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ -#pragma warning disable 169 // unused private field - - [TestFixture] - public class VtUserDataFieldsTests - { - public struct SomeClass - { - public int IntProp; - public const int ConstIntProp = 115; - public int? NIntProp; - public object ObjProp; - public static string StaticProp; - private string PrivateProp; - } - - public void Test_ConstIntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.ConstIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(115, res.Number); - } - - public void Test_ConstIntFieldSetter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.ConstIntProp = 1; - return myobj.ConstIntProp;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(115, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - - - public void Test_IntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.IntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(321, res.Number); - } - - public void Test_NIntFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.NIntProp; - y = myobj2.NIntProp; - return x,y;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(321.0, res.Tuple[0].Number); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Nil, res.Tuple[1].Type); - } - - public void Test_ObjFieldGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.ObjProp; - y = myobj2.ObjProp; - z = myobj2.ObjProp.ObjProp; - return x,y,z;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual("ciao", res.Tuple[0].String); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("ciao", res.Tuple[2].String); - Assert.AreEqual(DataType.UserData, res.Tuple[1].Type); - Assert.AreEqual(obj1, res.Tuple[1].UserData.Object); - } - - public void Test_IntFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = 19; - return myobj.IntProp; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - - // right! because value types do not change.. - Assert.AreEqual(321, obj.IntProp); - } - - public void Test_NIntFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj1.NIntProp = nil; - myobj2.NIntProp = 19; - return myobj1.NIntProp, myobj2.NIntProp; - "; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual(321, obj1.NIntProp); - Assert.AreEqual(null, obj2.NIntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(19, res.Tuple[1].Number); - - // again.. are structs so the originals won't change - Assert.AreEqual(321, obj1.NIntProp); - Assert.AreEqual(null, obj2.NIntProp); - } - - - public void Test_InvalidFieldSetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = '19';"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_StaticFieldAccess(InteropAccessMode opt) - { - string script = @" - static.StaticProp = 'asdasd' .. static.StaticProp;"; - - Script S = new Script(); - - SomeClass.StaticProp = "qweqwe"; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - - Assert.AreEqual("qweqwe", SomeClass.StaticProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual("asdasdqweqwe", SomeClass.StaticProp); - } - - [Test] - public void VInterop_IntFieldGetter_None() - { - Test_IntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_IntFieldGetter_Lazy() - { - Test_IntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_IntFieldGetter_Precomputed() - { - Test_IntFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_NIntFieldGetter_None() - { - Test_NIntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_NIntFieldGetter_Lazy() - { - Test_NIntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_NIntFieldGetter_Precomputed() - { - Test_NIntFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ObjFieldGetter_None() - { - Test_ObjFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ObjFieldGetter_Lazy() - { - Test_ObjFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ObjFieldGetter_Precomputed() - { - Test_ObjFieldGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_IntFieldSetter_None() - { - Test_IntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_IntFieldSetter_Lazy() - { - Test_IntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_IntFieldSetter_Precomputed() - { - Test_IntFieldSetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_NIntFieldSetter_None() - { - Test_NIntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_NIntFieldSetter_Lazy() - { - Test_NIntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_NIntFieldSetter_Precomputed() - { - Test_NIntFieldSetter(InteropAccessMode.Preoptimized); - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidFieldSetter_None() - { - Test_InvalidFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidFieldSetter_Lazy() - { - Test_InvalidFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidFieldSetter_Precomputed() - { - Test_InvalidFieldSetter(InteropAccessMode.Preoptimized); - } - - - [Test] - public void VInterop_StaticFieldAccess_None() - { - Test_StaticFieldAccess(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_StaticFieldAccess_Lazy() - { - Test_StaticFieldAccess(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_StaticFieldAccess_Precomputed() - { - Test_StaticFieldAccess(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void VInterop_IntFieldSetterWithSimplifiedSyntax() - { - string script = @" - myobj.IntProp = 19; - return myobj.IntProp; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals["myobj"] = obj; - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - - // expected behaviour - Assert.AreEqual(321, obj.IntProp); - } - - - - - [Test] - public void VInterop_ConstIntFieldGetter_None() - { - Test_ConstIntFieldGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConstIntFieldGetter_Lazy() - { - Test_ConstIntFieldGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConstIntFieldGetter_Precomputed() - { - Test_ConstIntFieldGetter(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void VInterop_ConstIntFieldSetter_None() - { - Test_ConstIntFieldSetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConstIntFieldSetter_Lazy() - { - Test_ConstIntFieldSetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConstIntFieldSetter_Precomputed() - { - Test_ConstIntFieldSetter(InteropAccessMode.Preoptimized); - } - - - - - - - - - - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataIndexerTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataIndexerTests.cs deleted file mode 100644 index 160e469a..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataIndexerTests.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class VtUserDataIndexerTests - { - public struct IndexerTestClass - { - public Dictionary mymap; - - public int this[int idx] - { - get { return mymap[idx]; } - set { mymap[idx] = value; } - } - - public int this[int idx1, int idx2, int idx3] - { - get { int idx = (idx1 + idx2) * idx3; return mymap[idx]; } - set { int idx = (idx1 + idx2) * idx3; mymap[idx] = value; } - } - } - - private void IndexerTest(string code, int expected) - { - Script S = new Script(); - - IndexerTestClass obj = new IndexerTestClass(); - obj.mymap = new Dictionary(); - - UserData.RegisterType(); - - S.Globals.Set("o", UserData.Create(obj)); - - DynValue v = S.DoString(code); - - Assert.AreEqual(DataType.Number, v.Type); - Assert.AreEqual(expected, v.Number); - } - - [Test] - public void VInterop_SingleSetterOnly() - { - string script = @"o[1] = 1; return 13"; - IndexerTest(script, 13); - } - - - [Test] - public void VInterop_SingleIndexerGetSet() - { - string script = @"o[5] = 19; return o[5];"; - IndexerTest(script, 19); - } - - [Test] - public void VInterop_MultiIndexerGetSet() - { - string script = @"o[1,2,3] = 47; return o[1,2,3];"; - IndexerTest(script, 47); - } - - [Test] - public void VInterop_MultiIndexerMetatableGetSet() - { - string script = @" - m = { - __index = o, - __newindex = o - } - - t = { } - - setmetatable(t, m); - - t[10,11,12] = 1234; return t[10,11,12];"; - IndexerTest(script, 1234); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_MultiIndexerMetamethodGetSet() - { - string script = @" - m = { - __index = function() end, - __newindex = function() end - } - - t = { } - - setmetatable(t, m); - - t[10,11,12] = 1234; return t[10,11,12];"; - IndexerTest(script, 1234); - } - - - - - - [Test] - public void VInterop_MixedIndexerGetSet() - { - string script = @"o[3,2,3] = 119; return o[15];"; - IndexerTest(script, 119); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_ExpListIndexingCompilesButNotRun1() - { - string script = @" - x = { 99, 98, 97, 96 } - return x[2,3]; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(98, res.Number); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_ExpListIndexingCompilesButNotRun2() - { - string script = @" - x = { 99, 98, 97, 96 } - x[2,3] = 5; - "; - - DynValue res = Script.RunString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(98, res.Number); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataMethodsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataMethodsTests.cs deleted file mode 100755 index 856e2d16..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataMethodsTests.cs +++ /dev/null @@ -1,1041 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class VtUserDataMethodsTests - { - public struct SomeClass_NoRegister : IComparable - { - public string ManipulateString(string input, ref string tobeconcat, out string lowercase) - { - tobeconcat = input + tobeconcat; - lowercase = input.ToLower(); - return input.ToUpper(); - } - - public string ConcatNums(int p1, int p2) - { - return string.Format("{0}%{1}", p1, p2); - } - - public int SomeMethodWithLongName(int i) - { - return i * 2; - } - - public static StringBuilder SetComplexRecursive(List intList) - { - StringBuilder sb = new StringBuilder(); - - foreach (int[] arr in intList) - { - sb.Append(string.Join(",", arr.Select(s => s.ToString()).ToArray())); - sb.Append("|"); - } - - return sb; - } - - public static StringBuilder SetComplexTypes(List strlist, IList intlist, Dictionary map, - string[] strarray, int[] intarray) - { - StringBuilder sb = new StringBuilder(); - - sb.Append(string.Join(",", strlist.ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", intlist.Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Values.OrderBy(x => x).Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", strarray)); - - sb.Append("|"); - - sb.Append(string.Join(",", intarray.Select(i => i.ToString()).ToArray())); - - return sb; - } - - - public static StringBuilder ConcatS(int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass_NoRegister p9, int p10 = 1994) - { - p7.Append(p1); - p7.Append(p2); - p7.Append(p3); - p7.Append(p4); - - p7.Append("|"); - foreach (var o in p5) p7.Append(o); - p7.Append("|"); - foreach (var o in p6) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - - p7.Append(p9); - p7.Append(p10); - - return p7; - } - - public string Format(string s, params object[] args) - { - return string.Format(s, args); - } - - public StringBuilder ConcatI(Script s, int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass_NoRegister p9, int p10 = 1912) - { - Assert.IsNotNull(s); - return ConcatS(p1, p2, p3, p4, p5, p6, p7, p8, this, p10); - } - - public override string ToString() - { - return "!SOMECLASS!"; - } - - public List MkList(int from, int to) - { - List l = new List(); - for (int i = from; i <= to; i++) - l.Add(i); - return l; - } - - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - } - - public struct SomeClass : IComparable - { - public string ManipulateString(string input, ref string tobeconcat, out string lowercase) - { - tobeconcat = input + tobeconcat; - lowercase = input.ToLower(); - return input.ToUpper(); - } - - public string ConcatNums(int p1, int p2) - { - return string.Format("{0}%{1}", p1, p2); - } - - public int SomeMethodWithLongName(int i) - { - return i * 2; - } - - public static StringBuilder SetComplexRecursive(List intList) - { - StringBuilder sb = new StringBuilder(); - - foreach (int[] arr in intList) - { - sb.Append(string.Join(",", arr.Select(s => s.ToString()).ToArray())); - sb.Append("|"); - } - - return sb; - } - - public static StringBuilder SetComplexTypes(List strlist, IList intlist, Dictionary map, - string[] strarray, int[] intarray) - { - StringBuilder sb = new StringBuilder(); - - sb.Append(string.Join(",", strlist.ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", intlist.Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Keys.OrderBy(x => x.ToUpperInvariant()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", map.Values.OrderBy(x => x).Select(i => i.ToString()).ToArray())); - - sb.Append("|"); - - sb.Append(string.Join(",", strarray)); - - sb.Append("|"); - - sb.Append(string.Join(",", intarray.Select(i => i.ToString()).ToArray())); - - return sb; - } - - - public static StringBuilder ConcatS(int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass p9, int p10 = 1994) - { - p7.Append(p1); - p7.Append(p2); - p7.Append(p3); - p7.Append(p4); - - p7.Append("|"); - foreach (var o in p5) p7.Append(o); - p7.Append("|"); - foreach (var o in p6) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Keys.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - foreach (var o in p8.Values.OrderBy(x => x.ToString().ToUpperInvariant())) p7.Append(o); - p7.Append("|"); - - p7.Append(p9); - p7.Append(p10); - - return p7; - } - - public string Format(string s, params object[] args) - { - return string.Format(s, args); - } - - public StringBuilder ConcatI(Script s, int p1, string p2, IComparable p3, bool p4, List p5, IEnumerable p6, - StringBuilder p7, Dictionary p8, SomeClass p9, int p10 = 1912) - { - Assert.IsNotNull(s); - return ConcatS(p1, p2, p3, p4, p5, p6, p7, p8, this, p10); - } - - public override string ToString() - { - return "!SOMECLASS!"; - } - - public List MkList(int from, int to) - { - List l = new List(); - for (int i = from; i <= to; i++) - l.Add(i); - return l; - } - - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - } - - public interface Interface1 - { - string Test1(); - } - - public interface Interface2 - { - string Test2(); - } - - - public class SomeOtherClass - { - public string Test1() - { - return "Test1"; - } - - public string Test2() - { - return "Test2"; - } - } - - - public struct SomeOtherClassCustomDescriptor - { - } - - public struct CustomDescriptor : IUserDataDescriptor - { - public string Name - { - get { return "ciao"; } - } - - public Type Type - { - get { return typeof(SomeOtherClassCustomDescriptor); } - } - - public DynValue Index(Script script, object obj, DynValue index, bool dummy) - { - return DynValue.NewNumber(index.Number * 4); - } - - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool dummy) - { - throw new NotImplementedException(); - } - - public string AsString(object obj) - { - return null; - } - - public DynValue MetaIndex(Script script, object obj, string metaname) - { - return null; - } - - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } - - - - - public struct SelfDescribingClass : IUserDataType - { - public DynValue Index(Script script, DynValue index, bool isNameIndex) - { - return DynValue.NewNumber(index.Number * 3); - } - - public bool SetIndex(Script script, DynValue index, DynValue value, bool isNameIndex) - { - throw new NotImplementedException(); - } - - public DynValue MetaIndex(Script script, string metaname) - { - throw new NotImplementedException(); - } - } - - public struct SomeOtherClassWithDualInterfaces : Interface1, Interface2 - { - public string Test1() - { - return "Test1"; - } - - public string Test2() - { - return "Test2"; - } - } - - public void Test_VarArgs(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - return myobj.format('{0}.{1}@{2}:{3}', 1, 2, 'ciao', true);"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1.2@ciao:True", res.String); - } - - - public void Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode opt) - { - try - { - UserData.UnregisterType(); - - string script = @" - strlist = { 'ciao', 'hello', 'aloha' }; - intlist = { }; - dictry = { ciao = 39, hello = 78, aloha = 128 }; - - x = static.SetComplexTypes(strlist, intlist, dictry, strlist, intlist); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - Script.GlobalOptions.CustomConverters.Clear(); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(List), - v => null); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(IList), - v => new List() { 42, 77, 125, 13 }); - - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(int[]), - v => new int[] { 43, 78, 126, 14 }); - - Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion( - (_s, v) => DynValue.NewString(v.ToString().ToUpper())); - - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("CIAO,HELLO,ALOHA|42,77,125,13|ALOHA,CIAO,HELLO|39,78,128|CIAO,HELLO,ALOHA|43,78,126,14", res.String); - } - finally - { - Script.GlobalOptions.CustomConverters.Clear(); - } - } - - - public void Test_ConcatMethodStaticComplex(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - strlist = { 'ciao', 'hello', 'aloha' }; - intlist = { 42, 77, 125, 13 }; - dictry = { ciao = 39, hello = 78, aloha = 128 }; - - x = static.SetComplexTypes(strlist, intlist, dictry, strlist, intlist); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("ciao,hello,aloha|42,77,125,13|aloha,ciao,hello|39,78,128|ciao,hello,aloha|42,77,125,13", res.String); - } - - public void Test_ConcatMethodStaticComplexRec(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - array = { { 1, 2, 3 }, { 11, 35, 77 }, { 16, 42, 64 }, {99, 76, 17 } }; - - x = static.SetComplexRecursive(array); - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1,2,3|11,35,77|16,42,64|99,76,17|", res.String); - } - - - public void Test_RefOutParams(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - x, y, z = myobj:manipulateString('CiAo', 'hello'); - return x, y, z;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(3, res.Tuple.Length); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual(DataType.String, res.Tuple[1].Type); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("CIAO", res.Tuple[0].String); - Assert.AreEqual("CiAohello", res.Tuple[1].String); - Assert.AreEqual("ciao", res.Tuple[2].String); - } - - - - - public void Test_ConcatMethodStatic(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = static.ConcatS(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1994", res.String); - } - - public void Test_ConcatMethod(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj.ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - public void Test_ConcatMethodSemicolon(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj:ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - public void Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - myobj = mytype.__new(); - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = myobj:ConcatI(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals["mytype"] = typeof(SomeClass); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1912", res.String); - } - - - - public void Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - t = { 'asd', 'qwe', 'zxc', ['x'] = 'X', ['y'] = 'Y' }; - x = static.ConcatS(1, 'ciao', myobj, true, t, t, 'eheh', t, myobj); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals["static"] = typeof(SomeClass); - S.Globals["myobj"] = obj; - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("eheh1ciao!SOMECLASS!True|asdqwezxc|asdqwezxc|123xy|asdqweXYzxc|!SOMECLASS!1994", res.String); - } - - public void Test_DelegateMethod(InteropAccessMode opt) - { - UserData.UnregisterType(); - - string script = @" - x = concat(1, 2); - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - S.Globals["concat"] = CallbackFunction.FromDelegate(S, (Func)obj.ConcatNums, opt); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("1%2", res.String); - } - - public void Test_ListMethod(InteropAccessMode opt) - { - string script = @" - x = mklist(1, 4); - sum = 0; - - for _, v in ipairs(x) do - sum = sum + v; - end - - return sum;"; - - Script S = new Script(); - - SomeClass_NoRegister obj = new SomeClass_NoRegister(); - - S.Globals["mklist"] = CallbackFunction.FromDelegate(S, (Func>)obj.MkList, opt); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - - [Test] - public void VInterop_ConcatMethod_None() - { - Test_ConcatMethod(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethod_Lazy() - { - Test_ConcatMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethod_Precomputed() - { - Test_ConcatMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConcatMethodSemicolon_None() - { - Test_ConcatMethodSemicolon(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodSemicolon_Lazy() - { - Test_ConcatMethodSemicolon(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodSemicolon_Precomputed() - { - Test_ConcatMethodSemicolon(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConstructorAndConcatMethodSemicolon_None() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConstructorAndConcatMethodSemicolon_Lazy() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConstructorAndConcatMethodSemicolon_Precomputed() - { - Test_ConstructorAndConcatMethodSemicolon(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxCustomConv_None() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxCustomConv_Lazy() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxCustomConv_Precomputed() - { - Test_ConcatMethodStaticComplexCustomConv(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplx_None() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodStaticCplx_Lazy() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplx_Precomputed() - { - Test_ConcatMethodStaticComplex(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxRec_None() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxRec_Lazy() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticCplxRec_Precomputed() - { - Test_ConcatMethodStaticComplexRec(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ConcatMethodStatic_None() - { - Test_ConcatMethodStatic(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodStatic_Lazy() - { - Test_ConcatMethodStatic(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodStatic_Precomputed() - { - Test_ConcatMethodStatic(InteropAccessMode.Preoptimized); - } - - - [Test] - public void VInterop_ConcatMethodStaticSimplifiedSyntax_None() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ConcatMethodStaticSimplifiedSyntax_Lazy() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ConcatMethodStaticSimplifiedSyntax_Precomputed() - { - Test_ConcatMethodStaticSimplifiedSyntax(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_VarArgs_None() - { - Test_VarArgs(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_VarArgs_Lazy() - { - Test_VarArgs(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_VarArgs_Precomputed() - { - Test_VarArgs(InteropAccessMode.Preoptimized); - } - - - [Test] - public void VInterop_DelegateMethod_None() - { - Test_DelegateMethod(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_DelegateMethod_Lazy() - { - Test_DelegateMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_DelegateMethod_Precomputed() - { - Test_DelegateMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_OutRefParams_None() - { - Test_RefOutParams(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_OutRefParams_Lazy() - { - Test_RefOutParams(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_OutRefParams_Precomputed() - { - Test_RefOutParams(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ListMethod_None() - { - Test_ListMethod(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ListMethod_Lazy() - { - Test_ListMethod(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ListMethod_Precomputed() - { - Test_ListMethod(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_TestAutoregisterPolicy() - { - var oldPolicy = UserData.RegistrationPolicy; - - try - { - string script = @"return myobj:Test1()"; - - UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; - - Script S = new Script(); - - SomeOtherClass obj = new SomeOtherClass(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Test1", res.String); - } - finally - { - UserData.RegistrationPolicy = oldPolicy; - } - } - - [Test] - public void VInterop_DualInterfaces() - { - string script = @"return myobj:Test1() .. myobj:Test2()"; - - Script S = new Script(); - - UserData.UnregisterType(); - UserData.UnregisterType(); - UserData.RegisterType(); - UserData.RegisterType(); - - SomeOtherClassWithDualInterfaces obj = new SomeOtherClassWithDualInterfaces(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.String, res.Type); - Assert.AreEqual("Test1Test2", res.String); - } - - [Test] - public void VInterop_TestNamesCamelized() - { - UserData.UnregisterType(); - - string script = @" - a = myobj:SomeMethodWithLongName(1); - b = myobj:someMethodWithLongName(2); - c = myobj:some_method_with_long_name(3); - d = myobj:Some_method_withLong_name(4); - - return a + b + c + d; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(20, res.Number); - - } - - [Test] - public void VInterop_TestSelfDescribingType() - { - UserData.UnregisterType(); - - string script = @" - a = myobj[1]; - b = myobj[2]; - c = myobj[3]; - - return a + b + c; - "; - - Script S = new Script(); - - SelfDescribingClass obj = new SelfDescribingClass(); - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(18, res.Number); - } - - [Test] - public void VInterop_TestCustomDescribedType() - { - UserData.UnregisterType(); - - string script = @" - a = myobj[1]; - b = myobj[2]; - c = myobj[3]; - - return a + b + c; - "; - - Script S = new Script(); - - SomeOtherClassCustomDescriptor obj = new SomeOtherClassCustomDescriptor(); - - UserData.RegisterType(new CustomDescriptor()); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(24, res.Number); - } - - } -} - diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataOverloadsTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataOverloadsTests.cs deleted file mode 100755 index f0efa6ae..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataOverloadsTests.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - public static class VtOverloadsExtMethods - { - public static string Method1(this VtUserDataOverloadsTests.OverloadsTestClass obj, string x, bool b) - { - return "X" + obj.Method1(); - } - - public static string Method3(this VtUserDataOverloadsTests.OverloadsTestClass obj) - { - obj.Method1(); - return "X3"; - } - } - - - [TestFixture] - public class VtUserDataOverloadsTests - { - public struct OverloadsTestClass - { - public static void UnCalled() - { - var otc = new OverloadsTestClass(); - otc.Method1(); - OverloadsTestClass.Method1(false); - } - - public string MethodV(string fmt, params object[] args) - { - return "varargs:" + string.Format(fmt, args); - } - - public string MethodV(string fmt, int a, bool b) - { - return "exact:" + string.Format(fmt, a, b); - } - - public string Method1() - { - return "1"; - } - - public static string Method1(bool b) - { - return "s"; - } - - public string Method1(int a) - { - return "2"; - } - - public string Method1(double d) - { - return "3"; - } - - public string Method1(double d, string x = null) - { - return "4"; - } - - public string Method1(double d, string x, int y = 5) - { - return "5"; - } - - public string Method2(string x, string y) - { - return "v"; - } - - public string Method2(string x, ref string y) - { - return "r"; - } - - public string Method2(string x, ref string y, int z) - { - return "R"; - } - } - - private void RunTestOverload(string code, string expected, bool tupleExpected = false) - { - Script S = new Script(); - - OverloadsTestClass obj = new OverloadsTestClass(); - - UserData.RegisterType(); - - S.Globals.Set("s", UserData.CreateStatic()); - S.Globals.Set("o", UserData.Create(obj)); - - DynValue v = S.DoString("return " + code); - - if (tupleExpected) - { - Assert.AreEqual(DataType.Tuple, v.Type); - v = v.Tuple[0]; - } - - Assert.AreEqual(DataType.String, v.Type); - Assert.AreEqual(expected, v.String); - } - - - [Test] - public void VInterop_Overloads_Varargs1() - { - RunTestOverload("o:methodV('{0}-{1}', 15, true)", "exact:15-True"); - } - - [Test] - public void VInterop_Overloads_Varargs2() - { - RunTestOverload("o:methodV('{0}-{1}-{2}', 15, true, false)", "varargs:15-True-False"); - } - - - [Test] - public void VInterop_Overloads_ByRef() - { - RunTestOverload("o:method2('x', 'y')", "v"); - } - - [Test] - public void VInterop_Overloads_ByRef2() - { - RunTestOverload("o:method2('x', 'y', 5)", "R", true); - } - - [Test] - public void VInterop_Overloads_NoParams() - { - RunTestOverload("o:method1()", "1"); - } - - [Test] - public void VInterop_Overloads_NumDowncast() - { - RunTestOverload("o:method1(5)", "3"); - } - - [Test] - public void VInterop_Overloads_NilSelectsNonOptional() - { - RunTestOverload("o:method1(5, nil)", "4"); - } - - [Test] - public void VInterop_Overloads_FullDecl() - { - RunTestOverload("o:method1(5, nil, 0)", "5"); - } - - [Test] - public void VInterop_Overloads_Static1() - { - RunTestOverload("s:method1(true)", "s"); - } - - [Test] - public void VInterop_Overloads_ExtMethods() - { - UserData.RegisterExtensionType(typeof(VtOverloadsExtMethods)); - - RunTestOverload("o:method1('xx', true)", "X1"); - RunTestOverload("o:method3()", "X3"); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_Overloads_ExtMethods2() - { - UserData.RegisterExtensionType(typeof(VtOverloadsExtMethods)); - RunTestOverload("s:method3()", "X3"); - } - - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_Overloads_Static2() - { - // pollute cache - RunTestOverload("o:method1(5)", "3"); - // exec non static on static - RunTestOverload("s:method1(5)", "s"); - } - - [Test] - public void VInterop_Overloads_Cache1() - { - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5)", "3"); - } - - [Test] - public void VInterop_Overloads_Cache2() - { - RunTestOverload("o:method1()", "1"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, nil)", "4"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5, 'x')", "4"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 'x', 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 5)", "4"); - RunTestOverload("o:method1(5, nil, 0)", "5"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("s:method1(true)", "s"); - RunTestOverload("o:method1(5)", "3"); - RunTestOverload("o:method1(5, 5, 0)", "5"); - RunTestOverload("s:method1(true)", "s"); - } - - - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataPropertiesTests.cs b/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataPropertiesTests.cs deleted file mode 100644 index 4677b7e8..00000000 --- a/src/MoonSharp.Interpreter.Tests/EndToEnd/VtUserDataPropertiesTests.cs +++ /dev/null @@ -1,827 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.EndToEnd -{ - [TestFixture] - public class VtUserDataPropertiesTests - { - public struct SomeClass - { - public int IntProp { get; set; } - public int? NIntProp { get; set; } - public object ObjProp { get; set; } - public static string StaticProp { get; set; } - - public int RoIntProp { get { return 5; } } - public int RoIntProp2 { get; internal set; } - - public int WoIntProp { set { IntProp = value; } } - public int WoIntProp2 { internal get; set; } - - public int GetWoIntProp2() { return WoIntProp2; } - - - [MoonSharpVisible(false)] - internal int AccessOverrProp - { - get; - [MoonSharpVisible(true)] - set; - } - - - public static IEnumerable Numbers - { - get - { - for (int i = 1; i <= 4; i++) - yield return i; - } - } - } - - public void Test_IntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.IntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(321, res.Number); - } - - public void Test_NIntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.NIntProp; - y = myobj2.NIntProp; - return x,y;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(321.0, res.Tuple[0].Number); - Assert.AreEqual(DataType.Number, res.Tuple[0].Type); - Assert.AreEqual(DataType.Nil, res.Tuple[1].Type); - } - - public void Test_ObjPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj1.ObjProp; - y = myobj2.ObjProp; - z = myobj2.ObjProp.ObjProp; - return x,y,z;"; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { ObjProp = "ciao" }; - SomeClass obj2 = new SomeClass() { ObjProp = obj1 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Tuple, res.Type); - Assert.AreEqual(DataType.String, res.Tuple[0].Type); - Assert.AreEqual("ciao", res.Tuple[0].String); - Assert.AreEqual(DataType.String, res.Tuple[2].Type); - Assert.AreEqual("ciao", res.Tuple[2].String); - Assert.AreEqual(DataType.UserData, res.Tuple[1].Type); - Assert.AreEqual(obj1, res.Tuple[1].UserData.Object); - } - - public void Test_IntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = 19; - return myobj.IntProp;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - } - - public void Test_NIntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj1.NIntProp = nil; - myobj2.NIntProp = 19; - return myobj1.NIntProp, myobj2.NIntProp - "; - - Script S = new Script(); - - SomeClass obj1 = new SomeClass() { NIntProp = 321 }; - SomeClass obj2 = new SomeClass() { NIntProp = null }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj1", UserData.Create(obj1)); - S.Globals.Set("myobj2", UserData.Create(obj2)); - - Assert.AreEqual(321, obj1.NIntProp); - Assert.AreEqual(null, obj2.NIntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Nil, res.Tuple[0].Type); - Assert.AreEqual(DataType.Number, res.Tuple[1].Type); - Assert.AreEqual(19, res.Tuple[1].Number); - } - - - - public void Test_InvalidPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.IntProp = '19';"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, obj.IntProp); - } - - public void Test_StaticPropertyAccess(InteropAccessMode opt) - { - string script = @" - static.StaticProp = 'asdasd' .. static.StaticProp;"; - - Script S = new Script(); - - SomeClass.StaticProp = "qweqwe"; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("static", UserData.CreateStatic()); - - Assert.AreEqual("qweqwe", SomeClass.StaticProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual("asdasdqweqwe", SomeClass.StaticProp); - } - - public void Test_IteratorPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = 0; - for i in myobj.Numbers do - x = x + i; - end - - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(10, res.Number); - } - - public void Test_RoIntPropertyGetter(InteropAccessMode opt) - { - string script = @" - x = myobj.RoIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(5, res.Number); - } - - public void Test_RoIntProperty2Getter(InteropAccessMode opt) - { - string script = @" - x = myobj.RoIntProp2; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { RoIntProp2 = 1234, WoIntProp2 = 1235 }; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234, res.Number); - } - - public void Test_RoIntPropertySetter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.RoIntProp = 19; - return myobj.RoIntProp; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - public void Test_RoIntProperty2Setter(InteropAccessMode opt) - { - try - { - string script = @" - myobj.RoIntProp2 = 19; - return myobj.RoIntProp2; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - public void Test_WoIntPropertySetter(InteropAccessMode opt) - { - string script = @" - myobj.WoIntProp = 19; - return myobj.IntProp; - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - } - - public void Test_WoIntProperty2Setter(InteropAccessMode opt) - { - string script = @" - myobj.WoIntProp2 = 19; - return myobj.GetWoIntProp2(); - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - } - - - public void Test_WoIntPropertyGetter(InteropAccessMode opt) - { - try - { - string script = @" - x = myobj.WoIntProp; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(5, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - public void Test_WoIntProperty2Getter(InteropAccessMode opt) - { - try - { - string script = @" - x = myobj.WoIntProp2; - return x;"; - - Script S = new Script(); - - SomeClass obj = new SomeClass(); - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - - Assert.AreEqual(DataType.Number, res.Type); - Assert.AreEqual(1234, res.Number); - } - catch (ScriptRuntimeException) - { - return; - } - - Assert.Fail(); - } - - - public void Test_PropertyAccessOverrides(InteropAccessMode opt) - { - SomeClass obj = new SomeClass(); - - try - { - string script = @" - myobj.AccessOverrProp = 19; - return myobj.AccessOverrProp; - "; - - Script S = new Script(); - - obj.AccessOverrProp = 13; - - UserData.UnregisterType(); - UserData.RegisterType(opt); - - S.Globals.Set("myobj", UserData.Create(obj)); - - DynValue res = S.DoString(script); - } - catch (ScriptRuntimeException) - { - // Assert.AreEqual(19, obj.AccessOverrProp); // can't do on value type - return; - } - - Assert.Fail(); - } - - - [Test] - public void VInterop_IntPropertyGetter_None() - { - Test_IntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_IntPropertyGetter_Lazy() - { - Test_IntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_IntPropertyGetter_Precomputed() - { - Test_IntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_NIntPropertyGetter_None() - { - Test_NIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_NIntPropertyGetter_Lazy() - { - Test_NIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_NIntPropertyGetter_Precomputed() - { - Test_NIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_ObjPropertyGetter_None() - { - Test_ObjPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_ObjPropertyGetter_Lazy() - { - Test_ObjPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_ObjPropertyGetter_Precomputed() - { - Test_ObjPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_IntPropertySetter_None() - { - Test_IntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_IntPropertySetter_Lazy() - { - Test_IntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_IntPropertySetter_Precomputed() - { - Test_IntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_NIntPropertySetter_None() - { - Test_NIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_NIntPropertySetter_Lazy() - { - Test_NIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_NIntPropertySetter_Precomputed() - { - Test_NIntPropertySetter(InteropAccessMode.Preoptimized); - } - - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidPropertySetter_None() - { - Test_InvalidPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidPropertySetter_Lazy() - { - Test_InvalidPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - [ExpectedException(typeof(ScriptRuntimeException))] - public void VInterop_InvalidPropertySetter_Precomputed() - { - Test_InvalidPropertySetter(InteropAccessMode.Preoptimized); - } - - - [Test] - public void VInterop_StaticPropertyAccess_None() - { - Test_StaticPropertyAccess(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_StaticPropertyAccess_Lazy() - { - Test_StaticPropertyAccess(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_StaticPropertyAccess_Precomputed() - { - Test_StaticPropertyAccess(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_IteratorPropertyGetter_None() - { - Test_IteratorPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_IteratorPropertyGetter_Lazy() - { - Test_IteratorPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_IteratorPropertyGetter_Precomputed() - { - Test_IteratorPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_RoIntPropertyGetter_None() - { - Test_RoIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_RoIntPropertyGetter_Lazy() - { - Test_RoIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_RoIntPropertyGetter_Precomputed() - { - Test_RoIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_RoIntProperty2Getter_None() - { - Test_RoIntProperty2Getter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_RoIntProperty2Getter_Lazy() - { - Test_RoIntProperty2Getter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_RoIntProperty2Getter_Precomputed() - { - Test_RoIntProperty2Getter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_RoIntPropertySetter_None() - { - Test_RoIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_RoIntPropertySetter_Lazy() - { - Test_RoIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_RoIntPropertySetter_Precomputed() - { - Test_RoIntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_RoIntProperty2Setter_None() - { - Test_RoIntProperty2Setter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_RoIntProperty2Setter_Lazy() - { - Test_RoIntProperty2Setter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_RoIntProperty2Setter_Precomputed() - { - Test_RoIntProperty2Setter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_WoIntPropertyGetter_None() - { - Test_WoIntPropertyGetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_WoIntPropertyGetter_Lazy() - { - Test_WoIntPropertyGetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_WoIntPropertyGetter_Precomputed() - { - Test_WoIntPropertyGetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_WoIntProperty2Getter_None() - { - Test_WoIntProperty2Getter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_WoIntProperty2Getter_Lazy() - { - Test_WoIntProperty2Getter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_WoIntProperty2Getter_Precomputed() - { - Test_WoIntProperty2Getter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_WoIntPropertySetter_None() - { - Test_WoIntPropertySetter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_WoIntPropertySetter_Lazy() - { - Test_WoIntPropertySetter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_WoIntPropertySetter_Precomputed() - { - Test_WoIntPropertySetter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_WoIntProperty2Setter_None() - { - Test_WoIntProperty2Setter(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_WoIntProperty2Setter_Lazy() - { - Test_WoIntProperty2Setter(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_WoIntProperty2Setter_Precomputed() - { - Test_WoIntProperty2Setter(InteropAccessMode.Preoptimized); - } - - [Test] - public void VInterop_PropertyAccessOverrides_None() - { - Test_PropertyAccessOverrides(InteropAccessMode.Reflection); - } - - [Test] - public void VInterop_PropertyAccessOverrides_Lazy() - { - Test_PropertyAccessOverrides(InteropAccessMode.LazyOptimized); - } - - [Test] - public void VInterop_PropertyAccessOverrides_Precomputed() - { - Test_PropertyAccessOverrides(InteropAccessMode.Preoptimized); - } - - - - [Test] - public void VInterop_IntPropertySetterWithSimplifiedSyntax() - { - string script = @" - myobj.IntProp = 19; - return myobj.IntProp - "; - - Script S = new Script(); - - SomeClass obj = new SomeClass() { IntProp = 321 }; - - UserData.UnregisterType(); - UserData.RegisterType(); - - S.Globals["myobj"] = obj; - - Assert.AreEqual(321, obj.IntProp); - - DynValue res = S.DoString(script); - - Assert.AreEqual(19, res.Number); - } - - [Test] - public void VInterop_OutOfRangeNumber() - { - Script s = new Script(); - long big = long.MaxValue; - var v = DynValue.FromObject(s, big); - Assert.IsNotNull(v); - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.csproj.bak b/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.csproj.bak deleted file mode 100644 index fad73c86..00000000 --- a/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.csproj.bak +++ /dev/null @@ -1,119 +0,0 @@ - - - - Debug - AnyCPU - {4AD350E6-E296-43EF-9FEA-CB70358467E4} - Library - Properties - MoonSharp.Interpreter.Tests - MoonSharp.Interpreter.Tests - v3.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - 3.5 - - - - - - - - - - - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter - - - - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 4.5 - true - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.net35-client.csproj b/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.net35-client.csproj deleted file mode 100644 index 3af2831c..00000000 --- a/src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.net35-client.csproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - Debug - AnyCPU - {4AD350E6-E296-43EF-9FEA-CB70358467E4} - Library - Properties - MoonSharp.Interpreter.Tests - MoonSharp.Interpreter.Tests - v3.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - true - ..\keypair.snk - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - true - bin\Dev\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Dev\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Devp4\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 82d2077e..00000000 --- a/src/MoonSharp.Interpreter.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.Tests")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -//[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -//[assembly: Guid("2d45e616-2c1d-4458-b68c-734ef4616028")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Interpreter.Tests/TapRunner.cs b/src/MoonSharp.Interpreter.Tests/TapRunner.cs deleted file mode 100644 index f31dcfd8..00000000 --- a/src/MoonSharp.Interpreter.Tests/TapRunner.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.CoreLib; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Loaders; -using MoonSharp.Interpreter.Platforms; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests -{ -#if !EMBEDTEST - class TestsScriptLoader : ScriptLoaderBase - { - public override bool ScriptFileExists(string name) - { - return File.Exists(name); - } - - public override object LoadFile(string file, Table globalContext) - { - return new FileStream(file, FileMode.Open, FileAccess.Read); - } - } -#endif - - public class TapRunner - { - string m_File; - - /// - /// Prints the specified string. - /// - /// The string. - public void Print(string str) - { - // System.Diagnostics.Debug.WriteLine(str); - - Assert.IsFalse(str.Trim().StartsWith("not ok"), string.Format("TAP fail ({0}) : {1}", m_File, str)); - } - - public TapRunner(string filename) - { - m_File = filename; - } - - public void Run() - { - Script S = new Script(); - - S.Options.DebugPrint = Print; - - S.Options.UseLuaErrorLocations = true; - -#if PCL - #if EMBEDTEST - S.Options.ScriptLoader = new EmbeddedResourcesScriptLoader(Assembly.GetExecutingAssembly()); - #else - S.Options.ScriptLoader = new TestsScriptLoader(); - #endif -#endif - - S.Globals.Set("arg", DynValue.NewTable(S)); - - ((ScriptLoaderBase)S.Options.ScriptLoader).ModulePaths = new string[] { "TestMore/Modules/?", "TestMore/Modules/?.lua" }; - - S.DoFile(m_File); - } - - public static void Run(string filename) - { - TapRunner t = new TapRunner(filename); - t.Run(); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/TestMore/301-basic.t b/src/MoonSharp.Interpreter.Tests/TestMore/301-basic.t deleted file mode 100644 index 62eb0970..00000000 --- a/src/MoonSharp.Interpreter.Tests/TestMore/301-basic.t +++ /dev/null @@ -1,391 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Basic Library - -=head2 Synopsis - - % prove 301-basic.t - -=head2 Description - -Tests Lua Basic Library - -See "Lua 5.2 Reference Manual", section 6.1 "Basic Functions", -L. - -=cut - ---]] - --- MoonSharp note : THIS SUITE WAS HEAVILY CUT FOR NOT APPLIABLE TESTS - - -require 'Test.More' - -plan(168) - ---[[ -if jit then - like(_VERSION, '^Lua 5%.1$', "variable _VERSION") -else - like(_VERSION, '^Lua 5%.2$', "variable _VERSION") -end --- ]] - -v, msg = assert('text', "assert string") -is(v, 'text', "function assert") -is(msg, "assert string") -v, msg = assert({}, "assert table") -is(msg, "assert table") - -error_like(function () assert(false, "ASSERTION TEST") end, - "^[^:]+:%d+: ASSERTION TEST", - "function assert(false, msg)") - -error_like(function () assert(false) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false)") - -error_like(function () assert(false, nil) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false, nil)") - - -a = {'a','b','c'} -local f, v, s = ipairs(a) -type_ok(f, 'function', "function ipairs") -type_ok(v, 'table') -is(s, 0) -s, v = f(a, s) -is(s, 1) -is(v, 'a') -s, v = f(a, s) -is(s, 2) -is(v, 'b') -s, v = f(a, s) -is(s, 3) -is(v, 'c') -s, v = f(a, s) -is(s, nil) -is(v, nil) - -t = { [[ -function bar (x) - return x -end -]] } -i = 0 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(reader)") -is(bar, nil) -f() -is(bar('ok'), 'ok') -bar = nil - -t = { [[ -function baz (x) - return x -end -]] } -i = -1 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(pathological reader)") -f() -is(baz, nil) - -t = { [[?syntax error?]] } -i = 0 -f, msg = load(reader, "errorchunk") -is(f, nil, "function load(syntax error)") ---like(msg, "^%[string \"errorchunk\"%]:%d+:") -- ERRORMSG - -f = load(function () return nil end) -type_ok(f, 'function', "when reader returns nothing") - -f, msg = load(function () return {} end) -is(f, nil, "reader function must return a string") -like(msg, "reader function must return a string") - -f = load([[ -function bar (x) - return x -end -]]) -is(bar, nil, "function load(str)") -f() -is(bar('ok'), 'ok') -bar = nil - -env = {} -f = load([[ -function bar (x) - return x -end -]], "from string", 't', env) -is(env.bar, nil, "function load(str)") -f() -is(env.bar('ok'), 'ok') - - --- ... - - -f = load([[i = i + 1]]) -i = 0 -f() -is(i, 1, "function loadstring") -f() -is(i, 2) - -i = 32 -local i = 0 -f = load([[i = i + 1; return i]]) -g = function () i = i + 1; return i end -is(f(), 33, "function loadstring") -is(g(), 1) - -f, msg = load([[?syntax error?]]) -is(f, nil, "function loadstring (syntax error)") --- like(msg, '^%[string "%?syntax error%?"%]:%d+:') -- ERRORMSG - -t = {'a','b','c'} -a = next(t, nil) -is(a, 1, "function next (array)") -a = next(t, 1) -is(a, 2) -a = next(t, 2) -is(a, 3) -a = next(t, 3) -is(a, nil) - -error_like(function () a = next() end, - "^[^:]+:%d+: bad argument #1 to 'next' %(table expected, got no value%)", - "function next (no arg)") - -error_like(function () a = next(t, 6) end, - "invalid key to 'next'", - "function next (invalid key)") - -t = {'a','b','c'} -a = next(t, 2) -is(a, 3, "function next (unorderer)") -a = next(t, 1) -is(a, 2) -a = next(t, 3) -is(a, nil) - -t = {} -a = next(t, nil) -is(a, nil, "function next (empty table)") - -a = {'a','b','c'} -local f, v, s = pairs(a) -type_ok(f, 'function', "function pairs") -type_ok(v, 'table') -is(s, nil) -s = f(v, s) -is(s, 1) -s = f(v, s) -is(s, 2) -s = f(v, s) -is(s, 3) -s = f(v, s) -is(s, nil) - -r = pcall(assert, true) -is(r, true, "function pcall") -r, msg = pcall(assert, false, 'catched') -is(r, false) -is(msg, 'catched') -r = pcall(assert) -is(r, false) - -t = {} -a = t -is(rawequal(nil, nil), true, "function rawequal -> true") -is(rawequal(false, false), true) -is(rawequal(3, 3), true) -is(rawequal('text', 'text'), true) -is(rawequal(t, a), true) -is(rawequal(print, print), true) - -is(rawequal(nil, 2), false, "function rawequal -> false") -is(rawequal(false, true), false) -is(rawequal(false, 2), false) -is(rawequal(3, 2), false) -is(rawequal(3, '2'), false) -is(rawequal('text', '2'), false) -is(rawequal('text', 2), false) -is(rawequal(t, {}), false) -is(rawequal(t, 2), false) -is(rawequal(print, format), false) -is(rawequal(print, 2), false) - -is(rawlen("text"), 4, "function rawlen (string)") -is(rawlen({ 'a', 'b', 'c'}), 3, "function rawlen (table)") -error_like(function () a = rawlen(true) end, - "^[^:]+:%d+: bad argument #1 to 'rawlen' %(table ", - "function rawlen (bad arg)") - -t = {a = 'letter a', b = 'letter b'} -is(rawget(t, 'a'), 'letter a', "function rawget") - -t = {} -is(rawset(t, 'a', 'letter a'), t, "function rawset") -is(t.a, 'letter a') - -error_like(function () t = {}; rawset(t, nil, 42) end, - "^[^:]+:%d+: table index is nil", -- changed this for MoonSharp, but we stay as it is! - "function rawset (table index is nil)") - -is(select('#'), 0, "function select") -is(select('#','a','b','c'), 3) -eq_array({select(1,'a','b','c')}, {'a','b','c'}) -eq_array({select(3,'a','b','c')}, {'c'}) -eq_array({select(5,'a','b','c')}, {}) -eq_array({select(-1,'a','b','c')}, {'c'}) -eq_array({select(-2,'a','b','c')}, {'b', 'c'}) -eq_array({select(-3,'a','b','c')}, {'a', 'b', 'c'}) - -error_like(function () select(0,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -error_like(function () select(-4,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -is(type("Hello world"), 'string', "function type") -is(type(10.4*3), 'number') -is(type(print), 'function') -is(type(type), 'function') -is(type(true), 'boolean') -is(type(nil), 'nil') --- is(type(io.stdin), 'userdata') -- no stdin in MoonSharp so far -is(type(type(X)), 'string') - -a = nil -is(type(a), 'nil', "function type") -a = 10 -is(type(a), 'number') -a = "a string!!" -is(type(a), 'string') -a = print -is(type(a), 'function') -is(type(function () end), 'function') - -error_like(function () type() end, - "^[^:]+:%d+: bad argument #1 to 'type' %(value expected%)", - "function type (no arg)") - -is(tonumber('text12'), nil, "function tonumber") -is(tonumber('12text'), nil) -is(tonumber(3.14), 3.14) -is(tonumber('3.14'), 3.14) -is(tonumber(' 3.14 '), 3.14) -is(tonumber(111, 2), 7) -is(tonumber('111', 2), 7) -is(tonumber(' 111 ', 2), 7) -is(tonumber('78', 9), 71) -is(tonumber('111 ', 3), 13) -is(tonumber('111', 4), 21) -is(tonumber('1234', 5), 194) -is(tonumber('54321', 6), 7465) - -a = {} -is(tonumber(a), nil) - -error_like(function () tonumber() end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(value expected%)", - "function tonumber (no arg)") - -error_like(function () tonumber('111', 200) end, - "^[^:]+:%d+: bad argument #2 to 'tonumber' %(base out of range%)", - "function tonumber (bad base)") - -error_like(function () tonumber('17', 6) end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(invalid character%)", - "function tonumber (bad base)") - -is(tostring('text'), 'text', "function tostring") -is(tostring(3.14), '3.14') -is(tostring(nil), 'nil') -is(tostring(true), 'true') -is(tostring(false), 'false') -like(tostring({}), '^table: 0?[Xx]?%x+$') -like(tostring(print), '^function: 0?[Xx]?[builtin]*#?%x+$') - -error_like(function () tostring() end, - "^[^:]+:%d+: bad argument #1 to 'tostring' %(value expected%)", - "function tostring (no arg)") - ---[[ MoonSharp : this is intentional - we support pack and unpack outside the table namespace (or whatever they are) -if (platform and platform.compat) or jit then - type_ok(unpack, 'function', "function unpack") -else - is(unpack, nil, "function unpack (removed)") -end -]] - - -if jit then - error_like(function () xpcall(assert, nil) end, - "bad argument #2 to 'xpcall' %(function expected, got nil%)", - "function xpcall") - error_like(function () xpcall(assert) end, - "bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall") - diag("LuaJIT intentional. xpcall") -else - is(xpcall(assert, nil), false, "function xpcall") - error_like(function () xpcall(assert) end, - "^[^:]+:%d+: bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall (no arg)") -end - -function backtrace () - return 'not a back trace' -end -r, msg = xpcall(assert, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r, msg = xpcall(function() assert(); end, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r = xpcall(assert, backtrace, true) -is(r, true, "function xpcall") - - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/TestMore/309-os.t b/src/MoonSharp.Interpreter.Tests/TestMore/309-os.t deleted file mode 100644 index a92ab3f8..00000000 --- a/src/MoonSharp.Interpreter.Tests/TestMore/309-os.t +++ /dev/null @@ -1,202 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Operating System Library - -=head2 Synopsis - - % prove 309-os.t - -=head2 Description - -Tests Lua Operating System Library - -See "Lua 5.2 Reference Manual", section 6.9 "Operating System Facilities", -L. - -See "Programming in Lua", section 22 "The Operating System Library". - -=cut - ---]] - -require 'Test.More' - -plan(54) - -local lua = "lua" - -clk = os.clock() -type_ok(clk, 'number', "function clock") -ok(clk <= os.clock()) - -d = os.date('!*t', 0) -is(d.year, 1970, "function date") -is(d.month, 1) -is(d.day, 1) -is(d.hour, 0) -is(d.min, 0) -is(d.sec, 0) -is(d.wday, 5) -is(d.yday, 1) -is(d.isdst, false) - -is(os.date('!%d/%m/%y %H:%M:%S', 0), '01/01/70 00:00:00', "function date") - -like(os.date('%H:%M:%S'), '^%d%d:%d%d:%d%d', "function date") - -if jit and jit.version_num < 20100 then - todo("LuaJIT TODO. invalid strftime.", 1) -end -is(os.date('%Oy', 0), '70') -if jit then - todo("LuaJIT TODO. invalid strftime.", 1) -end - - - -error_like(function () os.date('%Ja', 0) end, - "^[^:]+:%d+: bad argument #1 to 'date' %(invalid conversion specifier '%%Ja'%)", - "function date (invalid)") - -is(os.difftime(1234, 1200), 34, "function difftime") -is(os.difftime(1234), 1234) - -r = os.execute() -is(r, true, "function execute") - -r, s, n = os.execute('__IMPROBABLE__') -is(r, nil, "function execute") -is(s, 'exit') -type_ok(n, 'number') - ---[===[ -- Tests commented as currently they are more likely to fail because of OS configuration than implementation details - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(2)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 2, "exit value 1") - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(false)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 1, "exit value 2") - --- cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(true, true)"]] --- is(os.execute(cmd), true, "function execute & exit") - -cmd = lua .. [[ -e "print 'reached'; os.exit(); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - code = f:close() - is(code, true, "exit code") -else - skip("io.popen not supported", 3) -end - -cmd = lua .. [[ -e "print 'reached'; os.exit(3); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - r, s, n = f:close() - is(r, nil) - is(s, 'exit', "exit code") - is(n, 3, "exit value 3") -else - skip("io.popen not supported", 5) -end - ---]===] - -is(os.getenv('__IMPROBABLE__'), nil, "function getenv") - -user = os.getenv('LOGNAME') or os.getenv('USERNAME') -type_ok(user, 'string', "function getenv") - -local f = io.open('file.rm', 'w') -f:write("file to remove") -f:close() -r = os.remove("file.rm") -is(r, true, "function remove") - -r, msg = os.remove('file.rm') -is(r, nil, "function remove") -like(msg, '^file.rm: No such file or directory') - -local f = io.open('file.old', 'w') -f:write("file to rename") -f:close() -os.remove('file.new') -r = os.rename('file.old', 'file.new') -is(r, true, "function rename") -os.remove('file.new') -- clean up - -r, msg = os.rename('file.old', 'file.new') -is(r, nil, "function rename") -like(msg, 'No such file or directory') - ---[[ setlocale NOT supported! -is(os.setlocale('C', 'all'), 'C', "function setlocale") -is(os.setlocale(), 'C') - -is(os.setlocale('unk_loc', 'all'), nil, "function setlocale (unknown locale)") - -]] - -like(os.time(), '^%d+%.?%d*$', "function time") - -like(os.time(nil), '^%d+%.?%d*$', "function time") - -like(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 2000, - isdst = 0, -}), '^946%d+$', "function time") - -if platform and platform.intsize == 8 then - todo("pb on 64bit platforms") - -- os.time returns nil when C mktime returns < 0 - -- this test needs a out of range value on any platform -end -is(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 1000, - isdst = 0, -}), nil, "function time -> nil") - -error_like(function () os.time{} end, - "^[^:]+:%d+: field 'day' missing in date table", - "function time (missing field)") - -fname = os.tmpname() -type_ok(fname, 'string', "function tmpname") -ok(fname ~= os.tmpname()) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/Builder.lua b/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/Builder.lua deleted file mode 100644 index 9fc87c9b..00000000 --- a/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/Builder.lua +++ /dev/null @@ -1,392 +0,0 @@ - --- --- lua-TestMore : --- - -local debug = nil; -- require 'debug' -local io = nil; -- require 'io' -local os = nil; -- require 'os' -local error = error -local gsub = require 'string'.gsub -local match = require 'string'.match -local pairs = pairs -local pcall = pcall -local print = print -local rawget = rawget -local setmetatable = setmetatable -local tconcat = require 'table'.concat -local tonumber = tonumber -local tostring = tostring -local type = type - -_ENV = nil -local m = {} - -local testout = io and io.stdout -local testerr = io and (io.stderr or io.stdout) - -function m.puts (f, str) - f:write(str) -end - -local function _print_to_fh (self, f, ...) - -- if f then - -- local msg = tconcat({...}) - -- gsub(msg, "\n", "\n" .. self.indent) - -- m.puts(f, self.indent .. msg .. "\n") - -- else - print(self.indent, ...) - -- end -end - -local function _print (self, ...) - _print_to_fh(self, self:output(), ...) -end - -local function print_comment (self, f, ...) - local arg = {...} - for k, v in pairs(arg) do - arg[k] = tostring(v) - end - local msg = tconcat(arg) - msg = gsub(msg, "\n", "\n# ") - msg = gsub(msg, "\n# \n", "\n#\n") - msg = gsub(msg, "\n# $", '') - _print_to_fh(self, f, "# ", msg) -end - -function m.create () - local o = { - data = setmetatable({}, { __index = m }), - } - setmetatable(o, { - __index = function (t, k) - return rawget(t, 'data')[k] - end, - __newindex = function (t, k, v) - rawget(o, 'data')[k] = v - end, - }) - o:reset() - return o -end - -local test -function m.new () - test = test or m.create() - return test -end - -local function in_todo (self) - return self.todo_upto >= self.curr_test -end - -function m:child (name) - if self.child_name then - error("You already have a child named (" .. self.child_name .. " running") - end - local child = m.create() - child.indent = self.indent .. ' ' - child.out_file = self.out_file - child.fail_file = in_todo(self) and self.todo_file or self.fail_file - child.todo_file = self.todo_file - child.parent = self - self.child_name = name - return child -end - -local function plan_handled (self) - return self.have_plan or self.no_plan or self._skip_all -end - -function m:subtest (name, func) - if type(func) ~= 'function' then - error("subtest()'s second argument must be a function") - end - self:diag('Subtest: ' .. name) - local child = self:child(name) - local parent = self.data - self.data = child.data - local r, msg = pcall(func) - child.data = self.data - self.data = parent - if not r and not child._skip_all then - error(msg, 0) - end - if not plan_handled(child) then - child:done_testing() - end - child:finalize() -end - -function m:finalize () - if not self.parent then - return - end - if self.child_name then - error("Can't call finalize() with child (" .. self.child_name .. " active") - end - local parent = self.parent - local name = parent.child_name - parent.child_name = nil - if self._skip_all then - parent:skip(self._skip_all) - elseif self.curr_test == 0 then - parent:ok(false, "No tests run for subtest \"" .. name .. "\"", 2) - else - parent:ok(self.is_passing, name, 2) - end - self.parent = nil -end - -function m:reset () - self.curr_test = 0 - self._done_testing = false - self.expected_tests = 0 - self.is_passing = true - self.todo_upto = -1 - self.todo_reason = nil - self.have_plan = false - self.no_plan = false - self._skip_all = false - self.have_output_plan = false - self.indent = '' - self.parent = false - self.child_name = false - self:reset_outputs() -end - -local function _output_plan (self, max, directive, reason) - if self.have_output_plan then - error("The plan was already output") - end - local out = "1.." .. max - if directive then - out = out .. " # " .. directive - end - if reason then - out = out .. " " .. reason - end - _print(self, out) - self.have_output_plan = true -end - -function m:plan (arg) - if self.have_plan then - error("You tried to plan twice") - end - if type(arg) == 'string' and arg == 'no_plan' then - self.have_plan = true - self.no_plan = true - return true - elseif type(arg) ~= 'number' then - error("Need a number of tests") - elseif arg < 0 then - error("Number of tests must be a positive integer. You gave it '" .. arg .."'.") - else - self.expected_tests = arg - self.have_plan = true - _output_plan(self, arg) - return arg - end -end - -function m:done_testing (num_tests) - if num_tests then - self.no_plan = false - end - num_tests = num_tests or self.curr_test - if self._done_testing then - tb:ok(false, "done_testing() was already called") - return - end - self._done_testing = true - if self.expected_tests > 0 and num_tests ~= self.expected_tests then - self:ok(false, "planned to run " .. self.expected_tests - .. " but done_testing() expects " .. num_tests) - else - self.expected_tests = num_tests - end - if not self.have_output_plan then - _output_plan(self, num_tests) - end - self.have_plan = true - -- The wrong number of tests were run - if self.expected_tests ~= self.curr_test then - self.is_passing = false - end - -- No tests were run - if self.curr_test == 0 then - self.is_passing = false - end -end - -function m:has_plan () - if self.expected_tests > 0 then - return self.expected_tests - end - if self.no_plan then - return 'no_plan' - end - return nil -end - -function m:skip_all (reason) - if self.have_plan then - error("You tried to plan twice") - end - self._skip_all = reason - _output_plan(self, 0, 'SKIP', reason) - if self.parent then - error("skip_all in child", 0) - end - -- os.exit(0) -end - -local function _check_is_passing_plan (self) - local plan = self:has_plan() - if not plan or not tonumber(plan) then - return - end - if plan < self.curr_test then - self.is_passing = false - end -end - -function m:ok (test, name, level) - if self.child_name then - name = name or 'unnamed test' - self.is_passing = false - error("Cannot run test (" .. name .. ") with active children") - end - name = name or '' - level = level or 0 - self.curr_test = self.curr_test + 1 - name = tostring(name) - if match(name, '^[%d%s]+$') then - self:diag(" You named your test '" .. name .."'. You shouldn't use numbers for your test names." - .. "\n Very confusing.") - end - local out = '' - if not test then - out = "not " - end - out = out .. "ok " .. self.curr_test - if name ~= '' then - out = out .. " - " .. name - end - if self.todo_reason and in_todo(self) then - out = out .. " # TODO " .. self.todo_reason - end - _print(self, out) - if not test then - local msg = in_todo(self) and "Failed (TODO)" or "Failed" - local info = debug and debug.getinfo(3 + level) - if info then - local file = info.short_src - local line = info.currentline - self:diag(" " .. msg .. " test (" .. file .. " at line " .. line .. ")") - else - self:diag(" " .. msg .. " test") - end - end - if not test and not in_todo(self) then - self.is_passing = false - end - _check_is_passing_plan(self) -end - -function m:BAIL_OUT (reason) - local out = "Bail out!" - if reason then - out = out .. " " .. reason - end - _print(self, out) - os.exit(255) -end - -function m:current_test (num) - if num then - self.curr_test = num - end - return self.curr_test -end - -function m:todo (reason, count) - count = count or 1 - self.todo_upto = self.curr_test + count - self.todo_reason = reason -end - -function m:skip (reason) - local name = "# skip" - if reason then - name = name .. " " .. reason - end - self:ok(true, name, 1) -end - -function m:todo_skip (reason) - local name = "# TODO & SKIP" - if reason then - name = name .. " " .. reason - end - self:ok(false, name, 1) -end - -function m:skip_rest (reason) - for i = self.curr_test, self.expected_tests do - tb:skip(reason) - end -end - -local function diag_file (self) - if in_todo(self) then - return self:todo_output() - else - return self:failure_output() - end -end - -function m:diag (...) - print_comment(self, diag_file(self), ...) -end - -function m:note (...) - print_comment(self, self:output(), ...) -end - -function m:output (f) - if f then - self.out_file = f - end - return self.out_file -end - -function m:failure_output (f) - if f then - self.fail_file = f - end - return self.fail_file -end - -function m:todo_output (f) - if f then - self.todo_file = f - end - return self.todo_file -end - -function m:reset_outputs () - self:output(testout) - self:failure_output(testerr) - self:todo_output(testout) -end - -return m --- --- Copyright (c) 2009-2012 Francois Perrad --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/More.lua b/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/More.lua deleted file mode 100644 index 9f417ca4..00000000 --- a/src/MoonSharp.Interpreter.Tests/TestMore/Modules/Test/More.lua +++ /dev/null @@ -1,383 +0,0 @@ - --- --- lua-TestMore : --- - -local loadstring = loadstring or load -local pairs = pairs -local pcall = pcall -local require = require -local tostring = tostring -local type = type -local match = require 'string'.match -local unpack = require 'table'.unpack or unpack -local _G = _G - -local tb = require 'Test.Builder'.new() - -_ENV = nil -local m = {} - -function m.plan (arg) - tb:plan(arg) -end - -function m.done_testing (num_tests) - tb:done_testing(num_tests) -end - -function m.skip_all (reason) - tb:skip_all(reason) -end - -function m.BAIL_OUT (reason) - tb:BAIL_OUT(reason) -end - -function m.ok (test, name) - tb:ok(test, name) -end - -function m.nok (test, name) - tb:ok(not test, name) -end - -function m.is (got, expected, name) - local pass = got == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: " .. tostring(expected)) - end -end - -function m.isnt (got, expected, name) - local pass = got ~= expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: anything else") - end -end - -function m.like (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end -end - -function m.unlike (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = not match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n matches '" .. pattern .. "'") - end -end - -local cmp = { - ['<'] = function (a, b) return a < b end, - ['<='] = function (a, b) return a <= b end, - ['>'] = function (a, b) return a > b end, - ['>='] = function (a, b) return a >= b end, - ['=='] = function (a, b) return a == b end, - ['~='] = function (a, b) return a ~= b end, -} - -function m.cmp_ok (this, op, that, name) - local f = cmp[op] - if not f then - tb:ok(false, name) - tb:diag("unknown operator : " .. tostring(op)) - return - end - local pass = f(this, that) - tb:ok(pass, name) - if not pass then - tb:diag(" " .. tostring(this) - .. "\n " .. op - .. "\n " .. tostring(that)) - end -end - -function m.type_ok (val, t, name) - if type(t) ~= 'string' then - tb:ok(false, name) - tb:diag("type isn't a string : " .. tostring(t)) - return - end - if type(val) == t then - tb:ok(true, name) - else - tb:ok(false, name) - tb:diag(" " .. tostring(val) .. " isn't a '" .. t .."' it's a '" .. type(val) .. "'") - end -end - -function m.subtest (name, func) - tb:subtest(name, func) -end - -function m.pass (name) - tb:ok(true, name) -end - -function m.fail (name) - tb:ok(false, name) -end - -function m.require_ok (mod) - local r, msg = pcall(require, mod) - tb:ok(r, "require '" .. tostring(mod) .. "'") - if not r then - tb:diag(" " .. msg) - end - return r -end - -function m.eq_array (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - for i = 1, #expected do - local v = expected[i] - local val = got[i] - if val ~= v then - tb:ok(false, name) - tb:diag(" at index: " .. tostring(i) - .. "\n got: " .. tostring(val) - .. "\n expected: " .. tostring(v)) - return - end - end - local extra = #got - #expected - if extra ~= 0 then - tb:ok(false, name) - tb:diag(" " .. tostring(extra) .. " unexpected item(s)") - else - tb:ok(true, name) - end -end - -function m.is_deeply (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - local msg1 - local msg2 - local seen = {} - - local function deep_eq (t1, t2, key_path) - if t1 == t2 or seen[t1] then - return true - end - seen[t1] = true - for k, v2 in pairs(t2) do - local v1 = t1[k] - if type(v1) == 'table' and type(v2) == 'table' then - local r = deep_eq(v1, v2, key_path .. "." .. tostring(k)) - if not r then - return false - end - else - if v1 ~= v2 then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(v1) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - end - for k in pairs(t1) do - local v2 = t2[k] - if v2 == nil then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(t1[k]) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - return true - end -- deep_eq - - local pass = deep_eq(got, expected, '') - tb:ok(pass, name) - if not pass then - tb:diag(" Tables begin differing at:") - tb:diag(" " .. msg1) - tb:diag(" " .. msg2) - end -end - -function m.error_is (code, arg2, arg3, arg4) - local params, expected, name - if type(arg2) == 'table' then - params = arg2 - expected = arg3 - name = arg4 - else - params = {} - expected = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(expected)) - else - local pass = msg == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. msg - .. "\n expected: " .. tostring(expected)) - end - end -end - -function m.error_like (code, arg2, arg3, arg4) - local params, pattern, name - if type(arg2) == 'table' then - params = arg2 - pattern = arg3 - name = arg4 - else - params = {} - pattern = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(pattern)) - else - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - local pass = match(msg, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. msg .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end - end -end - -function m.lives_ok (code, arg2, arg3) - local params, name - if type(arg2) == 'table' then - params = arg2 - name = arg3 - else - params = {} - name = arg2 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - tb:ok(r, name) - if not r then - tb:diag(" " .. msg) - end -end - -function m.diag (msg) - tb:diag(msg) -end - -function m.note (msg) - tb:note(msg) -end - -function m.skip (reason, count) - count = count or 1 - for i = 1, count do - tb:skip(reason) - end -end - -function m.todo_skip (reason, count) - count = count or 1 - for i = 1, count do - tb:todo_skip(reason) - end -end - -function m.skip_rest (reason) - tb:skip_rest(reason) -end - -function m.todo (reason, count) - tb:todo(reason, count) -end - -for k, v in pairs(m) do -- injection - _G[k] = v -end - -m._VERSION = "0.3.1" -m._DESCRIPTION = "lua-TestMore : an Unit Testing Framework" -m._COPYRIGHT = "Copyright (c) 2009-2012 Francois Perrad" -return m --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/TestRunner.cs b/src/MoonSharp.Interpreter.Tests/TestRunner.cs deleted file mode 100755 index 82894da6..00000000 --- a/src/MoonSharp.Interpreter.Tests/TestRunner.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests -{ - public enum TestResultType - { - Message, - Ok, - Fail, - Skipped - } - - public class TestResult - { - public string TestName; - public string Message; - public Exception Exception; - public TestResultType Type; - } - - internal class SkipThisTestException : Exception { } - - public class TestRunner - { - Action loggerAction; - public int Ok = 0; - public int Fail = 0; - public int Total = 0; - public int Skipped = 0; - - public static bool IsRunning { get; private set; } - - public TestRunner(Action loggerAction) - { - IsRunning = true; - - this.loggerAction = loggerAction; - - Console_WriteLine("MoonSharp Test Suite Runner - {0} [{1}]", Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName()); - Console_WriteLine("http://www.moonsharp.org"); - Console_WriteLine(""); - } - - public void Test(string whichTest = null, string[] testsToSkip = null) - { - foreach (TestResult tr in IterateOnTests(whichTest, testsToSkip)) - loggerAction(tr); - } - - - public IEnumerable IterateOnTests(string whichTest = null, string[] testsToSkip = null, Type[] types = null) - { - HashSet skipList = new HashSet(); - - if (testsToSkip != null) - skipList.UnionWith(testsToSkip); - - Assembly asm = Framework.Do.GetAssembly(typeof(TestRunner)); - - types = types ?? Framework.Do.GetAssemblyTypes(asm).Where( - t => Framework.Do.GetCustomAttributes(t, typeof(TestFixtureAttribute), true).Any()).ToArray(); - -#if UNITY_EDITOR_OSX - System.IO.File.WriteAllLines("/temp/types.cs", types.Select(t => t.FullName).ToArray()); -#endif - - Console_WriteLine("Found {0} test types.", types.Length); - - foreach (Type t in types) - { - MethodInfo[] tests = Framework.Do.GetMethods(t).Where(m => m.GetCustomAttributes(typeof(TestAttribute), true).Any()).ToArray(); - //Console_WriteLine("Testing {0} - {1} tests found.", t.Name, tests.Length); - - foreach (MethodInfo mi in tests) - { - if (whichTest != null && mi.Name != whichTest) - continue; - - if (skipList.Contains(mi.Name)) - { - ++Skipped; - TestResult trs = new TestResult() - { - TestName = mi.Name, - Message = "skipped (skip-list)", - Type = TestResultType.Skipped - }; - yield return trs; - continue; - } - - TestResult tr = RunTest(t, mi); - - if (tr.Type != TestResultType.Message) - { - if (tr.Type == TestResultType.Fail) - ++Fail; - else if (tr.Type == TestResultType.Ok) - ++Ok; - else - ++Skipped; - - ++Total; - } - - yield return tr; - } - } - - Console_WriteLine(""); - Console_WriteLine("OK : {0}/{2}, Failed {1}/{2}, Skipped {3}/{2}", Ok, Fail, Total, Skipped); - } - - private void Console_WriteLine(string message, params object[] args) - { - loggerAction(new TestResult() - { - Type = TestResultType.Message, - Message = string.Format(message, args) - }); - } - - private static TestResult RunTest(Type t, MethodInfo mi) - { - if (mi.GetCustomAttributes(typeof(IgnoreAttribute), true).Any()) - { - return new TestResult() - { - TestName = mi.Name, - Message = "skipped", - Type = TestResultType.Skipped - }; - } - - ExpectedExceptionAttribute expectedEx = mi.GetCustomAttributes(typeof(ExpectedExceptionAttribute), true) - .OfType() - .FirstOrDefault(); - - - try - { - object o = Activator.CreateInstance(t); - mi.Invoke(o, new object[0]); - - if (expectedEx != null) - { - return new TestResult() - { - TestName = mi.Name, - Message = string.Format("Exception {0} expected", expectedEx.ExpectedException), - Type = TestResultType.Fail - }; - } - else - { - return new TestResult() - { - TestName = mi.Name, - Message = "ok", - Type = TestResultType.Ok - }; - } - } - catch (TargetInvocationException tiex) - { - Exception ex = tiex.InnerException; - - if (ex is SkipThisTestException) - { - return new TestResult() - { - TestName = mi.Name, - Message = "skipped", - Type = TestResultType.Skipped - }; - } - - if (expectedEx != null && Framework.Do.IsInstanceOfType(expectedEx.ExpectedException, ex)) - { - return new TestResult() - { - TestName = mi.Name, - Message = "ok", - Type = TestResultType.Ok - }; - } - else - { - return new TestResult() - { - TestName = mi.Name, - Message = BuildExceptionMessage(ex), - Type = TestResultType.Fail, - Exception = ex - }; - } - } - } - - private static string BuildExceptionMessage(Exception ex) - { - StringBuilder sb = new StringBuilder(); - - for (Exception e = ex; e != null; e = e.InnerException) - { - sb.Append(">>> "); - sb.Append(e.Message); - } - - return sb.ToString(); - } - - internal static void Skip() - { - if (TestRunner.IsRunning) - throw new SkipThisTestException(); - } - } -} diff --git a/src/MoonSharp.Interpreter.Tests/Units/BinDumpStreamTests.cs b/src/MoonSharp.Interpreter.Tests/Units/BinDumpStreamTests.cs deleted file mode 100644 index 99977237..00000000 --- a/src/MoonSharp.Interpreter.Tests/Units/BinDumpStreamTests.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.IO; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.Units -{ - [TestFixture] - public class BinDumpStreamTests - { - [Test] - public void BinDumpBinaryStreams_TestIntWrites() - { - int[] values = new int[] { 0, 1, -1, 10, -10, 32767, 32768, -32767, -32768, int.MinValue, int.MaxValue }; - - using(MemoryStream ms_orig = new MemoryStream()) - { - UndisposableStream ms = new UndisposableStream(ms_orig); - - using(BinDumpBinaryWriter bdbw = new BinDumpBinaryWriter(ms, Encoding.UTF8)) - { - for(int i = 0; i < values.Length; i++) - { - bdbw.Write(values[i]); - } - } - - ms.Seek(0, SeekOrigin.Begin); - - using(BinDumpBinaryReader bdbr = new BinDumpBinaryReader(ms, Encoding.UTF8)) - { - for (int i = 0; i < values.Length; i++) - { - int v = bdbr.ReadInt32(); - Assert.AreEqual(values[i], v, "i = "+ i.ToString()); - } - } - } - } - - [Test] - public void BinDumpBinaryStreams_TestUIntWrites() - { - uint[] values = new uint[] { 0, 1, 0x7F, 10, 0x7E, 32767, 32768, uint.MinValue, uint.MaxValue }; - - using (MemoryStream ms_orig = new MemoryStream()) - { - UndisposableStream ms = new UndisposableStream(ms_orig); - - using (BinDumpBinaryWriter bdbw = new BinDumpBinaryWriter(ms, Encoding.UTF8)) - { - for (int i = 0; i < values.Length; i++) - { - bdbw.Write(values[i]); - } - } - - ms.Seek(0, SeekOrigin.Begin); - - using (BinDumpBinaryReader bdbr = new BinDumpBinaryReader(ms, Encoding.UTF8)) - { - for (int i = 0; i < values.Length; i++) - { - uint v = bdbr.ReadUInt32(); - Assert.AreEqual(values[i], v, "i = " + i.ToString()); - } - } - } - } - - - [Test] - public void BinDumpBinaryStreams_TestStringWrites() - { - string[] values = new string[] { "hello", "you", "fool", "hello", "I", "love", "you" }; - - using (MemoryStream ms_orig = new MemoryStream()) - { - UndisposableStream ms = new UndisposableStream(ms_orig); - - using (BinDumpBinaryWriter bdbw = new BinDumpBinaryWriter(ms, Encoding.UTF8)) - { - for (int i = 0; i < values.Length; i++) - { - bdbw.Write(values[i]); - } - } - - ms.Seek(0, SeekOrigin.Begin); - - using (BinDumpBinaryReader bdbr = new BinDumpBinaryReader(ms, Encoding.UTF8)) - { - for (int i = 0; i < values.Length; i++) - { - string v = bdbr.ReadString(); - Assert.AreEqual(values[i], v, "i = " + i.ToString()); - } - } - } - } - - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/Units/FastStackTests.cs b/src/MoonSharp.Interpreter.Tests/Units/FastStackTests.cs deleted file mode 100644 index dbf985c7..00000000 --- a/src/MoonSharp.Interpreter.Tests/Units/FastStackTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.Units -{ - [TestFixture] - public class FastStackTests - { - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/Units/InteropTests.cs b/src/MoonSharp.Interpreter.Tests/Units/InteropTests.cs deleted file mode 100644 index 2782788c..00000000 --- a/src/MoonSharp.Interpreter.Tests/Units/InteropTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Interop; -using NUnit.Framework; - -namespace MoonSharp.Interpreter.Tests.Units -{ - [TestFixture] - public class InteropTests - { - [Test] - public void Converter_FromObject() - { - //DynValue v; - //int? x = 3; - //int? y = null; - - //v = Converter.FromObject(1); - //v = Converter.FromObject(x); - //v = Converter.FromObject(y); - - - - - } - - } -} diff --git a/src/MoonSharp.Interpreter.Tests/_Hardwired.cs b/src/MoonSharp.Interpreter.Tests/_Hardwired.cs deleted file mode 100755 index 5769867d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Hardwired.cs +++ /dev/null @@ -1,15213 +0,0 @@ -#if !PCL && !UNITY_5 && !DOTNET_CORE - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// ---------------------------------------------------------- -// Generated by MoonSharp.Hardwire v.1.0.5877.41842 -// Compatible with MoonSharp v.1.99.999.9999 or equivalent -// ---------------------------------------------------------- -// Code generated on 2016-02-03T23:14:47.5315068+01:00 -// ---------------------------------------------------------- -// -// -// -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Vector3.X::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Vector3.Y::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Vector3.Z::Set' will be a no-op, as it's a member of a value type. -// ERROR : Type/Member 'MyEvent' cannot be hardwired, error = 'unsupported member type : MoonSharp.Interpreter.Interop.EventMemberDescriptor' (stack = MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests+SomeClass). -// ERROR : Type/Member 'MySEvent' cannot be hardwired, error = 'unsupported member type : MoonSharp.Interpreter.Interop.EventMemberDescriptor' (stack = MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests+SomeClass). -// WARNING : Type/Member 'MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType+SomeNestedTypePrivate' cannot be hardwired because its visibility is 'private' (stack = ). -// WARNING : Type/Member 'SomeNestedTypePrivate' cannot be hardwired because its visibility is 'private' (stack = MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType). -// WARNING : Type/Member 'MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType+SomeNestedTypePrivate' cannot be hardwired because its visibility is 'private' (stack = ). -// WARNING : Type/Member 'SomeNestedTypePrivate' cannot be hardwired because its visibility is 'private' (stack = MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType). -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.IntProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.NIntProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.ObjProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.StaticProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.WoIntProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.WoIntProp2::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass.AccessOverrProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ArithmOperatorsTestClass.Value::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests+IndexerTestClass.mymap::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass.IntProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass.NIntProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass.ObjProp::Set' will be a no-op, as it's a member of a value type. -// WARNING : Member 'MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass.StaticProp::Set' will be a no-op, as it's a member of a value type. -namespace MyNamespace -{ - - - public abstract class MyClass - { - - private MyClass() - { - } - - public static void Initialize() - { - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_71dd5d8c103e4d768ae1c67d2e10dd85()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_9a70b110dfd644339862781b0912b66e()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_690908c2f3234d4eb890ade67497dac8()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_c142762d43fa4da88b624f4c928cd065()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_8f6f2e3c154e4ac8a127ef998b64b06b()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_c8d44043712740c180e31cf9a5ec5893()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_9ccc3059bc124dbea894c97ceed6e510()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_cad5306f62694a019a0d2753e1d2fca3()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_728312c1affe4e99a286edc5d9020c48()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_50fe3e19ee7b4d34b2d94c2ec09ad8d4()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_da3e72ee164847a58fb8b3fa12421a15()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_22f0c3c36b3147bfb30a605ca30fde1c()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_1f6c21b9d2ba407f8815e4195628d3ab()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_201806dd10b345358abc1e2a7fea60d2()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_96070a3ffc144574bd59a74250e84abd()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_71451dacd00543d1b4b5d91d5b9f4bc9()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_1a704d11703e4b01bbe25a3a6e3d7437()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_52f7e7443c124d23a81e55f9e22be191()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_7569b35816794806aa24df61d472ad96()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_8df48697e4b4488fac40be824e5775c2()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_fdd5466522954a8ead748408a2a3e02e()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_480c8e43dcda4daeb4f7736380f9d3db()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_d8f481563a93412d905a66a0f4640f91()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_159cf7f2538e48f0aa152cdabc23042e()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_edfd942631734cc1951924896cb28111()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_42c7f3d0acb341bca981275e2ecf79c9()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_835b52631f614895b7b48ef29d9dfe1b()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_d4bc7b8842184932b3fa631f414a2cc7()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_dc0291b3e19a4bb1b9944defdb5d6a77()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_8b14e5a0f85c42219e8c5b4b7ff618ca()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_b7f437771da443599c33303bb0a7c864()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_6a6a78e9064a45ba8885f2df3a5b58f4()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_5111a7ecd6544644a489165b35869822()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_837265dc0f5143f38128bce0768e5a33()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_111440b2f057418ea38cba2c19403629()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_79f4cd059fcf483495a03356bb8cce46()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_acc8a8b40d184cdf88cb69e719d37cbb()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_849992c03f5a412f92b34315fa1849e8()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_9a705002c22f4c57aaea7b4dfd2de660()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_2d2fe58092f042eaac7ff3c4874a6eaa()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_357faad2de2b4026a781cdc01ee447d3()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_cfa246c16d8e45c28af66bfe941f2759()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_fb4a26496fb54e9c9a36dfcdbc2bd9a1()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_9302398a948a4cc883b9dff9976a4e80()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_3f7a152fa8b348c996f851343aa9b2ad()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_a7e62b0e3ff84281b50f51f8d5504a63()); - MoonSharp.Interpreter.UserData.RegisterType(new TYPE_0fd7f1a4f76344ef81e0c9e5081fa739()); - } - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods - private sealed class TYPE_71dd5d8c103e4d768ae1c67d2e10dd85 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_71dd5d8c103e4d768ae1c67d2e10dd85() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1476583642394beb9b3cad7cff1bc1ae()})); - this.AddMember("GetMultiArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetMultiArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_813179e653654d41a605da7cef926c9b()})); - this.AddMember("GetArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3a3a01b7a5d746f5b98be006a4eb6239()})); - this.AddMember("GetItems", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetItems", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fc41c2d662294652a50d1d57a371506a()})); - this.AddMember("GetList", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetList", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c30b367325c945c2ac40690cd0a64010()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9d9dfaf351d540678d749d0672ccc0d5()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_669663d55dae460baee227bef0b27725()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_97b5ee69e9d34767b4e324d0ba95ed44()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dc2dd86f79ae40b1be6770ea5ef682d1()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f440427ef4254200b065322d5956a4ec()})); - } - - private sealed class MTHD_1476583642394beb9b3cad7cff1bc1ae : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1476583642394beb9b3cad7cff1bc1ae() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods(); - } - } - - private sealed class MTHD_813179e653654d41a605da7cef926c9b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_813179e653654d41a605da7cef926c9b() - { - this.Initialize("GetMultiArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)(obj)).GetMultiArray(); - } - } - - private sealed class MTHD_3a3a01b7a5d746f5b98be006a4eb6239 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3a3a01b7a5d746f5b98be006a4eb6239() - { - this.Initialize("GetArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)(obj)).GetArray(); - } - } - - private sealed class MTHD_fc41c2d662294652a50d1d57a371506a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fc41c2d662294652a50d1d57a371506a() - { - this.Initialize("GetItems", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)(obj)).GetItems(); - } - } - - private sealed class MTHD_c30b367325c945c2ac40690cd0a64010 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c30b367325c945c2ac40690cd0a64010() - { - this.Initialize("GetList", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)(obj)).GetList(); - } - } - - private sealed class MTHD_9d9dfaf351d540678d749d0672ccc0d5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9d9dfaf351d540678d749d0672ccc0d5() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollMethods)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_669663d55dae460baee227bef0b27725 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_669663d55dae460baee227bef0b27725() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_97b5ee69e9d34767b4e324d0ba95ed44 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_97b5ee69e9d34767b4e324d0ba95ed44() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_dc2dd86f79ae40b1be6770ea5ef682d1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dc2dd86f79ae40b1be6770ea5ef682d1() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_f440427ef4254200b065322d5956a4ec : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f440427ef4254200b065322d5956a4ec() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem - private sealed class TYPE_9a70b110dfd644339862781b0912b66e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_9a70b110dfd644339862781b0912b66e() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fa16de63b5ff457dbeff70ae1c6a0045()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_aaec65d527724778a2ab2177bb2b9e4d()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c3dc6acb7450464097bfeeaee706335f()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_26de3c5a05d94c1d8b7b7cb302959ea0()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_de2e70a5de224c17808001b0348ceebd()})); - this.AddMember("Value", new FLDV_54880f3941e44b3e854c424ce2af3ce9()); - } - - private sealed class MTHD_fa16de63b5ff457dbeff70ae1c6a0045 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fa16de63b5ff457dbeff70ae1c6a0045() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem(((int)(pars[0]))); - } - } - - private sealed class MTHD_aaec65d527724778a2ab2177bb2b9e4d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_aaec65d527724778a2ab2177bb2b9e4d() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_c3dc6acb7450464097bfeeaee706335f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c3dc6acb7450464097bfeeaee706335f() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_26de3c5a05d94c1d8b7b7cb302959ea0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_26de3c5a05d94c1d8b7b7cb302959ea0() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_de2e70a5de224c17808001b0348ceebd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_de2e70a5de224c17808001b0348ceebd() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_54880f3941e44b3e854c424ce2af3ce9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_54880f3941e44b3e854c424ce2af3ce9() : - base(typeof(int), "Value", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(obj)).Value; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(obj)); - tmp.Value = ((int)(value)); - } - } - } - #endregion - - #region Descriptor of System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - // Descriptor of System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - private sealed class TYPE_690908c2f3234d4eb890ade67497dac8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_690908c2f3234d4eb890ade67497dac8() : - base(typeof(System.Collections.Generic.List)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_afb8c106b74d4751aa13ef8e9c8f1905(), - new MTHD_d80367843e2b41f4a93de8ed6206d67a(), - new MTHD_811b38a66d644cd29916c0dc9235af88()})); - this.AddMember("get_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3613719c7d194871945e31b20bd1743e()})); - this.AddMember("set_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6b8b63f535f748eaa378f32897254bbc()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fa3b16d8d9704826971c7aa7165e68aa()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b7b0dd98e501441f953af07669860863()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae9f0e6563224103a76f2d2d358fcab0()})); - this.AddMember("Add", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Add", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_616085b16f934e14a61d7aff991ad3a3()})); - this.AddMember("AddRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AddRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ff728a7102ea415ab5e7efac0517282b()})); - this.AddMember("AsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AsReadOnly", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_15f6bea4eef14a73bef5ef3c2c7ac49b()})); - this.AddMember("BinarySearch", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("BinarySearch", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d6c4c4e1acee4ba9a56c6c5a1b096999(), - new MTHD_0cad825d11754d07ab36d25f67c00540(), - new MTHD_1bce1812985c48c88f2181fa013438d4()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4027e99821eb48ffaba3d1469a25f38e()})); - this.AddMember("Contains", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Contains", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8c708df507d84faaac617d5df3691ae6()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a0adb855315f4d4f97493afe4321327f(), - new MTHD_51d15a4e2e1f4b4d88c38d37546c2c4c(), - new MTHD_0399bb34e99442f09439e4d26d928b99()})); - this.AddMember("Exists", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Exists", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a8574139c28e4796b26d9e5c636dcee1()})); - this.AddMember("Find", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Find", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_434cec04b69e455eb58fd5f8a5d1a9e8()})); - this.AddMember("FindAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1628c8aac9ab40deb463bda80614ff2a()})); - this.AddMember("FindIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_119e3def72cf4942a84d55ca80f71408(), - new MTHD_d20bb63016704e799c3577a0e92f9b29(), - new MTHD_921f8c4471604bf2810e287b98132d57()})); - this.AddMember("FindLast", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLast", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c36db91411c14ec9a61d38299eb02ac8()})); - this.AddMember("FindLastIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLastIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_01ced101ce6c47be8e7f10feb8b34ceb(), - new MTHD_2482cfe973074232a34750d3b42441c4(), - new MTHD_6b95d9c0f21341e593ef060194e514cd()})); - this.AddMember("ForEach", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ForEach", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fbc4a8daf85549a4831bd49ec662d6a3()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_42030c3cee404cefaee6b3bf9ecda56b()})); - this.AddMember("GetRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2e7041f2c37f4e23855d392775ca02bc()})); - this.AddMember("IndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("IndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_378c87e012be4b24b4a825b15fc6edaa(), - new MTHD_e29c53477f15445da414e5906c9024e0(), - new MTHD_8a0c6e0b24264045a27d094ae65f8144()})); - this.AddMember("Insert", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Insert", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3d16ab2f2f83499493b873419b0c0bb7()})); - this.AddMember("InsertRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("InsertRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6a0ef46ad5c645f9be705b460cfbcb43()})); - this.AddMember("LastIndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("LastIndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_44de0fe24b354232b2ec16c363be6bac(), - new MTHD_88195228b36c419792bf8a56d1d61f72(), - new MTHD_740085423d7a4c2990ab983a0ad06078()})); - this.AddMember("Remove", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Remove", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a25034a4eaeb428a922e3dfcedde6b35()})); - this.AddMember("RemoveAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_752ce0218c9840ca86a0b1b61a70d626()})); - this.AddMember("RemoveAt", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAt", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f89b18059b7945a29682c5d3435b0679()})); - this.AddMember("RemoveRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_300082208c5d40ba908f2c0da50217c3()})); - this.AddMember("Reverse", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Reverse", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3bb5187542aa4a34b599153d3558ecf1(), - new MTHD_d9889b27c1fa49428245062b0d8f8242()})); - this.AddMember("Sort", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Sort", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_14fd2256fc0a4b068d1b7cc105fa9251(), - new MTHD_1fd65814a62244739ac20d878f8050f7(), - new MTHD_64c15750085140a3a642102e5ac4fca0(), - new MTHD_4cccfc6371bd411cbfdd76151cf43a6f()})); - this.AddMember("ToArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToArray", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6b528a80f1c84162a1ff076a7f2cf2be()})); - this.AddMember("TrimExcess", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrimExcess", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e5fca54d44d7404d8ce4e2756ec23078()})); - this.AddMember("TrueForAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrueForAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_407ffb2c566b417abdae39db08f5143b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e408124ea01145a6b6171c72f1a6cf92()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_55e5cc6755154d63b8fae52dc9c3b69d()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_568c681987094cd09c13966536c62b3c()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_05dba885a21f487aaea77d133be9169e()})); - this.AddMember("Capacity", new PROP_da6a10b435d340d5a01cbea2fe4deffb()); - this.AddMember("Count", new PROP_97c1fe2c60544e20a8baf5bf0f91e501()); - } - - private sealed class MTHD_afb8c106b74d4751aa13ef8e9c8f1905 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_afb8c106b74d4751aa13ef8e9c8f1905() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(); - } - } - - private sealed class MTHD_d80367843e2b41f4a93de8ed6206d67a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d80367843e2b41f4a93de8ed6206d67a() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((int)(pars[0]))); - } - } - - private sealed class MTHD_811b38a66d644cd29916c0dc9235af88 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_811b38a66d644cd29916c0dc9235af88() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((System.Collections.Generic.IEnumerable)(pars[0]))); - } - } - - private sealed class MTHD_3613719c7d194871945e31b20bd1743e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3613719c7d194871945e31b20bd1743e() - { - this.Initialize("get_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - } - - private sealed class MTHD_6b8b63f535f748eaa378f32897254bbc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6b8b63f535f748eaa378f32897254bbc() - { - this.Initialize("set_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_fa3b16d8d9704826971c7aa7165e68aa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fa3b16d8d9704826971c7aa7165e68aa() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - - private sealed class MTHD_b7b0dd98e501441f953af07669860863 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b7b0dd98e501441f953af07669860863() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_ae9f0e6563224103a76f2d2d358fcab0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae9f0e6563224103a76f2d2d358fcab0() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp[((int)(pars[0]))] = ((int)(pars[1])); - return null; - } - } - - private sealed class MTHD_616085b16f934e14a61d7aff991ad3a3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_616085b16f934e14a61d7aff991ad3a3() - { - this.Initialize("Add", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Add(((int)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ff728a7102ea415ab5e7efac0517282b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ff728a7102ea415ab5e7efac0517282b() - { - this.Initialize("AddRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).AddRange(((System.Collections.Generic.IEnumerable)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_15f6bea4eef14a73bef5ef3c2c7ac49b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_15f6bea4eef14a73bef5ef3c2c7ac49b() - { - this.Initialize("AsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).AsReadOnly(); - } - } - - private sealed class MTHD_d6c4c4e1acee4ba9a56c6c5a1b096999 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d6c4c4e1acee4ba9a56c6c5a1b096999() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((System.Collections.Generic.IComparer)(pars[3]))); - } - } - - private sealed class MTHD_0cad825d11754d07ab36d25f67c00540 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0cad825d11754d07ab36d25f67c00540() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0]))); - } - } - - private sealed class MTHD_1bce1812985c48c88f2181fa013438d4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1bce1812985c48c88f2181fa013438d4() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0])), ((System.Collections.Generic.IComparer)(pars[1]))); - } - } - - private sealed class MTHD_4027e99821eb48ffaba3d1469a25f38e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4027e99821eb48ffaba3d1469a25f38e() - { - this.Initialize("Clear", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Clear(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_8c708df507d84faaac617d5df3691ae6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8c708df507d84faaac617d5df3691ae6() - { - this.Initialize("Contains", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Contains(((int)(pars[0]))); - } - } - - private sealed class MTHD_a0adb855315f4d4f97493afe4321327f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a0adb855315f4d4f97493afe4321327f() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(int[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int[])(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_51d15a4e2e1f4b4d88c38d37546c2c4c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_51d15a4e2e1f4b4d88c38d37546c2c4c() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(int[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int)(pars[0])), ((int[])(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_0399bb34e99442f09439e4d26d928b99 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0399bb34e99442f09439e4d26d928b99() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(int[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int[])(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a8574139c28e4796b26d9e5c636dcee1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a8574139c28e4796b26d9e5c636dcee1() - { - this.Initialize("Exists", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Exists(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_434cec04b69e455eb58fd5f8a5d1a9e8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_434cec04b69e455eb58fd5f8a5d1a9e8() - { - this.Initialize("Find", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Find(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_1628c8aac9ab40deb463bda80614ff2a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1628c8aac9ab40deb463bda80614ff2a() - { - this.Initialize("FindAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_119e3def72cf4942a84d55ca80f71408 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_119e3def72cf4942a84d55ca80f71408() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_d20bb63016704e799c3577a0e92f9b29 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d20bb63016704e799c3577a0e92f9b29() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_921f8c4471604bf2810e287b98132d57 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_921f8c4471604bf2810e287b98132d57() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_c36db91411c14ec9a61d38299eb02ac8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c36db91411c14ec9a61d38299eb02ac8() - { - this.Initialize("FindLast", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLast(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_01ced101ce6c47be8e7f10feb8b34ceb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_01ced101ce6c47be8e7f10feb8b34ceb() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_2482cfe973074232a34750d3b42441c4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2482cfe973074232a34750d3b42441c4() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_6b95d9c0f21341e593ef060194e514cd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6b95d9c0f21341e593ef060194e514cd() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_fbc4a8daf85549a4831bd49ec662d6a3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fbc4a8daf85549a4831bd49ec662d6a3() - { - this.Initialize("ForEach", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("action", typeof(System.Action), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).ForEach(((System.Action)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_42030c3cee404cefaee6b3bf9ecda56b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_42030c3cee404cefaee6b3bf9ecda56b() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_2e7041f2c37f4e23855d392775ca02bc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2e7041f2c37f4e23855d392775ca02bc() - { - this.Initialize("GetRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetRange(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_378c87e012be4b24b4a825b15fc6edaa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_378c87e012be4b24b4a825b15fc6edaa() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((int)(pars[0]))); - } - } - - private sealed class MTHD_e29c53477f15445da414e5906c9024e0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e29c53477f15445da414e5906c9024e0() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_8a0c6e0b24264045a27d094ae65f8144 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8a0c6e0b24264045a27d094ae65f8144() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_3d16ab2f2f83499493b873419b0c0bb7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3d16ab2f2f83499493b873419b0c0bb7() - { - this.Initialize("Insert", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Insert(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6a0ef46ad5c645f9be705b460cfbcb43 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6a0ef46ad5c645f9be705b460cfbcb43() - { - this.Initialize("InsertRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).InsertRange(((int)(pars[0])), ((System.Collections.Generic.IEnumerable)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_44de0fe24b354232b2ec16c363be6bac : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_44de0fe24b354232b2ec16c363be6bac() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((int)(pars[0]))); - } - } - - private sealed class MTHD_88195228b36c419792bf8a56d1d61f72 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_88195228b36c419792bf8a56d1d61f72() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_740085423d7a4c2990ab983a0ad06078 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_740085423d7a4c2990ab983a0ad06078() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_a25034a4eaeb428a922e3dfcedde6b35 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a25034a4eaeb428a922e3dfcedde6b35() - { - this.Initialize("Remove", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Remove(((int)(pars[0]))); - } - } - - private sealed class MTHD_752ce0218c9840ca86a0b1b61a70d626 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_752ce0218c9840ca86a0b1b61a70d626() - { - this.Initialize("RemoveAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).RemoveAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_f89b18059b7945a29682c5d3435b0679 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f89b18059b7945a29682c5d3435b0679() - { - this.Initialize("RemoveAt", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveAt(((int)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_300082208c5d40ba908f2c0da50217c3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_300082208c5d40ba908f2c0da50217c3() - { - this.Initialize("RemoveRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveRange(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3bb5187542aa4a34b599153d3558ecf1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3bb5187542aa4a34b599153d3558ecf1() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_d9889b27c1fa49428245062b0d8f8242 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d9889b27c1fa49428245062b0d8f8242() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_14fd2256fc0a4b068d1b7cc105fa9251 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_14fd2256fc0a4b068d1b7cc105fa9251() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_1fd65814a62244739ac20d878f8050f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1fd65814a62244739ac20d878f8050f7() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Collections.Generic.IComparer)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_64c15750085140a3a642102e5ac4fca0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_64c15750085140a3a642102e5ac4fca0() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((int)(pars[0])), ((int)(pars[1])), ((System.Collections.Generic.IComparer)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_4cccfc6371bd411cbfdd76151cf43a6f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4cccfc6371bd411cbfdd76151cf43a6f() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparison", typeof(System.Comparison), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Comparison)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6b528a80f1c84162a1ff076a7f2cf2be : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6b528a80f1c84162a1ff076a7f2cf2be() - { - this.Initialize("ToArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).ToArray(); - } - } - - private sealed class MTHD_e5fca54d44d7404d8ce4e2756ec23078 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e5fca54d44d7404d8ce4e2756ec23078() - { - this.Initialize("TrimExcess", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).TrimExcess(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_407ffb2c566b417abdae39db08f5143b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_407ffb2c566b417abdae39db08f5143b() - { - this.Initialize("TrueForAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).TrueForAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_e408124ea01145a6b6171c72f1a6cf92 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e408124ea01145a6b6171c72f1a6cf92() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_55e5cc6755154d63b8fae52dc9c3b69d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_55e5cc6755154d63b8fae52dc9c3b69d() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_568c681987094cd09c13966536c62b3c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_568c681987094cd09c13966536c62b3c() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_05dba885a21f487aaea77d133be9169e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_05dba885a21f487aaea77d133be9169e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_da6a10b435d340d5a01cbea2fe4deffb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_da6a10b435d340d5a01cbea2fe4deffb() : - base(typeof(int), "Capacity", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(value)); - } - } - - private sealed class PROP_97c1fe2c60544e20a8baf5bf0f91e501 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_97c1fe2c60544e20a8baf5bf0f91e501() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of System.Int32[] - // Descriptor of System.Int32[] - private sealed class TYPE_c142762d43fa4da88b624f4c928cd065 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_c142762d43fa4da88b624f4c928cd065() : - base(typeof(int[])) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4d33d06ef349464fb3c101d6c2600f21()})); - this.AddMember("Set", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Set", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("Address", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Address", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("GetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetValue", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_257a1325ac884d209bbbdfd4ed36376b(), - new MTHD_3d054e4834014f38ad5b29691c687b35(), - new MTHD_15ff51e17ecc4ff38e662b9ef8e37f3c(), - new MTHD_e9aa9fd693214bb7b2d0839c6f594849(), - new MTHD_5869a18d07354a47997674a81ef8b55a(), - new MTHD_11804194c1f24a588b87af605ac7888d(), - new MTHD_22c47ff2e0684318b46c9eaee3b57e11(), - new MTHD_bd4562cb6d354175a90d2582fba2c7bf()})); - this.AddMember("SetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetValue", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fb90eefdfa774399b8db09c30e1fb2fd(), - new MTHD_a7c25e7d17a04be5b5a4f9d09deed5b5(), - new MTHD_c4558181f4c441bd9accc7646d15be89(), - new MTHD_216ca376a56643028db182c20809f7b1(), - new MTHD_50245e470347462dbeb83eca058f4ae0(), - new MTHD_c75b595e74d14e919c4f9e7cdc04bd49(), - new MTHD_e3311820b3b44adb8427d27014586d2e(), - new MTHD_57e8131b0c2e4e94b3feae28bc379164()})); - this.AddMember("get_Length", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Length", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_156c4fd8efec45c48ce6160848b7906a()})); - this.AddMember("get_LongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_LongLength", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ebe91397376b409288f07bdd0e23db5f()})); - this.AddMember("GetLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLength", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6058b99ef9794dc99f5fb3ab6f6c0f18()})); - this.AddMember("GetLongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLongLength", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_92d43a7537d446d192dd4ba05be3e928()})); - this.AddMember("get_Rank", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Rank", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b463c2dc0064466790df9681acf84c85()})); - this.AddMember("GetUpperBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetUpperBound", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8ac7fd6bf71f4c6d9b5581ed7a5fb6ce()})); - this.AddMember("GetLowerBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLowerBound", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3316818a78d347f58b5567fd300e2732()})); - this.AddMember("get_SyncRoot", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_SyncRoot", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4781788832bf4ee7bea152acb9071ce1()})); - this.AddMember("get_IsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsReadOnly", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a8c7611488e649588d44374d322aae20()})); - this.AddMember("get_IsFixedSize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsFixedSize", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e78a46c5a8144c79b9f654d162f32c17()})); - this.AddMember("get_IsSynchronized", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsSynchronized", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e2d45050f4bf4cb6b7bde50ffe9582b0()})); - this.AddMember("Clone", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clone", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e5940f7b155a46669faf5c7086b80537()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_616906edea6c414681b8a3b57a528f11(), - new MTHD_e78d741b9fa04c4283874cffacadf0fe()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cd2431cf9e454e14a694ac0368558616()})); - this.AddMember("Initialize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Initialize", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9526e320c0df431cb599b051c70b4f64()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_46f3072a8fa14259b68fd9a99ea9385d()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_375efac28c0d4bff87de2a2cba50cd09()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_16b67510dc3a4ab98a82bb75cdf96bc1()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7c0d0b372e7d4088afda934843425e2f()})); - this.AddMember("Length", new PROP_7c933b0fd9364e60a00e60e374dfaca5()); - this.AddMember("LongLength", new PROP_1037c5c6a91346f6997781816737aea0()); - this.AddMember("Rank", new PROP_3912c0a6cc8b423896a884b04ee4a47d()); - this.AddMember("SyncRoot", new PROP_e1eaff8a26c64e17b49d4ca109517562()); - this.AddMember("IsReadOnly", new PROP_2f502cf54acd4059bd19ee2cc0695866()); - this.AddMember("IsFixedSize", new PROP_1906bd5fec404e32919480fd0a8ae052()); - this.AddMember("IsSynchronized", new PROP_fa4c8173bc7849f19a09b2716ba9c619()); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_dcf59393291f4ded9c3b002722d4be00()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(int[]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_950639da05cc4bce857537a45c29400d()})); - } - - private sealed class MTHD_4d33d06ef349464fb3c101d6c2600f21 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4d33d06ef349464fb3c101d6c2600f21() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new int[] { - ((int)(pars[0]))}; - } - } - - private sealed class MTHD_257a1325ac884d209bbbdfd4ed36376b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_257a1325ac884d209bbbdfd4ed36376b() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int[])(pars[0]))); - } - } - - private sealed class MTHD_3d054e4834014f38ad5b29691c687b35 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3d054e4834014f38ad5b29691c687b35() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0]))); - } - } - - private sealed class MTHD_15ff51e17ecc4ff38e662b9ef8e37f3c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_15ff51e17ecc4ff38e662b9ef8e37f3c() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_e9aa9fd693214bb7b2d0839c6f594849 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e9aa9fd693214bb7b2d0839c6f594849() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_5869a18d07354a47997674a81ef8b55a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5869a18d07354a47997674a81ef8b55a() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0]))); - } - } - - private sealed class MTHD_11804194c1f24a588b87af605ac7888d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_11804194c1f24a588b87af605ac7888d() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1]))); - } - } - - private sealed class MTHD_22c47ff2e0684318b46c9eaee3b57e11 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_22c47ff2e0684318b46c9eaee3b57e11() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - } - } - - private sealed class MTHD_bd4562cb6d354175a90d2582fba2c7bf : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bd4562cb6d354175a90d2582fba2c7bf() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long[])(pars[0]))); - } - } - - private sealed class MTHD_fb90eefdfa774399b8db09c30e1fb2fd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fb90eefdfa774399b8db09c30e1fb2fd() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a7c25e7d17a04be5b5a4f9d09deed5b5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a7c25e7d17a04be5b5a4f9d09deed5b5() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c4558181f4c441bd9accc7646d15be89 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c4558181f4c441bd9accc7646d15be89() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_216ca376a56643028db182c20809f7b1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_216ca376a56643028db182c20809f7b1() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_50245e470347462dbeb83eca058f4ae0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_50245e470347462dbeb83eca058f4ae0() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c75b595e74d14e919c4f9e7cdc04bd49 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c75b595e74d14e919c4f9e7cdc04bd49() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_e3311820b3b44adb8427d27014586d2e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e3311820b3b44adb8427d27014586d2e() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2])), ((long)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_57e8131b0c2e4e94b3feae28bc379164 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_57e8131b0c2e4e94b3feae28bc379164() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_156c4fd8efec45c48ce6160848b7906a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_156c4fd8efec45c48ce6160848b7906a() - { - this.Initialize("get_Length", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class MTHD_ebe91397376b409288f07bdd0e23db5f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ebe91397376b409288f07bdd0e23db5f() - { - this.Initialize("get_LongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class MTHD_6058b99ef9794dc99f5fb3ab6f6c0f18 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6058b99ef9794dc99f5fb3ab6f6c0f18() - { - this.Initialize("GetLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_92d43a7537d446d192dd4ba05be3e928 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_92d43a7537d446d192dd4ba05be3e928() - { - this.Initialize("GetLongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLongLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_b463c2dc0064466790df9681acf84c85 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b463c2dc0064466790df9681acf84c85() - { - this.Initialize("get_Rank", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class MTHD_8ac7fd6bf71f4c6d9b5581ed7a5fb6ce : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ac7fd6bf71f4c6d9b5581ed7a5fb6ce() - { - this.Initialize("GetUpperBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetUpperBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_3316818a78d347f58b5567fd300e2732 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3316818a78d347f58b5567fd300e2732() - { - this.Initialize("GetLowerBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLowerBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_4781788832bf4ee7bea152acb9071ce1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4781788832bf4ee7bea152acb9071ce1() - { - this.Initialize("get_SyncRoot", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class MTHD_a8c7611488e649588d44374d322aae20 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a8c7611488e649588d44374d322aae20() - { - this.Initialize("get_IsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class MTHD_e78a46c5a8144c79b9f654d162f32c17 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e78a46c5a8144c79b9f654d162f32c17() - { - this.Initialize("get_IsFixedSize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class MTHD_e2d45050f4bf4cb6b7bde50ffe9582b0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e2d45050f4bf4cb6b7bde50ffe9582b0() - { - this.Initialize("get_IsSynchronized", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class MTHD_e5940f7b155a46669faf5c7086b80537 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e5940f7b155a46669faf5c7086b80537() - { - this.Initialize("Clone", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Clone(); - } - } - - private sealed class MTHD_616906edea6c414681b8a3b57a528f11 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_616906edea6c414681b8a3b57a528f11() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_e78d741b9fa04c4283874cffacadf0fe : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e78d741b9fa04c4283874cffacadf0fe() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_cd2431cf9e454e14a694ac0368558616 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cd2431cf9e454e14a694ac0368558616() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_9526e320c0df431cb599b051c70b4f64 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9526e320c0df431cb599b051c70b4f64() - { - this.Initialize("Initialize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).Initialize(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_46f3072a8fa14259b68fd9a99ea9385d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_46f3072a8fa14259b68fd9a99ea9385d() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_375efac28c0d4bff87de2a2cba50cd09 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_375efac28c0d4bff87de2a2cba50cd09() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_16b67510dc3a4ab98a82bb75cdf96bc1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_16b67510dc3a4ab98a82bb75cdf96bc1() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_7c0d0b372e7d4088afda934843425e2f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7c0d0b372e7d4088afda934843425e2f() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_7c933b0fd9364e60a00e60e374dfaca5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_7c933b0fd9364e60a00e60e374dfaca5() : - base(typeof(int), "Length", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class PROP_1037c5c6a91346f6997781816737aea0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_1037c5c6a91346f6997781816737aea0() : - base(typeof(long), "LongLength", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class PROP_3912c0a6cc8b423896a884b04ee4a47d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_3912c0a6cc8b423896a884b04ee4a47d() : - base(typeof(int), "Rank", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class PROP_e1eaff8a26c64e17b49d4ca109517562 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_e1eaff8a26c64e17b49d4ca109517562() : - base(typeof(object), "SyncRoot", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class PROP_2f502cf54acd4059bd19ee2cc0695866 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_2f502cf54acd4059bd19ee2cc0695866() : - base(typeof(bool), "IsReadOnly", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class PROP_1906bd5fec404e32919480fd0a8ae052 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_1906bd5fec404e32919480fd0a8ae052() : - base(typeof(bool), "IsFixedSize", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class PROP_fa4c8173bc7849f19a09b2716ba9c619 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_fa4c8173bc7849f19a09b2716ba9c619() : - base(typeof(bool), "IsSynchronized", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class AIDX_dcf59393291f4ded9c3b002722d4be00 : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_dcf59393291f4ded9c3b002722d4be00() : - base("set_Item", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}) - { - } - } - - private sealed class AIDX_950639da05cc4bce857537a45c29400d : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_950639da05cc4bce857537a45c29400d() : - base("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false)}) - { - } - } - } - #endregion - - #region Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - // Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - private sealed class TYPE_8f6f2e3c154e4ac8a127ef998b64b06b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_8f6f2e3c154e4ac8a127ef998b64b06b() : - base(typeof(System.Collections.Generic.List)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_70b4fa6bfb574936b6f9c39f01f1dad6(), - new MTHD_b38288f975f44db49ac7bba8fc4b8788(), - new MTHD_dcd811c542a64e2e8160e4a97a2ce455()})); - this.AddMember("get_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_99d4b9a420de445da62c20a0d656786e()})); - this.AddMember("set_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5d5cfb10631d417fad98198772c499fd()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dc426c283fa842c3ae73c1063edc9aea()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_35f04082058148808709220bdf49b213()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a748699ff05447859268c43b4743e649()})); - this.AddMember("Add", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Add", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_765d7878ab4e49e0a9c7c579c8fcd255()})); - this.AddMember("AddRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AddRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cd75653c3b6a43c08ad77e9b81de8dc1()})); - this.AddMember("AsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AsReadOnly", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ace205271d5e4f5db17aac545cb9a385()})); - this.AddMember("BinarySearch", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("BinarySearch", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e1949359e739492cb132e258729e8d9f(), - new MTHD_72556f520af747c09d6ac40a26ad3bee(), - new MTHD_1f67cf307a9a40d2ba1862ed68316b0b()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_be734c11a70b4dcf802499f11cccc6c4()})); - this.AddMember("Contains", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Contains", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_682ae66a48ea436fa6a406781de6e52d()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_44918e73eab145698b4e48582c692b56(), - new MTHD_47e9a5957df142db937f094d06538d91(), - new MTHD_1688adfc087245ceb38330178ca3f059()})); - this.AddMember("Exists", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Exists", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c6c1ea7a84bb4badb6df9be25eb92273()})); - this.AddMember("Find", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Find", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_08234ec4a1cc41f9bc36b6743b3bb3f0()})); - this.AddMember("FindAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_62131faf30d048af8b148e05e8bff57a()})); - this.AddMember("FindIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4ef6d2f523264518abfd955f8d53c4cb(), - new MTHD_232454b7e5c14e71a053b7c01d7f0752(), - new MTHD_0b1716de51bb45bda807e4c24aa4ee59()})); - this.AddMember("FindLast", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLast", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2ac3d1f111f241cb9e5ba612c2e48c9c()})); - this.AddMember("FindLastIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLastIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d724f863dfef41c8af2dcc8bd5fe9eee(), - new MTHD_a1bb2b0e69944aa59564104b21a305ee(), - new MTHD_c62e1f426d1d4a079829e98b79de1c6e()})); - this.AddMember("ForEach", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ForEach", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ebb4f823391e4eada8d27258f01e30ee()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7d99afb81983467f9429651d8a927a40()})); - this.AddMember("GetRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3caa9c2446124d4782e0f14d4ac66e98()})); - this.AddMember("IndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("IndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_64c84873613c4fc18571821953e5b607(), - new MTHD_eabb104536d5468fbbc2137f6ea7da75(), - new MTHD_6ff39139ece24387a75ef89e6b408228()})); - this.AddMember("Insert", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Insert", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b2687345deac41839f39a9c65035a767()})); - this.AddMember("InsertRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("InsertRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8f773547500a4e199385ae8a53a2a5d1()})); - this.AddMember("LastIndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("LastIndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_43d4c3be16564bc9b4ea0f00f785cd94(), - new MTHD_5f3b9dbfcbba4121acb96791060ca302(), - new MTHD_b103a8f3ca22490ea0b46af141f04aba()})); - this.AddMember("Remove", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Remove", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_06b75cdc9c6c432ca8c14d523b446dab()})); - this.AddMember("RemoveAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1aa352c398884bc18477f8d6ee5c2cc3()})); - this.AddMember("RemoveAt", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAt", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_295c2a72edb64be1b275197470195a5d()})); - this.AddMember("RemoveRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f86b901b4e76442a97211f55132c9d70()})); - this.AddMember("Reverse", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Reverse", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8aabf3066a4a4b8d83e43d67d31a5102(), - new MTHD_6086d54c6b39426ea055e9b62dd5d450()})); - this.AddMember("Sort", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Sort", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_45ca2394edee471fbf312f57ad173714(), - new MTHD_ea9cf78ca41044ae89e955c7be5e0586(), - new MTHD_d1cdf680d4834791b683ad2437faf37e(), - new MTHD_f9677c8e002f46c9b51c0f037eb950ab()})); - this.AddMember("ToArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToArray", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b199102591b448f0959164dd841d998e()})); - this.AddMember("TrimExcess", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrimExcess", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c0f403398ce943f5ab60899930940a33()})); - this.AddMember("TrueForAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrueForAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6239b58b947e4271b471771fbb1e12a9()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a84e9230d5c74c5aafd6214ba00949f6()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f058c1ecd8504656b470b2d3931dad48()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7045586359d64aeeb8e115cd546fce79()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a9096e436dfc41c8857a16aab98c9e2e()})); - this.AddMember("Capacity", new PROP_7b4184d775484904ad5b06b91551618f()); - this.AddMember("Count", new PROP_f1455a724fb741c3b9c46689968b04eb()); - } - - private sealed class MTHD_70b4fa6bfb574936b6f9c39f01f1dad6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_70b4fa6bfb574936b6f9c39f01f1dad6() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(); - } - } - - private sealed class MTHD_b38288f975f44db49ac7bba8fc4b8788 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b38288f975f44db49ac7bba8fc4b8788() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((int)(pars[0]))); - } - } - - private sealed class MTHD_dcd811c542a64e2e8160e4a97a2ce455 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dcd811c542a64e2e8160e4a97a2ce455() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((System.Collections.Generic.IEnumerable)(pars[0]))); - } - } - - private sealed class MTHD_99d4b9a420de445da62c20a0d656786e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_99d4b9a420de445da62c20a0d656786e() - { - this.Initialize("get_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - } - - private sealed class MTHD_5d5cfb10631d417fad98198772c499fd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5d5cfb10631d417fad98198772c499fd() - { - this.Initialize("set_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_dc426c283fa842c3ae73c1063edc9aea : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dc426c283fa842c3ae73c1063edc9aea() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - - private sealed class MTHD_35f04082058148808709220bdf49b213 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_35f04082058148808709220bdf49b213() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_a748699ff05447859268c43b4743e649 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a748699ff05447859268c43b4743e649() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp[((int)(pars[0]))] = ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[1])); - return null; - } - } - - private sealed class MTHD_765d7878ab4e49e0a9c7c579c8fcd255 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_765d7878ab4e49e0a9c7c579c8fcd255() - { - this.Initialize("Add", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Add(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_cd75653c3b6a43c08ad77e9b81de8dc1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cd75653c3b6a43c08ad77e9b81de8dc1() - { - this.Initialize("AddRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).AddRange(((System.Collections.Generic.IEnumerable)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ace205271d5e4f5db17aac545cb9a385 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ace205271d5e4f5db17aac545cb9a385() - { - this.Initialize("AsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).AsReadOnly(); - } - } - - private sealed class MTHD_e1949359e739492cb132e258729e8d9f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e1949359e739492cb132e258729e8d9f() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0])), ((int)(pars[1])), ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[2])), ((System.Collections.Generic.IComparer)(pars[3]))); - } - } - - private sealed class MTHD_72556f520af747c09d6ac40a26ad3bee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_72556f520af747c09d6ac40a26ad3bee() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_1f67cf307a9a40d2ba1862ed68316b0b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1f67cf307a9a40d2ba1862ed68316b0b() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0])), ((System.Collections.Generic.IComparer)(pars[1]))); - } - } - - private sealed class MTHD_be734c11a70b4dcf802499f11cccc6c4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_be734c11a70b4dcf802499f11cccc6c4() - { - this.Initialize("Clear", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Clear(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_682ae66a48ea436fa6a406781de6e52d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_682ae66a48ea436fa6a406781de6e52d() - { - this.Initialize("Contains", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Contains(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_44918e73eab145698b4e48582c692b56 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_44918e73eab145698b4e48582c692b56() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[])(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_47e9a5957df142db937f094d06538d91 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_47e9a5957df142db937f094d06538d91() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[])(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_1688adfc087245ceb38330178ca3f059 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1688adfc087245ceb38330178ca3f059() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem[])(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c6c1ea7a84bb4badb6df9be25eb92273 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c6c1ea7a84bb4badb6df9be25eb92273() - { - this.Initialize("Exists", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Exists(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_08234ec4a1cc41f9bc36b6743b3bb3f0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_08234ec4a1cc41f9bc36b6743b3bb3f0() - { - this.Initialize("Find", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Find(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_62131faf30d048af8b148e05e8bff57a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_62131faf30d048af8b148e05e8bff57a() - { - this.Initialize("FindAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_4ef6d2f523264518abfd955f8d53c4cb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4ef6d2f523264518abfd955f8d53c4cb() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_232454b7e5c14e71a053b7c01d7f0752 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_232454b7e5c14e71a053b7c01d7f0752() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_0b1716de51bb45bda807e4c24aa4ee59 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0b1716de51bb45bda807e4c24aa4ee59() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_2ac3d1f111f241cb9e5ba612c2e48c9c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2ac3d1f111f241cb9e5ba612c2e48c9c() - { - this.Initialize("FindLast", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLast(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_d724f863dfef41c8af2dcc8bd5fe9eee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d724f863dfef41c8af2dcc8bd5fe9eee() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_a1bb2b0e69944aa59564104b21a305ee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a1bb2b0e69944aa59564104b21a305ee() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_c62e1f426d1d4a079829e98b79de1c6e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c62e1f426d1d4a079829e98b79de1c6e() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_ebb4f823391e4eada8d27258f01e30ee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ebb4f823391e4eada8d27258f01e30ee() - { - this.Initialize("ForEach", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("action", typeof(System.Action), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).ForEach(((System.Action)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_7d99afb81983467f9429651d8a927a40 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7d99afb81983467f9429651d8a927a40() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_3caa9c2446124d4782e0f14d4ac66e98 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3caa9c2446124d4782e0f14d4ac66e98() - { - this.Initialize("GetRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetRange(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_64c84873613c4fc18571821953e5b607 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_64c84873613c4fc18571821953e5b607() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_eabb104536d5468fbbc2137f6ea7da75 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eabb104536d5468fbbc2137f6ea7da75() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_6ff39139ece24387a75ef89e6b408228 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6ff39139ece24387a75ef89e6b408228() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_b2687345deac41839f39a9c65035a767 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b2687345deac41839f39a9c65035a767() - { - this.Initialize("Insert", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Insert(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_8f773547500a4e199385ae8a53a2a5d1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8f773547500a4e199385ae8a53a2a5d1() - { - this.Initialize("InsertRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).InsertRange(((int)(pars[0])), ((System.Collections.Generic.IEnumerable)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_43d4c3be16564bc9b4ea0f00f785cd94 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_43d4c3be16564bc9b4ea0f00f785cd94() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_5f3b9dbfcbba4121acb96791060ca302 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5f3b9dbfcbba4121acb96791060ca302() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_b103a8f3ca22490ea0b46af141f04aba : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b103a8f3ca22490ea0b46af141f04aba() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_06b75cdc9c6c432ca8c14d523b446dab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_06b75cdc9c6c432ca8c14d523b446dab() - { - this.Initialize("Remove", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Remove(((MoonSharp.Interpreter.Tests.EndToEnd.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_1aa352c398884bc18477f8d6ee5c2cc3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1aa352c398884bc18477f8d6ee5c2cc3() - { - this.Initialize("RemoveAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).RemoveAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_295c2a72edb64be1b275197470195a5d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_295c2a72edb64be1b275197470195a5d() - { - this.Initialize("RemoveAt", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveAt(((int)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f86b901b4e76442a97211f55132c9d70 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f86b901b4e76442a97211f55132c9d70() - { - this.Initialize("RemoveRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveRange(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_8aabf3066a4a4b8d83e43d67d31a5102 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8aabf3066a4a4b8d83e43d67d31a5102() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6086d54c6b39426ea055e9b62dd5d450 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6086d54c6b39426ea055e9b62dd5d450() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_45ca2394edee471fbf312f57ad173714 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_45ca2394edee471fbf312f57ad173714() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ea9cf78ca41044ae89e955c7be5e0586 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ea9cf78ca41044ae89e955c7be5e0586() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Collections.Generic.IComparer)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_d1cdf680d4834791b683ad2437faf37e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d1cdf680d4834791b683ad2437faf37e() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((int)(pars[0])), ((int)(pars[1])), ((System.Collections.Generic.IComparer)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f9677c8e002f46c9b51c0f037eb950ab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f9677c8e002f46c9b51c0f037eb950ab() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparison", typeof(System.Comparison), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Comparison)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_b199102591b448f0959164dd841d998e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b199102591b448f0959164dd841d998e() - { - this.Initialize("ToArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).ToArray(); - } - } - - private sealed class MTHD_c0f403398ce943f5ab60899930940a33 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c0f403398ce943f5ab60899930940a33() - { - this.Initialize("TrimExcess", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).TrimExcess(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6239b58b947e4271b471771fbb1e12a9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6239b58b947e4271b471771fbb1e12a9() - { - this.Initialize("TrueForAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).TrueForAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_a84e9230d5c74c5aafd6214ba00949f6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a84e9230d5c74c5aafd6214ba00949f6() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_f058c1ecd8504656b470b2d3931dad48 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f058c1ecd8504656b470b2d3931dad48() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_7045586359d64aeeb8e115cd546fce79 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7045586359d64aeeb8e115cd546fce79() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_a9096e436dfc41c8857a16aab98c9e2e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a9096e436dfc41c8857a16aab98c9e2e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_7b4184d775484904ad5b06b91551618f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_7b4184d775484904ad5b06b91551618f() : - base(typeof(int), "Capacity", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(value)); - } - } - - private sealed class PROP_f1455a724fb741c3b9c46689968b04eb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_f1455a724fb741c3b9c46689968b04eb() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollMethods - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollMethods - private sealed class TYPE_c8d44043712740c180e31cf9a5ec5893 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_c8d44043712740c180e31cf9a5ec5893() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_355e9dee7a82422d9ac12aa95f85e03d()})); - this.AddMember("GetMultiArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetMultiArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4d0ae649d3da4a6fa1f1148d014adaec()})); - this.AddMember("GetArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9cc2443dfff34253a2be6677dc7c6a3e()})); - this.AddMember("GetItems", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetItems", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_12861584f8b244f3b7b0e26513a109cb()})); - this.AddMember("GetList", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetList", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_edcae6bbef70442182240258693890a5()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_94c3d04f5de944329f50e2bbc5317962()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6acc1dd533fc45fdb26525c8fa800f01()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_217b82a43d304b9481f3d42924ad40a3()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4a5abf95aa0b4254ac08f1b275e9f42d()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_64a254f02d304e2fafac734c0addcb2c()})); - } - - private sealed class MTHD_355e9dee7a82422d9ac12aa95f85e03d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_355e9dee7a82422d9ac12aa95f85e03d() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods(); - } - } - - private sealed class MTHD_4d0ae649d3da4a6fa1f1148d014adaec : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4d0ae649d3da4a6fa1f1148d014adaec() - { - this.Initialize("GetMultiArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)(obj)).GetMultiArray(); - } - } - - private sealed class MTHD_9cc2443dfff34253a2be6677dc7c6a3e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9cc2443dfff34253a2be6677dc7c6a3e() - { - this.Initialize("GetArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)(obj)).GetArray(); - } - } - - private sealed class MTHD_12861584f8b244f3b7b0e26513a109cb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_12861584f8b244f3b7b0e26513a109cb() - { - this.Initialize("GetItems", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)(obj)).GetItems(); - } - } - - private sealed class MTHD_edcae6bbef70442182240258693890a5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_edcae6bbef70442182240258693890a5() - { - this.Initialize("GetList", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)(obj)).GetList(); - } - } - - private sealed class MTHD_94c3d04f5de944329f50e2bbc5317962 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_94c3d04f5de944329f50e2bbc5317962() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollMethods)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_6acc1dd533fc45fdb26525c8fa800f01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6acc1dd533fc45fdb26525c8fa800f01() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_217b82a43d304b9481f3d42924ad40a3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_217b82a43d304b9481f3d42924ad40a3() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_4a5abf95aa0b4254ac08f1b275e9f42d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4a5abf95aa0b4254ac08f1b275e9f42d() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_64a254f02d304e2fafac734c0addcb2c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_64a254f02d304e2fafac734c0addcb2c() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollItem - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollItem - private sealed class TYPE_9ccc3059bc124dbea894c97ceed6e510 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_9ccc3059bc124dbea894c97ceed6e510() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae75542a548246909fdfcd523fa6bc5a()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5d7ba0da6e2a4462970cec78b54482a8()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_120191ea67a04339a1bb89422e3d80a6()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fb20f31526524fd59c4293cca92583f9()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_214ee473c2c34ff28b680599c59b2b29()})); - this.AddMember("Value", new FLDV_ebf085ecf5004d608a347a0a7f2d2470()); - } - - private sealed class MTHD_ae75542a548246909fdfcd523fa6bc5a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae75542a548246909fdfcd523fa6bc5a() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem(((int)(pars[0]))); - } - } - - private sealed class MTHD_5d7ba0da6e2a4462970cec78b54482a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5d7ba0da6e2a4462970cec78b54482a8() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_120191ea67a04339a1bb89422e3d80a6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_120191ea67a04339a1bb89422e3d80a6() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_fb20f31526524fd59c4293cca92583f9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fb20f31526524fd59c4293cca92583f9() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_214ee473c2c34ff28b680599c59b2b29 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_214ee473c2c34ff28b680599c59b2b29() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_ebf085ecf5004d608a347a0a7f2d2470 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_ebf085ecf5004d608a347a0a7f2d2470() : - base(typeof(int), "Value", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(obj)).Value; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(obj)); - tmp.Value = ((int)(value)); - } - } - } - #endregion - - #region Descriptor of System.Array - // Descriptor of System.Array - private sealed class TYPE_cad5306f62694a019a0d2753e1d2fca3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_cad5306f62694a019a0d2753e1d2fca3() : - base(typeof(System.Array)) - { - this.AddMember("CreateInstance", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CreateInstance", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4fee7fc3e1e9451696cde23946be93b6(), - new MTHD_a7a12c70e82c48fd8acacec8356025b3(), - new MTHD_195e4ae911754722884408720e81217f(), - new MTHD_dcbd9d025a2b44d691880a0e517516c5(), - new MTHD_5f112044b541441f8bf8cb8f5ed9b120(), - new MTHD_09f0bff2a91a40b7a8072aa6e5ed372c()})); - this.AddMember("Copy", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Copy", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bba5b4b057cc48df9d981cf142748736(), - new MTHD_8ac60cb7a20d4ed990b940f28ed2321e(), - new MTHD_82012b17790c4382a68221afe48c5634(), - new MTHD_ae83ddbc82444762bf7080860542098c()})); - this.AddMember("ConstrainedCopy", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConstrainedCopy", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7e6fdc701ed84529aa84a84c1d768e86()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_937861abe53c4b44a54d21a61d544557()})); - this.AddMember("GetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetValue", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f45e4de0e34d443e94d39f1e1cf88706(), - new MTHD_ba06658eaa3d4f5f8723df3839cc4579(), - new MTHD_cc0444df9b3d467193b36b9b555275a8(), - new MTHD_28a78fc1dd5e4a719a22ecb5b51c50b0(), - new MTHD_7237eaf51f8d498b96b9aee6f53df88d(), - new MTHD_69941ddfbe0c44b38ce1087758d120a2(), - new MTHD_c78b556b054a465dba4934c6618483b5(), - new MTHD_07d8a713ede645e9a1e9db7f31a7167e()})); - this.AddMember("SetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetValue", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_17d6d6e0371b49bf99161a966d034219(), - new MTHD_3741dd6b4b3c4be2bf74cb9004e084c9(), - new MTHD_951088e4b276486796e85ffba570536e(), - new MTHD_b66043abee64487e8d2b235dacac67d1(), - new MTHD_faef216c22c5488aa25a37f6cace3353(), - new MTHD_ae21ac962b7647a5a09bbf10a5f7f8c1(), - new MTHD_34fcf4ac9f09408f82c98a0ed353ff3b(), - new MTHD_a355738a9ac94baa8b5698f68eebfb6c()})); - this.AddMember("get_Length", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Length", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f812728d7f4740f08da0762d3e180d22()})); - this.AddMember("get_LongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_LongLength", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9b0511ea59c24e6e89f4b7352d6f5593()})); - this.AddMember("GetLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLength", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c91fb72824ef437d99a422e54f8461a8()})); - this.AddMember("GetLongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLongLength", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_33f4cdd8b2a74a3fba3818b71bde89b9()})); - this.AddMember("get_Rank", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Rank", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_32ed90efadcf4e888e49291a349f7cdc()})); - this.AddMember("GetUpperBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetUpperBound", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae1c4f4fa5944ec69637c892a898c7a3()})); - this.AddMember("GetLowerBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLowerBound", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_68c5e1b79bfe4661ad45fd3463f1c246()})); - this.AddMember("get_SyncRoot", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_SyncRoot", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_333040a1d0c146db9911992c490f6b9c()})); - this.AddMember("get_IsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsReadOnly", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2f955b60af09477fb40e52d6944d14c9()})); - this.AddMember("get_IsFixedSize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsFixedSize", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dde6ff4262bf49d08f34ef6c0f8c88cb()})); - this.AddMember("get_IsSynchronized", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsSynchronized", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_78830d90b83445c39f46f641c4da9660()})); - this.AddMember("Clone", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clone", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_db3aac266d2b4501b805a6b89122db9e()})); - this.AddMember("BinarySearch", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("BinarySearch", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e73904e6c7ad47058d943baa40e70f85(), - new MTHD_6168ce2ef26d43289a87299aa4128c91(), - new MTHD_279dfaee82df4b33ae7e853be16fc998(), - new MTHD_2d9a7e89915e4e1cb1318d318e4b151f()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d565650c9725488aa39f64c71132c537(), - new MTHD_cee8a1b8a1094a5b8e7a9528759ccc72()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7ef591795d894cf699b471597a70af17()})); - this.AddMember("IndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("IndexOf", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_891bff63f6704a70821d90f33f1bffd5(), - new MTHD_879097071d2f4da4abc846e12970fa88(), - new MTHD_a74d3ef144c147baaf102a67f2f8bac3()})); - this.AddMember("LastIndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("LastIndexOf", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4e5b3cf3725a4483a2b9bbfe96d51fe1(), - new MTHD_97cda901bee94a04ba713cfcd87f494a(), - new MTHD_56e0b7d4b3b143078357223948fdc238()})); - this.AddMember("Reverse", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Reverse", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_151b9a85d12741e6be72f72679157036(), - new MTHD_25076e37ecb64d0782f9c9eb07ec31e6()})); - this.AddMember("Sort", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Sort", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7cb044102e4442afbc6f38d5f9bd5f80(), - new MTHD_9d59bc933d174901aae46c93d0b7a8ea(), - new MTHD_eceedc0a28744d16a6e7835d2c5b0983(), - new MTHD_ffd5bddc37bb4f67aa21a4b12f339178(), - new MTHD_81d827a4e65f42ba9371826161e0636d(), - new MTHD_93e11f8a0c3e4662a854941942eebbc8(), - new MTHD_fe509d8161034d4d95268548fb47c2ff(), - new MTHD_547c15e52fd34ffe9bbfe7c008a57891()})); - this.AddMember("Initialize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Initialize", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6a8e90770b1e4dc5aee0d29aa1f1939a()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0fe0ba30a7f948a5a3075943f11e0ca7()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1d9da14232f949989a1b4f1cceeb3224()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6c10fe8df9b34db3baa37febd2addeca()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b489db7e554f4ae9864d259c149cbbd4()})); - this.AddMember("Length", new PROP_1952e84d9d9345e4b2ac0dbb759af7fd()); - this.AddMember("LongLength", new PROP_54301e7e389043b5b1d4c83aecd60a5c()); - this.AddMember("Rank", new PROP_8dad3c2a4e914862a29b8bdc6faa16e7()); - this.AddMember("SyncRoot", new PROP_ad18274e4b564afebec7e40130972f56()); - this.AddMember("IsReadOnly", new PROP_6a8c9594559a43649f5fa03c937e642a()); - this.AddMember("IsFixedSize", new PROP_d21592e7deb5474db98699a252d90a97()); - this.AddMember("IsSynchronized", new PROP_e493445d44f14b5badbc3a97fac693e3()); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_1721802415b841b081c86d0bf8001cb4()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Array), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_f999fe33f5af45da885be5c9454bf9a9()})); - } - - private sealed class MTHD_4fee7fc3e1e9451696cde23946be93b6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4fee7fc3e1e9451696cde23946be93b6() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_a7a12c70e82c48fd8acacec8356025b3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a7a12c70e82c48fd8acacec8356025b3() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_195e4ae911754722884408720e81217f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_195e4ae911754722884408720e81217f() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - } - } - - private sealed class MTHD_dcbd9d025a2b44d691880a0e517516c5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dcbd9d025a2b44d691880a0e517516c5() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lengths", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((int[])(pars[1]))); - } - } - - private sealed class MTHD_5f112044b541441f8bf8cb8f5ed9b120 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5f112044b541441f8bf8cb8f5ed9b120() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lengths", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((long[])(pars[1]))); - } - } - - private sealed class MTHD_09f0bff2a91a40b7a8072aa6e5ed372c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_09f0bff2a91a40b7a8072aa6e5ed372c() - { - this.Initialize("CreateInstance", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("elementType", typeof(System.Type), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lengths", typeof(int[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lowerBounds", typeof(int[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.CreateInstance(((System.Type)(pars[0])), ((int[])(pars[1])), ((int[])(pars[2]))); - } - } - - private sealed class MTHD_bba5b4b057cc48df9d981cf142748736 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bba5b4b057cc48df9d981cf142748736() - { - this.Initialize("Copy", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Copy(((System.Array)(pars[0])), ((System.Array)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_8ac60cb7a20d4ed990b940f28ed2321e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ac60cb7a20d4ed990b940f28ed2321e() - { - this.Initialize("Copy", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Copy(((System.Array)(pars[0])), ((int)(pars[1])), ((System.Array)(pars[2])), ((int)(pars[3])), ((int)(pars[4]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_82012b17790c4382a68221afe48c5634 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_82012b17790c4382a68221afe48c5634() - { - this.Initialize("Copy", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Copy(((System.Array)(pars[0])), ((System.Array)(pars[1])), ((long)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ae83ddbc82444762bf7080860542098c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae83ddbc82444762bf7080860542098c() - { - this.Initialize("Copy", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceIndex", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationIndex", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Copy(((System.Array)(pars[0])), ((long)(pars[1])), ((System.Array)(pars[2])), ((long)(pars[3])), ((long)(pars[4]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_7e6fdc701ed84529aa84a84c1d768e86 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7e6fdc701ed84529aa84a84c1d768e86() - { - this.Initialize("ConstrainedCopy", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sourceIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationArray", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("destinationIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.ConstrainedCopy(((System.Array)(pars[0])), ((int)(pars[1])), ((System.Array)(pars[2])), ((int)(pars[3])), ((int)(pars[4]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_937861abe53c4b44a54d21a61d544557 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_937861abe53c4b44a54d21a61d544557() - { - this.Initialize("Clear", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Clear(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f45e4de0e34d443e94d39f1e1cf88706 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f45e4de0e34d443e94d39f1e1cf88706() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int[])(pars[0]))); - } - } - - private sealed class MTHD_ba06658eaa3d4f5f8723df3839cc4579 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ba06658eaa3d4f5f8723df3839cc4579() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0]))); - } - } - - private sealed class MTHD_cc0444df9b3d467193b36b9b555275a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cc0444df9b3d467193b36b9b555275a8() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_28a78fc1dd5e4a719a22ecb5b51c50b0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_28a78fc1dd5e4a719a22ecb5b51c50b0() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_7237eaf51f8d498b96b9aee6f53df88d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7237eaf51f8d498b96b9aee6f53df88d() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0]))); - } - } - - private sealed class MTHD_69941ddfbe0c44b38ce1087758d120a2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_69941ddfbe0c44b38ce1087758d120a2() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1]))); - } - } - - private sealed class MTHD_c78b556b054a465dba4934c6618483b5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c78b556b054a465dba4934c6618483b5() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - } - } - - private sealed class MTHD_07d8a713ede645e9a1e9db7f31a7167e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_07d8a713ede645e9a1e9db7f31a7167e() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long[])(pars[0]))); - } - } - - private sealed class MTHD_17d6d6e0371b49bf99161a966d034219 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_17d6d6e0371b49bf99161a966d034219() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3741dd6b4b3c4be2bf74cb9004e084c9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3741dd6b4b3c4be2bf74cb9004e084c9() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_951088e4b276486796e85ffba570536e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_951088e4b276486796e85ffba570536e() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_b66043abee64487e8d2b235dacac67d1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b66043abee64487e8d2b235dacac67d1() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_faef216c22c5488aa25a37f6cace3353 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_faef216c22c5488aa25a37f6cace3353() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ae21ac962b7647a5a09bbf10a5f7f8c1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae21ac962b7647a5a09bbf10a5f7f8c1() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_34fcf4ac9f09408f82c98a0ed353ff3b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_34fcf4ac9f09408f82c98a0ed353ff3b() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2])), ((long)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a355738a9ac94baa8b5698f68eebfb6c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a355738a9ac94baa8b5698f68eebfb6c() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f812728d7f4740f08da0762d3e180d22 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f812728d7f4740f08da0762d3e180d22() - { - this.Initialize("get_Length", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class MTHD_9b0511ea59c24e6e89f4b7352d6f5593 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9b0511ea59c24e6e89f4b7352d6f5593() - { - this.Initialize("get_LongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class MTHD_c91fb72824ef437d99a422e54f8461a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c91fb72824ef437d99a422e54f8461a8() - { - this.Initialize("GetLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_33f4cdd8b2a74a3fba3818b71bde89b9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_33f4cdd8b2a74a3fba3818b71bde89b9() - { - this.Initialize("GetLongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLongLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_32ed90efadcf4e888e49291a349f7cdc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_32ed90efadcf4e888e49291a349f7cdc() - { - this.Initialize("get_Rank", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class MTHD_ae1c4f4fa5944ec69637c892a898c7a3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae1c4f4fa5944ec69637c892a898c7a3() - { - this.Initialize("GetUpperBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetUpperBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_68c5e1b79bfe4661ad45fd3463f1c246 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_68c5e1b79bfe4661ad45fd3463f1c246() - { - this.Initialize("GetLowerBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLowerBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_333040a1d0c146db9911992c490f6b9c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_333040a1d0c146db9911992c490f6b9c() - { - this.Initialize("get_SyncRoot", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class MTHD_2f955b60af09477fb40e52d6944d14c9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2f955b60af09477fb40e52d6944d14c9() - { - this.Initialize("get_IsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class MTHD_dde6ff4262bf49d08f34ef6c0f8c88cb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dde6ff4262bf49d08f34ef6c0f8c88cb() - { - this.Initialize("get_IsFixedSize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class MTHD_78830d90b83445c39f46f641c4da9660 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_78830d90b83445c39f46f641c4da9660() - { - this.Initialize("get_IsSynchronized", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class MTHD_db3aac266d2b4501b805a6b89122db9e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_db3aac266d2b4501b805a6b89122db9e() - { - this.Initialize("Clone", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Clone(); - } - } - - private sealed class MTHD_e73904e6c7ad47058d943baa40e70f85 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e73904e6c7ad47058d943baa40e70f85() - { - this.Initialize("BinarySearch", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.BinarySearch(((System.Array)(pars[0])), ((object)(pars[1]))); - } - } - - private sealed class MTHD_6168ce2ef26d43289a87299aa4128c91 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6168ce2ef26d43289a87299aa4128c91() - { - this.Initialize("BinarySearch", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.BinarySearch(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((object)(pars[3]))); - } - } - - private sealed class MTHD_279dfaee82df4b33ae7e853be16fc998 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_279dfaee82df4b33ae7e853be16fc998() - { - this.Initialize("BinarySearch", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.BinarySearch(((System.Array)(pars[0])), ((object)(pars[1])), ((System.Collections.IComparer)(pars[2]))); - } - } - - private sealed class MTHD_2d9a7e89915e4e1cb1318d318e4b151f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2d9a7e89915e4e1cb1318d318e4b151f() - { - this.Initialize("BinarySearch", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.BinarySearch(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((object)(pars[3])), ((System.Collections.IComparer)(pars[4]))); - } - } - - private sealed class MTHD_d565650c9725488aa39f64c71132c537 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d565650c9725488aa39f64c71132c537() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_cee8a1b8a1094a5b8e7a9528759ccc72 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cee8a1b8a1094a5b8e7a9528759ccc72() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_7ef591795d894cf699b471597a70af17 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7ef591795d894cf699b471597a70af17() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_891bff63f6704a70821d90f33f1bffd5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_891bff63f6704a70821d90f33f1bffd5() - { - this.Initialize("IndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.IndexOf(((System.Array)(pars[0])), ((object)(pars[1]))); - } - } - - private sealed class MTHD_879097071d2f4da4abc846e12970fa88 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_879097071d2f4da4abc846e12970fa88() - { - this.Initialize("IndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.IndexOf(((System.Array)(pars[0])), ((object)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_a74d3ef144c147baaf102a67f2f8bac3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a74d3ef144c147baaf102a67f2f8bac3() - { - this.Initialize("IndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.IndexOf(((System.Array)(pars[0])), ((object)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - } - } - - private sealed class MTHD_4e5b3cf3725a4483a2b9bbfe96d51fe1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4e5b3cf3725a4483a2b9bbfe96d51fe1() - { - this.Initialize("LastIndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.LastIndexOf(((System.Array)(pars[0])), ((object)(pars[1]))); - } - } - - private sealed class MTHD_97cda901bee94a04ba713cfcd87f494a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_97cda901bee94a04ba713cfcd87f494a() - { - this.Initialize("LastIndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.LastIndexOf(((System.Array)(pars[0])), ((object)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_56e0b7d4b3b143078357223948fdc238 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_56e0b7d4b3b143078357223948fdc238() - { - this.Initialize("LastIndexOf", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return System.Array.LastIndexOf(((System.Array)(pars[0])), ((object)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - } - } - - private sealed class MTHD_151b9a85d12741e6be72f72679157036 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_151b9a85d12741e6be72f72679157036() - { - this.Initialize("Reverse", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Reverse(((System.Array)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_25076e37ecb64d0782f9c9eb07ec31e6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_25076e37ecb64d0782f9c9eb07ec31e6() - { - this.Initialize("Reverse", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Reverse(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_7cb044102e4442afbc6f38d5f9bd5f80 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7cb044102e4442afbc6f38d5f9bd5f80() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_9d59bc933d174901aae46c93d0b7a8ea : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9d59bc933d174901aae46c93d0b7a8ea() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("keys", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("items", typeof(System.Array), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((System.Array)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_eceedc0a28744d16a6e7835d2c5b0983 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eceedc0a28744d16a6e7835d2c5b0983() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ffd5bddc37bb4f67aa21a4b12f339178 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ffd5bddc37bb4f67aa21a4b12f339178() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("keys", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("items", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((System.Array)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_81d827a4e65f42ba9371826161e0636d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_81d827a4e65f42ba9371826161e0636d() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((System.Collections.IComparer)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_93e11f8a0c3e4662a854941942eebbc8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_93e11f8a0c3e4662a854941942eebbc8() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("keys", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("items", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((System.Array)(pars[1])), ((System.Collections.IComparer)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_fe509d8161034d4d95268548fb47c2ff : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fe509d8161034d4d95268548fb47c2ff() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((System.Collections.IComparer)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_547c15e52fd34ffe9bbfe7c008a57891 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_547c15e52fd34ffe9bbfe7c008a57891() - { - this.Initialize("Sort", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("keys", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("items", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("length", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Array.Sort(((System.Array)(pars[0])), ((System.Array)(pars[1])), ((int)(pars[2])), ((int)(pars[3])), ((System.Collections.IComparer)(pars[4]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6a8e90770b1e4dc5aee0d29aa1f1939a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6a8e90770b1e4dc5aee0d29aa1f1939a() - { - this.Initialize("Initialize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).Initialize(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_0fe0ba30a7f948a5a3075943f11e0ca7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0fe0ba30a7f948a5a3075943f11e0ca7() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_1d9da14232f949989a1b4f1cceeb3224 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1d9da14232f949989a1b4f1cceeb3224() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_6c10fe8df9b34db3baa37febd2addeca : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6c10fe8df9b34db3baa37febd2addeca() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_b489db7e554f4ae9864d259c149cbbd4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b489db7e554f4ae9864d259c149cbbd4() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_1952e84d9d9345e4b2ac0dbb759af7fd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_1952e84d9d9345e4b2ac0dbb759af7fd() : - base(typeof(int), "Length", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class PROP_54301e7e389043b5b1d4c83aecd60a5c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_54301e7e389043b5b1d4c83aecd60a5c() : - base(typeof(long), "LongLength", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class PROP_8dad3c2a4e914862a29b8bdc6faa16e7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_8dad3c2a4e914862a29b8bdc6faa16e7() : - base(typeof(int), "Rank", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class PROP_ad18274e4b564afebec7e40130972f56 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_ad18274e4b564afebec7e40130972f56() : - base(typeof(object), "SyncRoot", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class PROP_6a8c9594559a43649f5fa03c937e642a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_6a8c9594559a43649f5fa03c937e642a() : - base(typeof(bool), "IsReadOnly", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class PROP_d21592e7deb5474db98699a252d90a97 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_d21592e7deb5474db98699a252d90a97() : - base(typeof(bool), "IsFixedSize", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class PROP_e493445d44f14b5badbc3a97fac693e3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_e493445d44f14b5badbc3a97fac693e3() : - base(typeof(bool), "IsSynchronized", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class AIDX_1721802415b841b081c86d0bf8001cb4 : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_1721802415b841b081c86d0bf8001cb4() : - base("set_Item", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0]) - { - } - } - - private sealed class AIDX_f999fe33f5af45da885be5c9454bf9a9 : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_f999fe33f5af45da885be5c9454bf9a9() : - base("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0]) - { - } - } - } - #endregion - - #region Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - // Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests+RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - private sealed class TYPE_728312c1affe4e99a286edc5d9020c48 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_728312c1affe4e99a286edc5d9020c48() : - base(typeof(System.Collections.Generic.List)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e380ae3cc72844b3bb87e11357a22c6e(), - new MTHD_333987f8eb8b48769894a8db932b7d04(), - new MTHD_935df225dab444e5846270e6aac17312()})); - this.AddMember("get_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9254b8ca4e8b4fb78e44f085944c3ba5()})); - this.AddMember("set_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5f90bf1d59f9457599a0e5383fb828c0()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b53ad7b0b2594d81a3844df05c2c1150()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_245e0525178d4d94b5beeb6384703bd0()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d14715af78474462842d8e8b33daedab()})); - this.AddMember("Add", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Add", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2335f6d38a7a487bbb49dbdf51cb5ac7()})); - this.AddMember("AddRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AddRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2ba9bf6ef7a54678b3eb522b9dc9294f()})); - this.AddMember("AsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AsReadOnly", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_78f045c48624431b856749fe78f04b57()})); - this.AddMember("BinarySearch", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("BinarySearch", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eadaae88076045cba5b7215c683f2e57(), - new MTHD_01f778f6c8b64be0aef1300629eb7f49(), - new MTHD_fabc659403894e448658e0670d0aa3ee()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_46b8b111563c46fabc65be099355bb85()})); - this.AddMember("Contains", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Contains", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a9061c40809149b58707260976fecf08()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d07c4962b72e43dbb3300de11bf7f063(), - new MTHD_3cdaedf32e1a4970937bf5294a0ddf09(), - new MTHD_75add284290346cfb2ad3dd6a1add0f2()})); - this.AddMember("Exists", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Exists", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d91ea2ec808f4f7896baadbc91cd80a1()})); - this.AddMember("Find", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Find", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_15479705fb924865904522a8fd40297c()})); - this.AddMember("FindAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2efdc1c2e4444ad889e593ce4c375a49()})); - this.AddMember("FindIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b62a3652a74148a4b73df3359732a996(), - new MTHD_7659ff42100a457ba67d5991d874957e(), - new MTHD_6a69f98e8e974a0798aeb230ba59fdfa()})); - this.AddMember("FindLast", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLast", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b9c0fca9c72a4da4bea3305ab8c3f26c()})); - this.AddMember("FindLastIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLastIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_965d6a6995834ea1a66810858041d71c(), - new MTHD_15b2b9bc4c2a47c29926fff119d0532d(), - new MTHD_51d59832ec7b4ae9958f072d04099917()})); - this.AddMember("ForEach", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ForEach", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_13f9562c04f04feeac9f5086a51c5593()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_89e03701c3114b8380350a1eb640dff0()})); - this.AddMember("GetRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4dcf3380e1c94df69e00c2a1f7e6a838()})); - this.AddMember("IndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("IndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_684ec4238882427da6201bfb80395b90(), - new MTHD_4aef772f4b4e40c69da7100b7a2c9f55(), - new MTHD_fc63928b64fc47c4ba7e3e8c465fbab3()})); - this.AddMember("Insert", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Insert", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_21d143275851402fa56939573d3694c8()})); - this.AddMember("InsertRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("InsertRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fde1a0ac32754f6a968b0e01e43a23d1()})); - this.AddMember("LastIndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("LastIndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_732ef32193c745949d8f53cf1d36331e(), - new MTHD_381a5ab3ea0044fb8a10096d1f2933ad(), - new MTHD_c947ea334dc84bf3a5b546e20ef78043()})); - this.AddMember("Remove", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Remove", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a49a884be10446d7a3ff047256a7a480()})); - this.AddMember("RemoveAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f558713e8f354bdb8dddee6d2cfae89d()})); - this.AddMember("RemoveAt", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAt", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_98c4f19cb8b443239cc713a60e2d7018()})); - this.AddMember("RemoveRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_29fb8d24b97340dc8ce4f490c55e65be()})); - this.AddMember("Reverse", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Reverse", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d42de93e856f466582ddab296b430d4f(), - new MTHD_c880f97bef1e44ec8d17caa2efa3d1a2()})); - this.AddMember("Sort", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Sort", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6b749748b6f24d1390f86f8aa1ed0e02(), - new MTHD_5bf4f68101d4441e8cc59b3ae00bde3e(), - new MTHD_dd470e961d584df3af67475a686e09a8(), - new MTHD_ef18d4812e27487ab1441a1fa0c903a9()})); - this.AddMember("ToArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToArray", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f5080b0f006e4ffb83e1b24cab777884()})); - this.AddMember("TrimExcess", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrimExcess", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_655725ec2fa94342a5e3f26c7d4a6504()})); - this.AddMember("TrueForAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrueForAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0fc380377f234a66a8e88de289f91d01()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_270a2810eac54375ba3a87568d681d23()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7c4370484af344a5b78d20331e97a785()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d36728e2e2354a7e817ea957e4675c05()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_588ac57139604b12bbfab83537c0b635()})); - this.AddMember("Capacity", new PROP_3cf5c4c6bd1b48919becc55158357461()); - this.AddMember("Count", new PROP_a8ac1f6676964f2a958aa27818a8431f()); - } - - private sealed class MTHD_e380ae3cc72844b3bb87e11357a22c6e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e380ae3cc72844b3bb87e11357a22c6e() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(); - } - } - - private sealed class MTHD_333987f8eb8b48769894a8db932b7d04 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_333987f8eb8b48769894a8db932b7d04() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((int)(pars[0]))); - } - } - - private sealed class MTHD_935df225dab444e5846270e6aac17312 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_935df225dab444e5846270e6aac17312() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((System.Collections.Generic.IEnumerable)(pars[0]))); - } - } - - private sealed class MTHD_9254b8ca4e8b4fb78e44f085944c3ba5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9254b8ca4e8b4fb78e44f085944c3ba5() - { - this.Initialize("get_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - } - - private sealed class MTHD_5f90bf1d59f9457599a0e5383fb828c0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5f90bf1d59f9457599a0e5383fb828c0() - { - this.Initialize("set_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_b53ad7b0b2594d81a3844df05c2c1150 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b53ad7b0b2594d81a3844df05c2c1150() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - - private sealed class MTHD_245e0525178d4d94b5beeb6384703bd0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_245e0525178d4d94b5beeb6384703bd0() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_d14715af78474462842d8e8b33daedab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d14715af78474462842d8e8b33daedab() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp[((int)(pars[0]))] = ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[1])); - return null; - } - } - - private sealed class MTHD_2335f6d38a7a487bbb49dbdf51cb5ac7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2335f6d38a7a487bbb49dbdf51cb5ac7() - { - this.Initialize("Add", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Add(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_2ba9bf6ef7a54678b3eb522b9dc9294f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2ba9bf6ef7a54678b3eb522b9dc9294f() - { - this.Initialize("AddRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).AddRange(((System.Collections.Generic.IEnumerable)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_78f045c48624431b856749fe78f04b57 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_78f045c48624431b856749fe78f04b57() - { - this.Initialize("AsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).AsReadOnly(); - } - } - - private sealed class MTHD_eadaae88076045cba5b7215c683f2e57 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eadaae88076045cba5b7215c683f2e57() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0])), ((int)(pars[1])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[2])), ((System.Collections.Generic.IComparer)(pars[3]))); - } - } - - private sealed class MTHD_01f778f6c8b64be0aef1300629eb7f49 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_01f778f6c8b64be0aef1300629eb7f49() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_fabc659403894e448658e0670d0aa3ee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fabc659403894e448658e0670d0aa3ee() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0])), ((System.Collections.Generic.IComparer)(pars[1]))); - } - } - - private sealed class MTHD_46b8b111563c46fabc65be099355bb85 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_46b8b111563c46fabc65be099355bb85() - { - this.Initialize("Clear", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Clear(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a9061c40809149b58707260976fecf08 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a9061c40809149b58707260976fecf08() - { - this.Initialize("Contains", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Contains(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_d07c4962b72e43dbb3300de11bf7f063 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d07c4962b72e43dbb3300de11bf7f063() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[])(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3cdaedf32e1a4970937bf5294a0ddf09 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3cdaedf32e1a4970937bf5294a0ddf09() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[])(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_75add284290346cfb2ad3dd6a1add0f2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_75add284290346cfb2ad3dd6a1add0f2() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem[])(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_d91ea2ec808f4f7896baadbc91cd80a1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d91ea2ec808f4f7896baadbc91cd80a1() - { - this.Initialize("Exists", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Exists(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_15479705fb924865904522a8fd40297c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_15479705fb924865904522a8fd40297c() - { - this.Initialize("Find", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Find(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_2efdc1c2e4444ad889e593ce4c375a49 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2efdc1c2e4444ad889e593ce4c375a49() - { - this.Initialize("FindAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_b62a3652a74148a4b73df3359732a996 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b62a3652a74148a4b73df3359732a996() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_7659ff42100a457ba67d5991d874957e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7659ff42100a457ba67d5991d874957e() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_6a69f98e8e974a0798aeb230ba59fdfa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6a69f98e8e974a0798aeb230ba59fdfa() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_b9c0fca9c72a4da4bea3305ab8c3f26c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b9c0fca9c72a4da4bea3305ab8c3f26c() - { - this.Initialize("FindLast", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLast(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_965d6a6995834ea1a66810858041d71c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_965d6a6995834ea1a66810858041d71c() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_15b2b9bc4c2a47c29926fff119d0532d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_15b2b9bc4c2a47c29926fff119d0532d() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_51d59832ec7b4ae9958f072d04099917 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_51d59832ec7b4ae9958f072d04099917() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_13f9562c04f04feeac9f5086a51c5593 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_13f9562c04f04feeac9f5086a51c5593() - { - this.Initialize("ForEach", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("action", typeof(System.Action), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).ForEach(((System.Action)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_89e03701c3114b8380350a1eb640dff0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_89e03701c3114b8380350a1eb640dff0() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_4dcf3380e1c94df69e00c2a1f7e6a838 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4dcf3380e1c94df69e00c2a1f7e6a838() - { - this.Initialize("GetRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetRange(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_684ec4238882427da6201bfb80395b90 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_684ec4238882427da6201bfb80395b90() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_4aef772f4b4e40c69da7100b7a2c9f55 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4aef772f4b4e40c69da7100b7a2c9f55() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_fc63928b64fc47c4ba7e3e8c465fbab3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fc63928b64fc47c4ba7e3e8c465fbab3() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_21d143275851402fa56939573d3694c8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_21d143275851402fa56939573d3694c8() - { - this.Initialize("Insert", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Insert(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_fde1a0ac32754f6a968b0e01e43a23d1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fde1a0ac32754f6a968b0e01e43a23d1() - { - this.Initialize("InsertRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).InsertRange(((int)(pars[0])), ((System.Collections.Generic.IEnumerable)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_732ef32193c745949d8f53cf1d36331e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_732ef32193c745949d8f53cf1d36331e() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_381a5ab3ea0044fb8a10096d1f2933ad : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_381a5ab3ea0044fb8a10096d1f2933ad() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_c947ea334dc84bf3a5b546e20ef78043 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c947ea334dc84bf3a5b546e20ef78043() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_a49a884be10446d7a3ff047256a7a480 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a49a884be10446d7a3ff047256a7a480() - { - this.Initialize("Remove", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Remove(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsBaseGenRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_f558713e8f354bdb8dddee6d2cfae89d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f558713e8f354bdb8dddee6d2cfae89d() - { - this.Initialize("RemoveAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).RemoveAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_98c4f19cb8b443239cc713a60e2d7018 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_98c4f19cb8b443239cc713a60e2d7018() - { - this.Initialize("RemoveAt", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveAt(((int)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_29fb8d24b97340dc8ce4f490c55e65be : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_29fb8d24b97340dc8ce4f490c55e65be() - { - this.Initialize("RemoveRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveRange(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_d42de93e856f466582ddab296b430d4f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d42de93e856f466582ddab296b430d4f() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c880f97bef1e44ec8d17caa2efa3d1a2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c880f97bef1e44ec8d17caa2efa3d1a2() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6b749748b6f24d1390f86f8aa1ed0e02 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6b749748b6f24d1390f86f8aa1ed0e02() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_5bf4f68101d4441e8cc59b3ae00bde3e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5bf4f68101d4441e8cc59b3ae00bde3e() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Collections.Generic.IComparer)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_dd470e961d584df3af67475a686e09a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dd470e961d584df3af67475a686e09a8() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((int)(pars[0])), ((int)(pars[1])), ((System.Collections.Generic.IComparer)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ef18d4812e27487ab1441a1fa0c903a9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ef18d4812e27487ab1441a1fa0c903a9() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparison", typeof(System.Comparison), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Comparison)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f5080b0f006e4ffb83e1b24cab777884 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f5080b0f006e4ffb83e1b24cab777884() - { - this.Initialize("ToArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).ToArray(); - } - } - - private sealed class MTHD_655725ec2fa94342a5e3f26c7d4a6504 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_655725ec2fa94342a5e3f26c7d4a6504() - { - this.Initialize("TrimExcess", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).TrimExcess(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_0fc380377f234a66a8e88de289f91d01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0fc380377f234a66a8e88de289f91d01() - { - this.Initialize("TrueForAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).TrueForAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_270a2810eac54375ba3a87568d681d23 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_270a2810eac54375ba3a87568d681d23() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_7c4370484af344a5b78d20331e97a785 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7c4370484af344a5b78d20331e97a785() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_d36728e2e2354a7e817ea957e4675c05 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d36728e2e2354a7e817ea957e4675c05() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_588ac57139604b12bbfab83537c0b635 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_588ac57139604b12bbfab83537c0b635() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_3cf5c4c6bd1b48919becc55158357461 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_3cf5c4c6bd1b48919becc55158357461() : - base(typeof(int), "Capacity", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(value)); - } - } - - private sealed class PROP_a8ac1f6676964f2a958aa27818a8431f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_a8ac1f6676964f2a958aa27818a8431f() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollMethods - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollMethods - private sealed class TYPE_50fe3e19ee7b4d34b2d94c2ec09ad8d4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_50fe3e19ee7b4d34b2d94c2ec09ad8d4() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_053fdcc783524836a61adf31293c4270()})); - this.AddMember("GetMultiArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetMultiArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b71bfd6c2e844445873ce7b2de5e84c5()})); - this.AddMember("GetArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetArray", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d5da53f6a0524130955e0dbffb7ab251()})); - this.AddMember("GetItems", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetItems", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f43451e72c5b4f6eb2c87eeda5ba3080()})); - this.AddMember("GetList", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetList", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7ba46dd295884e058929e81c955313af()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5e20befa46c84253942ee6dddb6e1ed1()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4bae47c80da44e0ca28ad57a4a0ab967()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c28a4f0dc086497d8e36a2bb23ca2913()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_aae9e72563f94d259aca030798a5e41b()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e0b1e315e12c464b942d6c21ddce7b66()})); - } - - private sealed class MTHD_053fdcc783524836a61adf31293c4270 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_053fdcc783524836a61adf31293c4270() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods(); - } - } - - private sealed class MTHD_b71bfd6c2e844445873ce7b2de5e84c5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b71bfd6c2e844445873ce7b2de5e84c5() - { - this.Initialize("GetMultiArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)(obj)).GetMultiArray(); - } - } - - private sealed class MTHD_d5da53f6a0524130955e0dbffb7ab251 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d5da53f6a0524130955e0dbffb7ab251() - { - this.Initialize("GetArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)(obj)).GetArray(); - } - } - - private sealed class MTHD_f43451e72c5b4f6eb2c87eeda5ba3080 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f43451e72c5b4f6eb2c87eeda5ba3080() - { - this.Initialize("GetItems", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)(obj)).GetItems(); - } - } - - private sealed class MTHD_7ba46dd295884e058929e81c955313af : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7ba46dd295884e058929e81c955313af() - { - this.Initialize("GetList", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)(obj)).GetList(); - } - } - - private sealed class MTHD_5e20befa46c84253942ee6dddb6e1ed1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5e20befa46c84253942ee6dddb6e1ed1() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollMethods)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_4bae47c80da44e0ca28ad57a4a0ab967 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4bae47c80da44e0ca28ad57a4a0ab967() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_c28a4f0dc086497d8e36a2bb23ca2913 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c28a4f0dc086497d8e36a2bb23ca2913() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_aae9e72563f94d259aca030798a5e41b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_aae9e72563f94d259aca030798a5e41b() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_e0b1e315e12c464b942d6c21ddce7b66 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e0b1e315e12c464b942d6c21ddce7b66() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollItem - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollItem - private sealed class TYPE_da3e72ee164847a58fb8b3fa12421a15 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_da3e72ee164847a58fb8b3fa12421a15() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4c340fda1306427bb801c523bfd57488()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cd2295bdfbcc4191ab4fddd07adddcba()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8d9399f5faa24568890b0ccd0a57254b()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_64337cd3573b432e8c08d1a7efec7f15()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d0ce3a4334354e899823e8ad6f4ea322()})); - this.AddMember("Value", new FLDV_3fb1309463c84784bdea64cfd21e181c()); - } - - private sealed class MTHD_4c340fda1306427bb801c523bfd57488 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4c340fda1306427bb801c523bfd57488() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem(((int)(pars[0]))); - } - } - - private sealed class MTHD_cd2295bdfbcc4191ab4fddd07adddcba : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cd2295bdfbcc4191ab4fddd07adddcba() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_8d9399f5faa24568890b0ccd0a57254b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8d9399f5faa24568890b0ccd0a57254b() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_64337cd3573b432e8c08d1a7efec7f15 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_64337cd3573b432e8c08d1a7efec7f15() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_d0ce3a4334354e899823e8ad6f4ea322 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d0ce3a4334354e899823e8ad6f4ea322() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_3fb1309463c84784bdea64cfd21e181c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_3fb1309463c84784bdea64cfd21e181c() : - base(typeof(int), "Value", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(obj)).Value; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(obj)); - tmp.Value = ((int)(value)); - } - } - } - #endregion - - #region Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - // Descriptor of System.Collections.Generic.List`1[[MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests+RegCollItem, MoonSharp.Interpreter.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] - private sealed class TYPE_22f0c3c36b3147bfb30a605ca30fde1c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_22f0c3c36b3147bfb30a605ca30fde1c() : - base(typeof(System.Collections.Generic.List)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_50352431f3e949e183bf08b0eb352d97(), - new MTHD_13f142a071ba4263b9fe2cf506173954(), - new MTHD_8f8f045eb8bd4b81bf53a3abb6d25ebb()})); - this.AddMember("get_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_406d209ec791486aaf8bc2a29e8c953d()})); - this.AddMember("set_Capacity", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Capacity", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e9fc4a2f03574254b56554202b97de48()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_767b745d7b494d1caeca033c54cdfb42()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_96436222234a4bb1870eafcadab87c20()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_525aa951297c4cca811377bc4cb027fc()})); - this.AddMember("Add", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Add", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_226bd0a185d041109dd1f43899b8ddb5()})); - this.AddMember("AddRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AddRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_308bfd8beadf415aaecc53f7ecccaa04()})); - this.AddMember("AsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("AsReadOnly", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_931f55bbf414471db52ab109689a272d()})); - this.AddMember("BinarySearch", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("BinarySearch", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_14c5eb69ee0e48f1bea994c8bece81dc(), - new MTHD_3635c329685445719dd0fdf75b91b137(), - new MTHD_14647c8d3b7849e685a329b9688db501()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2cf5cc60895348649ed446327ade3673()})); - this.AddMember("Contains", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Contains", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eedf4b57f2d34cf9a2206dcaf26f8405()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0aaac2c2d88d4ad0a1ce1fb49cabacdd(), - new MTHD_4c5093fabdf748a580a50586f13a7835(), - new MTHD_f23b080561ce4d68ab6c17d818e52771()})); - this.AddMember("Exists", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Exists", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3905abca98c746c0944470523f96ec39()})); - this.AddMember("Find", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Find", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0a6cd94bd05c4ca6a7ee093c77de4a65()})); - this.AddMember("FindAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bd4df1c1b4ce4005bcdc56f740eeddcc()})); - this.AddMember("FindIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_564bbc8ac93142f3910f5151649a5d4b(), - new MTHD_768b320ac1e5482ea20be002d6bde139(), - new MTHD_c3a5e18664fb492594e029012b24146f()})); - this.AddMember("FindLast", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLast", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_03fe293a611f48a99ba8ed3b0ff99654()})); - this.AddMember("FindLastIndex", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("FindLastIndex", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c0977d52f4b941119935994b6e5d3d8e(), - new MTHD_1f1bc19ccf094edc82200ebcb316c825(), - new MTHD_357f9a8551974efc8c87f76b0f5985ff()})); - this.AddMember("ForEach", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ForEach", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_92b5590f227e41b3b93e9917a26c7377()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_59eb73a863be44e0a1a01a03eb3278f7()})); - this.AddMember("GetRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_784801d8e9fe466cbf15ca533c0ee5d8()})); - this.AddMember("IndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("IndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d30cfa7076ce43bc8fbd035badc46c3a(), - new MTHD_ecd5c9d0c8db44c38882bb098639cf25(), - new MTHD_1fedcc10e4b948ee84cc68278d7a6323()})); - this.AddMember("Insert", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Insert", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_69f1c9a353d943668dca55b4070b1513()})); - this.AddMember("InsertRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("InsertRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c4be381b78614d4e81df6850df65120a()})); - this.AddMember("LastIndexOf", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("LastIndexOf", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1c4559ed70f94a1182e1c4f531fbfd84(), - new MTHD_ee2aa33de4d049c7a13abca231a5d639(), - new MTHD_60ac3c619455459d966024b1f92a4885()})); - this.AddMember("Remove", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Remove", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8ff98058d1c44248bf66267d5e574ebd()})); - this.AddMember("RemoveAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1c5ac4133c484aac9709d715d0a0dad4()})); - this.AddMember("RemoveAt", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveAt", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eed28c1e662a4d7db490240eb4b8f777()})); - this.AddMember("RemoveRange", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("RemoveRange", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a00d44a7fe6643c0b64f5fb2b1292ed0()})); - this.AddMember("Reverse", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Reverse", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ed34c2888d094b06901c9b1deaf38a1d(), - new MTHD_3e3becbf01834085a4e0922754bf7972()})); - this.AddMember("Sort", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Sort", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c6415ae48ce748a497c0c77034f6d839(), - new MTHD_297cb111fdb64deab63889b54fa6bdf4(), - new MTHD_2d5291c991144c079f022ab515c71744(), - new MTHD_bd7d3ad3179045569c8426ba97545fd1()})); - this.AddMember("ToArray", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToArray", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eea10c6b8e7a425999972580c6b978b3()})); - this.AddMember("TrimExcess", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrimExcess", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fdb7c975af1d4e3aba6f7277f29ddc6f()})); - this.AddMember("TrueForAll", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TrueForAll", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d54f1d7e68694196940857f0567aa3a9()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f39a020b3cb74145be5fe29506898bc0()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a64a4f62fa054a4681d49fbf3fedc202()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_00e1a6bbe08747a5ab62a4cba4cdb313()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Collections.Generic.List), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_75fa93fe60134d7db355931742732d2e()})); - this.AddMember("Capacity", new PROP_de472cfe637b46dfb5d30ef3af1c71ac()); - this.AddMember("Count", new PROP_5fa69c7110f24aaca2f5ac39fe3719f5()); - } - - private sealed class MTHD_50352431f3e949e183bf08b0eb352d97 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_50352431f3e949e183bf08b0eb352d97() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(); - } - } - - private sealed class MTHD_13f142a071ba4263b9fe2cf506173954 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_13f142a071ba4263b9fe2cf506173954() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((int)(pars[0]))); - } - } - - private sealed class MTHD_8f8f045eb8bd4b81bf53a3abb6d25ebb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8f8f045eb8bd4b81bf53a3abb6d25ebb() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.List(((System.Collections.Generic.IEnumerable)(pars[0]))); - } - } - - private sealed class MTHD_406d209ec791486aaf8bc2a29e8c953d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_406d209ec791486aaf8bc2a29e8c953d() - { - this.Initialize("get_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - } - - private sealed class MTHD_e9fc4a2f03574254b56554202b97de48 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e9fc4a2f03574254b56554202b97de48() - { - this.Initialize("set_Capacity", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_767b745d7b494d1caeca033c54cdfb42 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_767b745d7b494d1caeca033c54cdfb42() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - - private sealed class MTHD_96436222234a4bb1870eafcadab87c20 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_96436222234a4bb1870eafcadab87c20() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_525aa951297c4cca811377bc4cb027fc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_525aa951297c4cca811377bc4cb027fc() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp[((int)(pars[0]))] = ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[1])); - return null; - } - } - - private sealed class MTHD_226bd0a185d041109dd1f43899b8ddb5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_226bd0a185d041109dd1f43899b8ddb5() - { - this.Initialize("Add", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Add(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_308bfd8beadf415aaecc53f7ecccaa04 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_308bfd8beadf415aaecc53f7ecccaa04() - { - this.Initialize("AddRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).AddRange(((System.Collections.Generic.IEnumerable)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_931f55bbf414471db52ab109689a272d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_931f55bbf414471db52ab109689a272d() - { - this.Initialize("AsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).AsReadOnly(); - } - } - - private sealed class MTHD_14c5eb69ee0e48f1bea994c8bece81dc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_14c5eb69ee0e48f1bea994c8bece81dc() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((int)(pars[0])), ((int)(pars[1])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[2])), ((System.Collections.Generic.IComparer)(pars[3]))); - } - } - - private sealed class MTHD_3635c329685445719dd0fdf75b91b137 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3635c329685445719dd0fdf75b91b137() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_14647c8d3b7849e685a329b9688db501 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_14647c8d3b7849e685a329b9688db501() - { - this.Initialize("BinarySearch", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).BinarySearch(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0])), ((System.Collections.Generic.IComparer)(pars[1]))); - } - } - - private sealed class MTHD_2cf5cc60895348649ed446327ade3673 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2cf5cc60895348649ed446327ade3673() - { - this.Initialize("Clear", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Clear(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_eedf4b57f2d34cf9a2206dcaf26f8405 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eedf4b57f2d34cf9a2206dcaf26f8405() - { - this.Initialize("Contains", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Contains(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_0aaac2c2d88d4ad0a1ce1fb49cabacdd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0aaac2c2d88d4ad0a1ce1fb49cabacdd() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[])(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_4c5093fabdf748a580a50586f13a7835 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4c5093fabdf748a580a50586f13a7835() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[])(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_f23b080561ce4d68ab6c17d818e52771 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f23b080561ce4d68ab6c17d818e52771() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("arrayIndex", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).CopyTo(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem[])(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3905abca98c746c0944470523f96ec39 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3905abca98c746c0944470523f96ec39() - { - this.Initialize("Exists", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Exists(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_0a6cd94bd05c4ca6a7ee093c77de4a65 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0a6cd94bd05c4ca6a7ee093c77de4a65() - { - this.Initialize("Find", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Find(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_bd4df1c1b4ce4005bcdc56f740eeddcc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bd4df1c1b4ce4005bcdc56f740eeddcc() - { - this.Initialize("FindAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_564bbc8ac93142f3910f5151649a5d4b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_564bbc8ac93142f3910f5151649a5d4b() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_768b320ac1e5482ea20be002d6bde139 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_768b320ac1e5482ea20be002d6bde139() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_c3a5e18664fb492594e029012b24146f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c3a5e18664fb492594e029012b24146f() - { - this.Initialize("FindIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_03fe293a611f48a99ba8ed3b0ff99654 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_03fe293a611f48a99ba8ed3b0ff99654() - { - this.Initialize("FindLast", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLast(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_c0977d52f4b941119935994b6e5d3d8e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c0977d52f4b941119935994b6e5d3d8e() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_1f1bc19ccf094edc82200ebcb316c825 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1f1bc19ccf094edc82200ebcb316c825() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((System.Predicate)(pars[1]))); - } - } - - private sealed class MTHD_357f9a8551974efc8c87f76b0f5985ff : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_357f9a8551974efc8c87f76b0f5985ff() - { - this.Initialize("FindLastIndex", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("startIndex", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).FindLastIndex(((int)(pars[0])), ((int)(pars[1])), ((System.Predicate)(pars[2]))); - } - } - - private sealed class MTHD_92b5590f227e41b3b93e9917a26c7377 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_92b5590f227e41b3b93e9917a26c7377() - { - this.Initialize("ForEach", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("action", typeof(System.Action), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).ForEach(((System.Action)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_59eb73a863be44e0a1a01a03eb3278f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_59eb73a863be44e0a1a01a03eb3278f7() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_784801d8e9fe466cbf15ca533c0ee5d8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_784801d8e9fe466cbf15ca533c0ee5d8() - { - this.Initialize("GetRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).GetRange(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_d30cfa7076ce43bc8fbd035badc46c3a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d30cfa7076ce43bc8fbd035badc46c3a() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_ecd5c9d0c8db44c38882bb098639cf25 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ecd5c9d0c8db44c38882bb098639cf25() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_1fedcc10e4b948ee84cc68278d7a6323 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1fedcc10e4b948ee84cc68278d7a6323() - { - this.Initialize("IndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).IndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_69f1c9a353d943668dca55b4070b1513 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_69f1c9a353d943668dca55b4070b1513() - { - this.Initialize("Insert", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Insert(((int)(pars[0])), ((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c4be381b78614d4e81df6850df65120a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c4be381b78614d4e81df6850df65120a() - { - this.Initialize("InsertRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("collection", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).InsertRange(((int)(pars[0])), ((System.Collections.Generic.IEnumerable)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_1c4559ed70f94a1182e1c4f531fbfd84 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1c4559ed70f94a1182e1c4f531fbfd84() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_ee2aa33de4d049c7a13abca231a5d639 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ee2aa33de4d049c7a13abca231a5d639() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_60ac3c619455459d966024b1f92a4885 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_60ac3c619455459d966024b1f92a4885() - { - this.Initialize("LastIndexOf", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).LastIndexOf(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_8ff98058d1c44248bf66267d5e574ebd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ff98058d1c44248bf66267d5e574ebd() - { - this.Initialize("Remove", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).Remove(((MoonSharp.Interpreter.Tests.EndToEnd.CollectionsRegisteredTests.RegCollItem)(pars[0]))); - } - } - - private sealed class MTHD_1c5ac4133c484aac9709d715d0a0dad4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1c5ac4133c484aac9709d715d0a0dad4() - { - this.Initialize("RemoveAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).RemoveAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_eed28c1e662a4d7db490240eb4b8f777 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eed28c1e662a4d7db490240eb4b8f777() - { - this.Initialize("RemoveAt", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveAt(((int)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a00d44a7fe6643c0b64f5fb2b1292ed0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a00d44a7fe6643c0b64f5fb2b1292ed0() - { - this.Initialize("RemoveRange", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).RemoveRange(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_ed34c2888d094b06901c9b1deaf38a1d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ed34c2888d094b06901c9b1deaf38a1d() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3e3becbf01834085a4e0922754bf7972 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3e3becbf01834085a4e0922754bf7972() - { - this.Initialize("Reverse", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Reverse(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c6415ae48ce748a497c0c77034f6d839 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c6415ae48ce748a497c0c77034f6d839() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_297cb111fdb64deab63889b54fa6bdf4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_297cb111fdb64deab63889b54fa6bdf4() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Collections.Generic.IComparer)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_2d5291c991144c079f022ab515c71744 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2d5291c991144c079f022ab515c71744() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("count", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((int)(pars[0])), ((int)(pars[1])), ((System.Collections.Generic.IComparer)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_bd7d3ad3179045569c8426ba97545fd1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bd7d3ad3179045569c8426ba97545fd1() - { - this.Initialize("Sort", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparison", typeof(System.Comparison), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).Sort(((System.Comparison)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_eea10c6b8e7a425999972580c6b978b3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eea10c6b8e7a425999972580c6b978b3() - { - this.Initialize("ToArray", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).ToArray(); - } - } - - private sealed class MTHD_fdb7c975af1d4e3aba6f7277f29ddc6f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fdb7c975af1d4e3aba6f7277f29ddc6f() - { - this.Initialize("TrimExcess", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.List)(obj)).TrimExcess(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_d54f1d7e68694196940857f0567aa3a9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d54f1d7e68694196940857f0567aa3a9() - { - this.Initialize("TrueForAll", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("match", typeof(System.Predicate), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.List)(obj)).TrueForAll(((System.Predicate)(pars[0]))); - } - } - - private sealed class MTHD_f39a020b3cb74145be5fe29506898bc0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f39a020b3cb74145be5fe29506898bc0() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_a64a4f62fa054a4681d49fbf3fedc202 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a64a4f62fa054a4681d49fbf3fedc202() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_00e1a6bbe08747a5ab62a4cba4cdb313 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_00e1a6bbe08747a5ab62a4cba4cdb313() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_75fa93fe60134d7db355931742732d2e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_75fa93fe60134d7db355931742732d2e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_de472cfe637b46dfb5d30ef3af1c71ac : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_de472cfe637b46dfb5d30ef3af1c71ac() : - base(typeof(int), "Capacity", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Capacity; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - System.Collections.Generic.List tmp = ((System.Collections.Generic.List)(obj)); - tmp.Capacity = ((int)(value)); - } - } - - private sealed class PROP_5fa69c7110f24aaca2f5ac39fe3719f5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_5fa69c7110f24aaca2f5ac39fe3719f5() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.List)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of System.Int32[,] - // Descriptor of System.Int32[,] - private sealed class TYPE_1f6c21b9d2ba407f8815e4195628d3ab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_1f6c21b9d2ba407f8815e4195628d3ab() : - base(typeof(int[,])) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4f3f78a46aa44c63bf1c22d4bcfed8a6(), - new MTHD_2601357a9287426faa0584b0ce1a01e1()})); - this.AddMember("Set", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Set", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("Address", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Address", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("GetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetValue", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4988e9cdf0014c219826ecf0aa423996(), - new MTHD_894d6343cabc40e986d6d9bc95293e8f(), - new MTHD_c9eedcb610354ee8a2de5ee477add58f(), - new MTHD_8e5067a97ba24f7286eab15738ebfd4a(), - new MTHD_df93564652bb4449ada4f99ddf85ae30(), - new MTHD_d00feaf12b5d4dd1960ec7436f7c9911(), - new MTHD_d17de8b12abb4f4a9fa48171ecaa72a8(), - new MTHD_c1660a1439eb4cbf98f43bb5176038da()})); - this.AddMember("SetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetValue", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3e565a1fb5674eb5b7cd548235c36e02(), - new MTHD_9c1046a046014c839ae3272801a05422(), - new MTHD_844ce0bf29534aafb4459bcbe56b0663(), - new MTHD_9a74a4c0c7d24cb498444a073a788195(), - new MTHD_3ae108ca88094fc6a4aef3cce6262a78(), - new MTHD_2e66b111f42c4a09b0684003e073ff42(), - new MTHD_a4ca562fb6c14aa1aa19c70a463f4a51(), - new MTHD_e61c8d123e674f3ba3186c1fb36d0b13()})); - this.AddMember("get_Length", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Length", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_03b30e87a3f04b54b6fe2624ece861f7()})); - this.AddMember("get_LongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_LongLength", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f8966cf0c0064d09b617f0ea700cf15e()})); - this.AddMember("GetLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLength", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d3c76bb1dfc341f3b7c77d63e99ab8e1()})); - this.AddMember("GetLongLength", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLongLength", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8ddf37a62d964aca8fc9bb2f9b6f753f()})); - this.AddMember("get_Rank", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Rank", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_80b0f7e407be4b17a3801a9ced1c56c5()})); - this.AddMember("GetUpperBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetUpperBound", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7b149d7dba4c4539bc8ba8d7b9aedae0()})); - this.AddMember("GetLowerBound", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetLowerBound", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d0758f64f60048599c37c43717ccde26()})); - this.AddMember("get_SyncRoot", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_SyncRoot", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1d6440c5188b48fbba1739a41fb7115f()})); - this.AddMember("get_IsReadOnly", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsReadOnly", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e3ca86ac1ef84fd289a56feead4e7423()})); - this.AddMember("get_IsFixedSize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsFixedSize", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_abea266569034310b2257ba67fb40932()})); - this.AddMember("get_IsSynchronized", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IsSynchronized", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f74823c0957241108dd9b45dc642a199()})); - this.AddMember("Clone", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clone", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_caeab363d9974925987758df13059eb2()})); - this.AddMember("CopyTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CopyTo", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dd1815fe6f3442fea489441a0bad362a(), - new MTHD_357b12c54104439dadba4e95c3111bc7()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c6309d14162b4dfe9b6eac83f08d5041()})); - this.AddMember("Initialize", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Initialize", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_96d99f6a5d30472bbc4d917362e5064b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_81c605b90516419ba0aedc79ffd57520()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b4e5346e1ece494cbaffebc37c0dc977()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_feae8e70f61f49db9e722f44255636b9()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6cfbb2b55b4a408ba9e4f1df37510543()})); - this.AddMember("Length", new PROP_bc2e8711faf248cb8b101328dd073b66()); - this.AddMember("LongLength", new PROP_49724995d0fa4c1a866064c6b2537e65()); - this.AddMember("Rank", new PROP_fa56f94b12be46e68b697cfa4dc65eb0()); - this.AddMember("SyncRoot", new PROP_d42870a080684433b2831302a792340e()); - this.AddMember("IsReadOnly", new PROP_9f3539905a9c46cd8470844c4b38a87c()); - this.AddMember("IsFixedSize", new PROP_f127150df76f4f2bbe324d7b3276e2b5()); - this.AddMember("IsSynchronized", new PROP_60ad70a6520146199067fbd0b076dd32()); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_7e1b90537af04bc5907e37e75e123889()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(int[,]), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new AIDX_9c861e2509f9449294be6f2f08dd7221()})); - } - - private sealed class MTHD_4f3f78a46aa44c63bf1c22d4bcfed8a6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4f3f78a46aa44c63bf1c22d4bcfed8a6() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new int[] { - ((int)(pars[0])), - ((int)(pars[1]))}; - } - } - - private sealed class MTHD_2601357a9287426faa0584b0ce1a01e1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2601357a9287426faa0584b0ce1a01e1() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new int[] { - ((int)(pars[0])), - ((int)(pars[1]))}; - } - } - - private sealed class MTHD_4988e9cdf0014c219826ecf0aa423996 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4988e9cdf0014c219826ecf0aa423996() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int[])(pars[0]))); - } - } - - private sealed class MTHD_894d6343cabc40e986d6d9bc95293e8f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_894d6343cabc40e986d6d9bc95293e8f() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0]))); - } - } - - private sealed class MTHD_c9eedcb610354ee8a2de5ee477add58f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c9eedcb610354ee8a2de5ee477add58f() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_8e5067a97ba24f7286eab15738ebfd4a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8e5067a97ba24f7286eab15738ebfd4a() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_df93564652bb4449ada4f99ddf85ae30 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_df93564652bb4449ada4f99ddf85ae30() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0]))); - } - } - - private sealed class MTHD_d00feaf12b5d4dd1960ec7436f7c9911 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d00feaf12b5d4dd1960ec7436f7c9911() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1]))); - } - } - - private sealed class MTHD_d17de8b12abb4f4a9fa48171ecaa72a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d17de8b12abb4f4a9fa48171ecaa72a8() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - } - } - - private sealed class MTHD_c1660a1439eb4cbf98f43bb5176038da : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c1660a1439eb4cbf98f43bb5176038da() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetValue(((long[])(pars[0]))); - } - } - - private sealed class MTHD_3e565a1fb5674eb5b7cd548235c36e02 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3e565a1fb5674eb5b7cd548235c36e02() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_9c1046a046014c839ae3272801a05422 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9c1046a046014c839ae3272801a05422() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_844ce0bf29534aafb4459bcbe56b0663 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_844ce0bf29534aafb4459bcbe56b0663() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int)(pars[1])), ((int)(pars[2])), ((int)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_9a74a4c0c7d24cb498444a073a788195 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9a74a4c0c7d24cb498444a073a788195() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(int[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((int[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_3ae108ca88094fc6a4aef3cce6262a78 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3ae108ca88094fc6a4aef3cce6262a78() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_2e66b111f42c4a09b0684003e073ff42 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2e66b111f42c4a09b0684003e073ff42() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_a4ca562fb6c14aa1aa19c70a463f4a51 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a4ca562fb6c14aa1aa19c70a463f4a51() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index1", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index2", typeof(long), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index3", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long)(pars[1])), ((long)(pars[2])), ((long)(pars[3]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_e61c8d123e674f3ba3186c1fb36d0b13 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e61c8d123e674f3ba3186c1fb36d0b13() - { - this.Initialize("SetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("indices", typeof(long[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).SetValue(((object)(pars[0])), ((long[])(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_03b30e87a3f04b54b6fe2624ece861f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_03b30e87a3f04b54b6fe2624ece861f7() - { - this.Initialize("get_Length", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class MTHD_f8966cf0c0064d09b617f0ea700cf15e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f8966cf0c0064d09b617f0ea700cf15e() - { - this.Initialize("get_LongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class MTHD_d3c76bb1dfc341f3b7c77d63e99ab8e1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d3c76bb1dfc341f3b7c77d63e99ab8e1() - { - this.Initialize("GetLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_8ddf37a62d964aca8fc9bb2f9b6f753f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ddf37a62d964aca8fc9bb2f9b6f753f() - { - this.Initialize("GetLongLength", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLongLength(((int)(pars[0]))); - } - } - - private sealed class MTHD_80b0f7e407be4b17a3801a9ced1c56c5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_80b0f7e407be4b17a3801a9ced1c56c5() - { - this.Initialize("get_Rank", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class MTHD_7b149d7dba4c4539bc8ba8d7b9aedae0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7b149d7dba4c4539bc8ba8d7b9aedae0() - { - this.Initialize("GetUpperBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetUpperBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_d0758f64f60048599c37c43717ccde26 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d0758f64f60048599c37c43717ccde26() - { - this.Initialize("GetLowerBound", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dimension", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetLowerBound(((int)(pars[0]))); - } - } - - private sealed class MTHD_1d6440c5188b48fbba1739a41fb7115f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1d6440c5188b48fbba1739a41fb7115f() - { - this.Initialize("get_SyncRoot", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class MTHD_e3ca86ac1ef84fd289a56feead4e7423 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e3ca86ac1ef84fd289a56feead4e7423() - { - this.Initialize("get_IsReadOnly", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class MTHD_abea266569034310b2257ba67fb40932 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_abea266569034310b2257ba67fb40932() - { - this.Initialize("get_IsFixedSize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class MTHD_f74823c0957241108dd9b45dc642a199 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f74823c0957241108dd9b45dc642a199() - { - this.Initialize("get_IsSynchronized", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class MTHD_caeab363d9974925987758df13059eb2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_caeab363d9974925987758df13059eb2() - { - this.Initialize("Clone", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).Clone(); - } - } - - private sealed class MTHD_dd1815fe6f3442fea489441a0bad362a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dd1815fe6f3442fea489441a0bad362a() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_357b12c54104439dadba4e95c3111bc7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_357b12c54104439dadba4e95c3111bc7() - { - this.Initialize("CopyTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("array", typeof(System.Array), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("index", typeof(long), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).CopyTo(((System.Array)(pars[0])), ((long)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_c6309d14162b4dfe9b6eac83f08d5041 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c6309d14162b4dfe9b6eac83f08d5041() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Array)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_96d99f6a5d30472bbc4d917362e5064b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_96d99f6a5d30472bbc4d917362e5064b() - { - this.Initialize("Initialize", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Array)(obj)).Initialize(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_81c605b90516419ba0aedc79ffd57520 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_81c605b90516419ba0aedc79ffd57520() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_b4e5346e1ece494cbaffebc37c0dc977 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b4e5346e1ece494cbaffebc37c0dc977() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_feae8e70f61f49db9e722f44255636b9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_feae8e70f61f49db9e722f44255636b9() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_6cfbb2b55b4a408ba9e4f1df37510543 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6cfbb2b55b4a408ba9e4f1df37510543() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_bc2e8711faf248cb8b101328dd073b66 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_bc2e8711faf248cb8b101328dd073b66() : - base(typeof(int), "Length", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Length; - } - } - - private sealed class PROP_49724995d0fa4c1a866064c6b2537e65 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_49724995d0fa4c1a866064c6b2537e65() : - base(typeof(long), "LongLength", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).LongLength; - } - } - - private sealed class PROP_fa56f94b12be46e68b697cfa4dc65eb0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_fa56f94b12be46e68b697cfa4dc65eb0() : - base(typeof(int), "Rank", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).Rank; - } - } - - private sealed class PROP_d42870a080684433b2831302a792340e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_d42870a080684433b2831302a792340e() : - base(typeof(object), "SyncRoot", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).SyncRoot; - } - } - - private sealed class PROP_9f3539905a9c46cd8470844c4b38a87c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_9f3539905a9c46cd8470844c4b38a87c() : - base(typeof(bool), "IsReadOnly", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsReadOnly; - } - } - - private sealed class PROP_f127150df76f4f2bbe324d7b3276e2b5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_f127150df76f4f2bbe324d7b3276e2b5() : - base(typeof(bool), "IsFixedSize", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsFixedSize; - } - } - - private sealed class PROP_60ad70a6520146199067fbd0b076dd32 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_60ad70a6520146199067fbd0b076dd32() : - base(typeof(bool), "IsSynchronized", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Array)(obj)).IsSynchronized; - } - } - - private sealed class AIDX_7e1b90537af04bc5907e37e75e123889 : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_7e1b90537af04bc5907e37e75e123889() : - base("set_Item", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}) - { - } - } - - private sealed class AIDX_9c861e2509f9449294be6f2f08dd7221 : MoonSharp.Interpreter.Interop.ArrayMemberDescriptor - { - - internal AIDX_9c861e2509f9449294be6f2f08dd7221() : - base("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx0", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false)}) - { - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests+MyObject - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests+MyObject - private sealed class TYPE_201806dd10b345358abc1e2a7fea60d2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_201806dd10b345358abc1e2a7fea60d2() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d487b9145a4e4ddd8d0a037b9dd1709b()})); - this.AddMember("GetSomething", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetSomething", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b78cc6d8a5274ace81da20370f3c423b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_60c915e64297447ba531d0b82081142a()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ed1b711a146e4a0f9e9df7b5d24db453()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a5eb9beb78c741d8a573c3c0ae4ddc18()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b6a2843a167b42c7973a6ba9b81946f8()})); - } - - private sealed class MTHD_d487b9145a4e4ddd8d0a037b9dd1709b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d487b9145a4e4ddd8d0a037b9dd1709b() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject(); - } - } - - private sealed class MTHD_b78cc6d8a5274ace81da20370f3c423b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b78cc6d8a5274ace81da20370f3c423b() - { - this.Initialize("GetSomething", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.MetatableTests.MyObject)(obj)).GetSomething(); - } - } - - private sealed class MTHD_60c915e64297447ba531d0b82081142a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_60c915e64297447ba531d0b82081142a() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_ed1b711a146e4a0f9e9df7b5d24db453 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ed1b711a146e4a0f9e9df7b5d24db453() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_a5eb9beb78c741d8a573c3c0ae4ddc18 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a5eb9beb78c741d8a573c3c0ae4ddc18() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_b6a2843a167b42c7973a6ba9b81946f8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b6a2843a167b42c7973a6ba9b81946f8() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests+Proxy - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests+Proxy - private sealed class TYPE_96070a3ffc144574bd59a74250e84abd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_96070a3ffc144574bd59a74250e84abd() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy)) - { - this.AddMember("GetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetValue", typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3df2f909d0f14a778d48db5e56d93f75()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0fe8702c4c6c4ad8910143a0d730b341()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fd05d9bdb0ff46ccb7ff2d9db26aa320()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f65585b5301947d5ac613a5cc2f195bd()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_feb090f9220943f487f5c0cb247815a5()})); - } - - private sealed class MTHD_3df2f909d0f14a778d48db5e56d93f75 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3df2f909d0f14a778d48db5e56d93f75() - { - this.Initialize("GetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.ProxyObjectsTests.Proxy)(obj)).GetValue(); - } - } - - private sealed class MTHD_0fe8702c4c6c4ad8910143a0d730b341 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0fe8702c4c6c4ad8910143a0d730b341() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_fd05d9bdb0ff46ccb7ff2d9db26aa320 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fd05d9bdb0ff46ccb7ff2d9db26aa320() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_f65585b5301947d5ac613a5cc2f195bd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f65585b5301947d5ac613a5cc2f195bd() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_feb090f9220943f487f5c0cb247815a5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_feb090f9220943f487f5c0cb247815a5() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Transform - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Transform - private sealed class TYPE_71451dacd00543d1b4b5d91d5b9f4bc9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_71451dacd00543d1b4b5d91d5b9f4bc9() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dded09d9e9fd4a23be9d80c6e3315b0b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b05a5b4308aa44c69653a8c62e9a0eeb()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_299ae55e121a4c4e9a954b0608e32659()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_191baf95988543bb8c479c39a9ffaba9()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bdd255b1367f452494ed21a37662f07a()})); - this.AddMember("position", new FLDV_0ba6b9065f874a0dba9b77737af9d1a5()); - } - - private sealed class MTHD_dded09d9e9fd4a23be9d80c6e3315b0b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dded09d9e9fd4a23be9d80c6e3315b0b() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform(); - } - } - - private sealed class MTHD_b05a5b4308aa44c69653a8c62e9a0eeb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b05a5b4308aa44c69653a8c62e9a0eeb() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_299ae55e121a4c4e9a954b0608e32659 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_299ae55e121a4c4e9a954b0608e32659() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_191baf95988543bb8c479c39a9ffaba9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_191baf95988543bb8c479c39a9ffaba9() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_bdd255b1367f452494ed21a37662f07a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bdd255b1367f452494ed21a37662f07a() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_0ba6b9065f874a0dba9b77737af9d1a5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_0ba6b9065f874a0dba9b77737af9d1a5() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), "position", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform)(obj)).position; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Transform)(obj)); - tmp.position = ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(value)); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Vector3 - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique+Vector3 - private sealed class TYPE_1a704d11703e4b01bbe25a3a6e3d7437 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_1a704d11703e4b01bbe25a3a6e3d7437() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_187f2ff523634a108fe936c703645f2e()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f38146ee3f464f86b0d828d2b98a3f8b()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d828a7fa4f144bd7ab1cae5685ecb537()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8963c25951e24c3ca149d3e7e475cce1()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2cd3c00cf24f46b79b555097185be456()})); - this.AddMember("X", new FLDV_8c43fa4afc2e47ef91a5bd1818eb1fa6()); - this.AddMember("Y", new FLDV_492fe0f509c546b2a3cfd1b127cea40b()); - this.AddMember("Z", new FLDV_9d2dcf8f8ead495e8900a17a176c3c0b()); - } - - private sealed class VTDC_187f2ff523634a108fe936c703645f2e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_187f2ff523634a108fe936c703645f2e() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3(); - } - } - - private sealed class MTHD_f38146ee3f464f86b0d828d2b98a3f8b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f38146ee3f464f86b0d828d2b98a3f8b() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_d828a7fa4f144bd7ab1cae5685ecb537 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d828a7fa4f144bd7ab1cae5685ecb537() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_8963c25951e24c3ca149d3e7e475cce1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8963c25951e24c3ca149d3e7e475cce1() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_2cd3c00cf24f46b79b555097185be456 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2cd3c00cf24f46b79b555097185be456() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_8c43fa4afc2e47ef91a5bd1818eb1fa6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_8c43fa4afc2e47ef91a5bd1818eb1fa6() : - base(typeof(float), "X", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)).X; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3 tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)); - tmp.X = ((float)(value)); - } - } - - private sealed class FLDV_492fe0f509c546b2a3cfd1b127cea40b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_492fe0f509c546b2a3cfd1b127cea40b() : - base(typeof(float), "Y", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)).Y; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3 tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)); - tmp.Y = ((float)(value)); - } - } - - private sealed class FLDV_9d2dcf8f8ead495e8900a17a176c3c0b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_9d2dcf8f8ead495e8900a17a176c3c0b() : - base(typeof(float), "Z", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)).Z; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3 tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.StructAssignmentTechnique.Vector3)(obj)); - tmp.Z = ((float)(value)); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests+SomeClass - private sealed class TYPE_52f7e7443c124d23a81e55f9e22be191 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_52f7e7443c124d23a81e55f9e22be191() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c362811c0a4241d4a4a903b48c4c7391()})); - this.AddMember("add_MyEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("add_MyEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bb1eeb8c3d7a4feea32f91cb5f9caab5()})); - this.AddMember("remove_MyEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("remove_MyEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4bd4f4998e8b4c39bf4314164bb856f1()})); - this.AddMember("add_MySEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("add_MySEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e8564581746b4e98a73d3067effc13bc()})); - this.AddMember("remove_MySEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("remove_MySEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d4af209cc89b489cba2f6236c3a870c7()})); - this.AddMember("Trigger_MyEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Trigger_MyEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b8601870224449a2b3f19b33abd72102()})); - this.AddMember("Trigger_MySEvent", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Trigger_MySEvent", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_19881438dfc94d978b534f5f97bd3ba2()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7388b1061aff46b7975a0210d977d779()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e6e782c089d5441aaf0f7f239522b6b3()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bdaac254875d47e1afa86cf26d7a1f81()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_59cce498d000415bac84cc162f1d7b3c()})); - } - - private sealed class MTHD_c362811c0a4241d4a4a903b48c4c7391 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c362811c0a4241d4a4a903b48c4c7391() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass(); - } - } - - private sealed class MTHD_bb1eeb8c3d7a4feea32f91cb5f9caab5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bb1eeb8c3d7a4feea32f91cb5f9caab5() - { - this.Initialize("add_MyEvent", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.EventHandler), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - throw new System.InvalidOperationException("Access to event special methods is not supported by hardwired decriptors."); - } - } - - private sealed class MTHD_4bd4f4998e8b4c39bf4314164bb856f1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4bd4f4998e8b4c39bf4314164bb856f1() - { - this.Initialize("remove_MyEvent", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.EventHandler), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - throw new System.InvalidOperationException("Access to event special methods is not supported by hardwired decriptors."); - } - } - - private sealed class MTHD_e8564581746b4e98a73d3067effc13bc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e8564581746b4e98a73d3067effc13bc() - { - this.Initialize("add_MySEvent", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.EventHandler), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - throw new System.InvalidOperationException("Access to event special methods is not supported by hardwired decriptors."); - } - } - - private sealed class MTHD_d4af209cc89b489cba2f6236c3a870c7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d4af209cc89b489cba2f6236c3a870c7() - { - this.Initialize("remove_MySEvent", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.EventHandler), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - throw new System.InvalidOperationException("Access to event special methods is not supported by hardwired decriptors."); - } - } - - private sealed class MTHD_b8601870224449a2b3f19b33abd72102 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b8601870224449a2b3f19b33abd72102() - { - this.Initialize("Trigger_MyEvent", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass)(obj)).Trigger_MyEvent(); - } - } - - private sealed class MTHD_19881438dfc94d978b534f5f97bd3ba2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_19881438dfc94d978b534f5f97bd3ba2() - { - this.Initialize("Trigger_MySEvent", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataEventsTests.SomeClass.Trigger_MySEvent(); - } - } - - private sealed class MTHD_7388b1061aff46b7975a0210d977d779 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7388b1061aff46b7975a0210d977d779() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_e6e782c089d5441aaf0f7f239522b6b3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e6e782c089d5441aaf0f7f239522b6b3() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_bdaac254875d47e1afa86cf26d7a1f81 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bdaac254875d47e1afa86cf26d7a1f81() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_59cce498d000415bac84cc162f1d7b3c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_59cce498d000415bac84cc162f1d7b3c() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of System.EventArgs - // Descriptor of System.EventArgs - private sealed class TYPE_7569b35816794806aa24df61d472ad96 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_7569b35816794806aa24df61d472ad96() : - base(typeof(System.EventArgs)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.EventArgs), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4c5fa6f3113e4a26850156d7672716ec()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.EventArgs), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0cf0c7f3a6e149c183ff39f7e72b8484()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.EventArgs), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_29f33afe3af0448f8562c7e5c15acacd()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.EventArgs), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_87056c53527b440f91a2a4ed9088ae88()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.EventArgs), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9fefa144a39b4841bfcb5d8447dab7c7()})); - this.AddMember("Empty", new FLDV_7668aa5ca821481b9806f2481378d04e()); - } - - private sealed class MTHD_4c5fa6f3113e4a26850156d7672716ec : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4c5fa6f3113e4a26850156d7672716ec() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.EventArgs(); - } - } - - private sealed class MTHD_0cf0c7f3a6e149c183ff39f7e72b8484 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0cf0c7f3a6e149c183ff39f7e72b8484() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_29f33afe3af0448f8562c7e5c15acacd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_29f33afe3af0448f8562c7e5c15acacd() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_87056c53527b440f91a2a4ed9088ae88 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_87056c53527b440f91a2a4ed9088ae88() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_9fefa144a39b4841bfcb5d8447dab7c7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9fefa144a39b4841bfcb5d8447dab7c7() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_7668aa5ca821481b9806f2481378d04e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_7668aa5ca821481b9806f2481378d04e() : - base(typeof(System.EventArgs), "Empty", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return System.EventArgs.Empty; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests+EnumOverloadsTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests+EnumOverloadsTestClass - private sealed class TYPE_8df48697e4b4488fac40be824e5775c2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_8df48697e4b4488fac40be824e5775c2() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_420280ab823a47039f5fc506b91a330f()})); - this.AddMember("MyMethod", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MyMethod", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9138c834754644b38de0848a8c929995(), - new MTHD_b3fae8f71d0846e9ad0524fd49db68b2()})); - this.AddMember("MyMethod2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MyMethod2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7b96764fa73d45298794c41419accd97()})); - this.AddMember("MyMethodB", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MyMethodB", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b388f2bcd57a4d8384be0f3078d4f5d5()})); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e4f8c8c532f143f9be3ca5232126b110()})); - this.AddMember("GetF", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetF", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e8c7f0e12dfa448db2f2cd8fb92e53f1()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f98e618550a041e38cc7ee5275190c7f()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4724dd075d8c49e79c3c6a0325f4f04f()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bcbd005b2bf94eada273944169f95f45()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_07bcfc2af1f041d88948b1115b643f67()})); - } - - private sealed class MTHD_420280ab823a47039f5fc506b91a330f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_420280ab823a47039f5fc506b91a330f() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass(); - } - } - - private sealed class MTHD_9138c834754644b38de0848a8c929995 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9138c834754644b38de0848a8c929995() - { - this.Initialize("MyMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("enm", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MyEnum), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).MyMethod(((MoonSharp.Interpreter.Tests.EndToEnd.MyEnum)(pars[0]))); - } - } - - private sealed class MTHD_b3fae8f71d0846e9ad0524fd49db68b2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b3fae8f71d0846e9ad0524fd49db68b2() - { - this.Initialize("MyMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("enm", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MyFlags), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).MyMethod(((MoonSharp.Interpreter.Tests.EndToEnd.MyFlags)(pars[0]))); - } - } - - private sealed class MTHD_7b96764fa73d45298794c41419accd97 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7b96764fa73d45298794c41419accd97() - { - this.Initialize("MyMethod2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("enm", typeof(MoonSharp.Interpreter.Tests.EndToEnd.MyEnum), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).MyMethod2(((MoonSharp.Interpreter.Tests.EndToEnd.MyEnum)(pars[0]))); - } - } - - private sealed class MTHD_b388f2bcd57a4d8384be0f3078d4f5d5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b388f2bcd57a4d8384be0f3078d4f5d5() - { - this.Initialize("MyMethodB", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("b", typeof(bool), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).MyMethodB(((bool)(pars[0]))); - } - } - - private sealed class MTHD_e4f8c8c532f143f9be3ca5232126b110 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e4f8c8c532f143f9be3ca5232126b110() - { - this.Initialize("Get", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).Get(); - } - } - - private sealed class MTHD_e8c7f0e12dfa448db2f2cd8fb92e53f1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e8c7f0e12dfa448db2f2cd8fb92e53f1() - { - this.Initialize("GetF", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataEnumsTests.EnumOverloadsTestClass)(obj)).GetF(); - } - } - - private sealed class MTHD_f98e618550a041e38cc7ee5275190c7f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f98e618550a041e38cc7ee5275190c7f() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_4724dd075d8c49e79c3c6a0325f4f04f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4724dd075d8c49e79c3c6a0325f4f04f() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_bcbd005b2bf94eada273944169f95f45 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bcbd005b2bf94eada273944169f95f45() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_07bcfc2af1f041d88948b1115b643f67 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_07bcfc2af1f041d88948b1115b643f67() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType+SomeNestedType - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType+SomeNestedType - private sealed class TYPE_fdd5466522954a8ead748408a2a3e02e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_fdd5466522954a8ead748408a2a3e02e() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4d8d5b129c674ba4930f9284d2316334()})); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_acb0da223bbd4f8392f0330a30b8c5f8()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ddee3f67d5684952bc7808c2f38d84d8()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cb4eac4a74de49388d4491b68e1d2a16()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f67155c2c2fd4515b0f9f1b4859506e2()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6ab74b925d554d2586bd588f700651c3()})); - } - - private sealed class MTHD_4d8d5b129c674ba4930f9284d2316334 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4d8d5b129c674ba4930f9284d2316334() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType(); - } - } - - private sealed class MTHD_acb0da223bbd4f8392f0330a30b8c5f8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_acb0da223bbd4f8392f0330a30b8c5f8() - { - this.Initialize("Get", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType.Get(); - } - } - - private sealed class MTHD_ddee3f67d5684952bc7808c2f38d84d8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ddee3f67d5684952bc7808c2f38d84d8() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_cb4eac4a74de49388d4491b68e1d2a16 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cb4eac4a74de49388d4491b68e1d2a16() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_f67155c2c2fd4515b0f9f1b4859506e2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f67155c2c2fd4515b0f9f1b4859506e2() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_6ab74b925d554d2586bd588f700651c3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6ab74b925d554d2586bd588f700651c3() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+SomeType - private sealed class TYPE_480c8e43dcda4daeb4f7736380f9d3db : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_480c8e43dcda4daeb4f7736380f9d3db() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eb25285187c84dd6aa143184d70bea96()})); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f033237d6c624ff4b4ee00750d34223f()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_118e093ccd80444cbcf2ab4c38fbf94b()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_12cb570e74b947a5a32ab27d182afbd2()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b057590aae694c49a6b965f1a4480baa()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_be8c1f3af11d43b9a051429d7ba7e6f3()})); - this.AddMember("SomeNestedEnum", new DVAL_884ef0c5eeed46e0a64b777cc2425d41()); - this.AddMember("SomeNestedType", new DVAL_a00953bd37d04b8f952fdbd2f6f2b372()); - } - - private sealed class MTHD_eb25285187c84dd6aa143184d70bea96 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eb25285187c84dd6aa143184d70bea96() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType(); - } - } - - private sealed class MTHD_f033237d6c624ff4b4ee00750d34223f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f033237d6c624ff4b4ee00750d34223f() - { - this.Initialize("Get", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.Get(); - } - } - - private sealed class MTHD_118e093ccd80444cbcf2ab4c38fbf94b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_118e093ccd80444cbcf2ab4c38fbf94b() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_12cb570e74b947a5a32ab27d182afbd2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_12cb570e74b947a5a32ab27d182afbd2() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_b057590aae694c49a6b965f1a4480baa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b057590aae694c49a6b965f1a4480baa() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_be8c1f3af11d43b9a051429d7ba7e6f3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_be8c1f3af11d43b9a051429d7ba7e6f3() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class DVAL_884ef0c5eeed46e0a64b777cc2425d41 : MoonSharp.Interpreter.Interop.DynValueMemberDescriptor - { - - internal DVAL_884ef0c5eeed46e0a64b777cc2425d41() : - base("SomeNestedEnum") - { - } - - public override MoonSharp.Interpreter.DynValue Value - { - get - { - return MoonSharp.Interpreter.UserData.CreateStatic(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedEnum)); - } - } - } - - private sealed class DVAL_a00953bd37d04b8f952fdbd2f6f2b372 : MoonSharp.Interpreter.Interop.DynValueMemberDescriptor - { - - internal DVAL_a00953bd37d04b8f952fdbd2f6f2b372() : - base("SomeNestedType") - { - } - - public override MoonSharp.Interpreter.DynValue Value - { - get - { - return MoonSharp.Interpreter.UserData.CreateStatic(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.SomeType.SomeNestedType)); - } - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType+SomeNestedType - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType+SomeNestedType - private sealed class TYPE_d8f481563a93412d905a66a0f4640f91 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_d8f481563a93412d905a66a0f4640f91() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_2d00abdeed2747d09b567187cf0d1b19()})); - this.AddMember("Get", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Get", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cdae6ec63bc24e8996a5d12db1911652()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0a5c99e5fd264597a81dee4eef73bc52()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_18448d6a6f714902ae44aea461d1b0eb()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_17666d63f3864fd88e263a96b74e4ba9()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_82416193254148cd92879a9f1e895d4c()})); - } - - private sealed class VTDC_2d00abdeed2747d09b567187cf0d1b19 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_2d00abdeed2747d09b567187cf0d1b19() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType(); - } - } - - private sealed class MTHD_cdae6ec63bc24e8996a5d12db1911652 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cdae6ec63bc24e8996a5d12db1911652() - { - this.Initialize("Get", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType.Get(); - } - } - - private sealed class MTHD_0a5c99e5fd264597a81dee4eef73bc52 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0a5c99e5fd264597a81dee4eef73bc52() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_18448d6a6f714902ae44aea461d1b0eb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_18448d6a6f714902ae44aea461d1b0eb() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_17666d63f3864fd88e263a96b74e4ba9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_17666d63f3864fd88e263a96b74e4ba9() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_82416193254148cd92879a9f1e895d4c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_82416193254148cd92879a9f1e895d4c() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests+VSomeType - private sealed class TYPE_159cf7f2538e48f0aa152cdabc23042e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_159cf7f2538e48f0aa152cdabc23042e() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_8d63c9e79d754a5482b3c7ec64996ace()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_383e92588ea94f01843ea2fc9b6b2fba()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9f2e63e92fda4c629e818aeaee6ee9a8()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_04f168ea22d94d13be266e57ce903011()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae3e39f9fceb478bba91901c5ab0baf1()})); - this.AddMember("SomeNestedType", new DVAL_11b393a314d64c36867e598106e02ddf()); - } - - private sealed class VTDC_8d63c9e79d754a5482b3c7ec64996ace : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_8d63c9e79d754a5482b3c7ec64996ace() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType(); - } - } - - private sealed class MTHD_383e92588ea94f01843ea2fc9b6b2fba : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_383e92588ea94f01843ea2fc9b6b2fba() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_9f2e63e92fda4c629e818aeaee6ee9a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9f2e63e92fda4c629e818aeaee6ee9a8() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_04f168ea22d94d13be266e57ce903011 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_04f168ea22d94d13be266e57ce903011() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_ae3e39f9fceb478bba91901c5ab0baf1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae3e39f9fceb478bba91901c5ab0baf1() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class DVAL_11b393a314d64c36867e598106e02ddf : MoonSharp.Interpreter.Interop.DynValueMemberDescriptor - { - - internal DVAL_11b393a314d64c36867e598106e02ddf() : - base("SomeNestedType") - { - } - - public override MoonSharp.Interpreter.DynValue Value - { - get - { - return MoonSharp.Interpreter.UserData.CreateStatic(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataNestedTypesTests.VSomeType.SomeNestedType)); - } - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests+SomeClass - private sealed class TYPE_edfd942631734cc1951924896cb28111 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_edfd942631734cc1951924896cb28111() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_17241aa0086048d4abb00578c817a383()})); - this.AddMember("get_IntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_88f9c4889fc841409040df482d3931e5()})); - this.AddMember("set_IntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_IntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b98fa7ab296e4394bad5d2490bd0bb5c()})); - this.AddMember("get_NIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_NIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ab7f3b32ee794cedb7c41c09b556a8f8()})); - this.AddMember("set_NIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_NIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fd23ba84ac6b41f5b02390c72b827e5b()})); - this.AddMember("get_ObjProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_ObjProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c389113e31304cd5a8fbbf0772be6c10()})); - this.AddMember("set_ObjProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_ObjProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8c41fc1651944b0fa9fc38af0b1b424d()})); - this.AddMember("get_StaticProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_StaticProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1284bf55fcf246fca01203fa4ac8ddaf()})); - this.AddMember("set_StaticProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_StaticProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_626fe0dbb101472d920b3b4c11a44005()})); - this.AddMember("get_RoIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_RoIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2c6331957d2542b9bde070ea3dc26954()})); - this.AddMember("get_RoIntProp2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_RoIntProp2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_15e6c747533d48c3be203c04dbb4dd94()})); - this.AddMember("set_WoIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_WoIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c84f41c452134c5b949738dd9ace1f0a()})); - this.AddMember("set_WoIntProp2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_WoIntProp2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_842287ae93674dc9977e8915fa26a3ab()})); - this.AddMember("GetWoIntProp2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetWoIntProp2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ed6a5e1607aa4996a2508e1d7cbf5236()})); - this.AddMember("set_AccessOverrProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_AccessOverrProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5e7a11a025c248599df3ea5681a3bfe1()})); - this.AddMember("get_Numbers", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Numbers", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_70fdc6f31e8a4519bb7b437400279b56()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8be3d525bb3247e288e9a3d5ed751d19()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cb57f0c7f7b443698a887cda8495d25b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8c880709014f4f1c8e2e584ff53e80ce()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2e23649bed26410986e26732b7b9817b()})); - this.AddMember("IntProp", new PROP_e399a9731982482a90d7c9cd12c72172()); - this.AddMember("NIntProp", new PROP_f23ba4ac7c7f46f2bb9dac656bd3d03f()); - this.AddMember("ObjProp", new PROP_f3b377ac313748f4bcd595ab05fc0744()); - this.AddMember("StaticProp", new PROP_4f7a58e4ac6347248e7eaf60551bc735()); - this.AddMember("RoIntProp", new PROP_13d2755eca5c43f39f3254d5f1daf737()); - this.AddMember("RoIntProp2", new PROP_b6d3bea495154b54a434a2cb12025e03()); - this.AddMember("WoIntProp", new PROP_43502f5f435e4ff3bbe039b06479b2cf()); - this.AddMember("WoIntProp2", new PROP_283901a0f8f8412fa0bc0ee9544f6a19()); - this.AddMember("AccessOverrProp", new PROP_7e23dd4c1a1245f5a9e72f93165a1dbd()); - this.AddMember("Numbers", new PROP_82f1bacd6af1453986fac8a33d99101e()); - } - - private sealed class VTDC_17241aa0086048d4abb00578c817a383 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_17241aa0086048d4abb00578c817a383() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass(); - } - } - - private sealed class MTHD_88f9c4889fc841409040df482d3931e5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_88f9c4889fc841409040df482d3931e5() - { - this.Initialize("get_IntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).IntProp; - } - } - - private sealed class MTHD_b98fa7ab296e4394bad5d2490bd0bb5c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b98fa7ab296e4394bad5d2490bd0bb5c() - { - this.Initialize("set_IntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.IntProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_ab7f3b32ee794cedb7c41c09b556a8f8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ab7f3b32ee794cedb7c41c09b556a8f8() - { - this.Initialize("get_NIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).NIntProp; - } - } - - private sealed class MTHD_fd23ba84ac6b41f5b02390c72b827e5b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fd23ba84ac6b41f5b02390c72b827e5b() - { - this.Initialize("set_NIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.Nullable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(pars[0])); - return null; - } - } - - private sealed class MTHD_c389113e31304cd5a8fbbf0772be6c10 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c389113e31304cd5a8fbbf0772be6c10() - { - this.Initialize("get_ObjProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).ObjProp; - } - } - - private sealed class MTHD_8c41fc1651944b0fa9fc38af0b1b424d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8c41fc1651944b0fa9fc38af0b1b424d() - { - this.Initialize("set_ObjProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(pars[0])); - return null; - } - } - - private sealed class MTHD_1284bf55fcf246fca01203fa4ac8ddaf : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1284bf55fcf246fca01203fa4ac8ddaf() - { - this.Initialize("get_StaticProp", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.StaticProp; - } - } - - private sealed class MTHD_626fe0dbb101472d920b3b4c11a44005 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_626fe0dbb101472d920b3b4c11a44005() - { - this.Initialize("set_StaticProp", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(string), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.StaticProp = ((string)(pars[0])); - return null; - } - } - - private sealed class MTHD_2c6331957d2542b9bde070ea3dc26954 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2c6331957d2542b9bde070ea3dc26954() - { - this.Initialize("get_RoIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).RoIntProp; - } - } - - private sealed class MTHD_15e6c747533d48c3be203c04dbb4dd94 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_15e6c747533d48c3be203c04dbb4dd94() - { - this.Initialize("get_RoIntProp2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).RoIntProp2; - } - } - - private sealed class MTHD_c84f41c452134c5b949738dd9ace1f0a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c84f41c452134c5b949738dd9ace1f0a() - { - this.Initialize("set_WoIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_842287ae93674dc9977e8915fa26a3ab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_842287ae93674dc9977e8915fa26a3ab() - { - this.Initialize("set_WoIntProp2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp2 = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_ed6a5e1607aa4996a2508e1d7cbf5236 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ed6a5e1607aa4996a2508e1d7cbf5236() - { - this.Initialize("GetWoIntProp2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).GetWoIntProp2(); - } - } - - private sealed class MTHD_5e7a11a025c248599df3ea5681a3bfe1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5e7a11a025c248599df3ea5681a3bfe1() - { - this.Initialize("set_AccessOverrProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.AccessOverrProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_70fdc6f31e8a4519bb7b437400279b56 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_70fdc6f31e8a4519bb7b437400279b56() - { - this.Initialize("get_Numbers", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.Numbers; - } - } - - private sealed class MTHD_8be3d525bb3247e288e9a3d5ed751d19 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8be3d525bb3247e288e9a3d5ed751d19() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_cb57f0c7f7b443698a887cda8495d25b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cb57f0c7f7b443698a887cda8495d25b() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_8c880709014f4f1c8e2e584ff53e80ce : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8c880709014f4f1c8e2e584ff53e80ce() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_2e23649bed26410986e26732b7b9817b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2e23649bed26410986e26732b7b9817b() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_e399a9731982482a90d7c9cd12c72172 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_e399a9731982482a90d7c9cd12c72172() : - base(typeof(int), "IntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).IntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.IntProp = ((int)(value)); - } - } - - private sealed class PROP_f23ba4ac7c7f46f2bb9dac656bd3d03f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_f23ba4ac7c7f46f2bb9dac656bd3d03f() : - base(typeof(System.Nullable), "NIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).NIntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(value)); - } - } - - private sealed class PROP_f3b377ac313748f4bcd595ab05fc0744 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_f3b377ac313748f4bcd595ab05fc0744() : - base(typeof(object), "ObjProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).ObjProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(value)); - } - } - - private sealed class PROP_4f7a58e4ac6347248e7eaf60551bc735 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_4f7a58e4ac6347248e7eaf60551bc735() : - base(typeof(string), "StaticProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.StaticProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.StaticProp = ((string)(value)); - } - } - - private sealed class PROP_13d2755eca5c43f39f3254d5f1daf737 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_13d2755eca5c43f39f3254d5f1daf737() : - base(typeof(int), "RoIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).RoIntProp; - } - } - - private sealed class PROP_b6d3bea495154b54a434a2cb12025e03 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_b6d3bea495154b54a434a2cb12025e03() : - base(typeof(int), "RoIntProp2", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)).RoIntProp2; - } - } - - private sealed class PROP_43502f5f435e4ff3bbe039b06479b2cf : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_43502f5f435e4ff3bbe039b06479b2cf() : - base(typeof(int), "WoIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp = ((int)(value)); - } - } - - private sealed class PROP_283901a0f8f8412fa0bc0ee9544f6a19 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_283901a0f8f8412fa0bc0ee9544f6a19() : - base(typeof(int), "WoIntProp2", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp2 = ((int)(value)); - } - } - - private sealed class PROP_7e23dd4c1a1245f5a9e72f93165a1dbd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_7e23dd4c1a1245f5a9e72f93165a1dbd() : - base(typeof(int), "AccessOverrProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass)(obj)); - tmp.AccessOverrProp = ((int)(value)); - } - } - - private sealed class PROP_82f1bacd6af1453986fac8a33d99101e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_82f1bacd6af1453986fac8a33d99101e() : - base(typeof(System.Collections.Generic.IEnumerable), "Numbers", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataPropertiesTests.SomeClass.Numbers; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests+OverloadsTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests+OverloadsTestClass - private sealed class TYPE_42c7f3d0acb341bca981275e2ecf79c9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_42c7f3d0acb341bca981275e2ecf79c9() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_7605d3a10aa24389a924390988b031f7()})); - this.AddMember("UnCalled", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("UnCalled", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e745cb1c235a47ce8c26e52741f9fd8e()})); - this.AddMember("MethodV", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MethodV", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_848e5676b4ee415198a0790d27a2ff6a(), - new MTHD_57ddabec2a204daba7f51311ad7d98ed()})); - this.AddMember("Method1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c8227904485d4853ba013a191119fef1(), - new MTHD_54bf8fd5f6274e24833132dfa9608e51(), - new MTHD_c47a1a8ad4cd4579927d80f42552a3c6(), - new MTHD_60dfd6e3c7d8438c98746f0507f11b1d(), - new MTHD_884ae9375b684daeb5af67d72a097c4e(), - new MTHD_0a6873e53fb34ff1baa5560987e8e5c9()})); - this.AddMember("Method2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_02fb46d4b00145e1b47119bb19de385b(), - new MTHD_ba5a6fb9366f4cc4b8567d534b8ca847(), - new MTHD_ea03426c827d4625a1cd458c89ace4d8()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_da3e2953545544ec80167feea7e6614c()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2bff607cfabd4828b61dc4c835daceb0()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_73e25b996e4e4b80b3cec420f9837132()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7da29db7e62141878c87936b0b2ab20e()})); - this.AddMember("Method3", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method3", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - } - - private sealed class VTDC_7605d3a10aa24389a924390988b031f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_7605d3a10aa24389a924390988b031f7() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass(); - } - } - - private sealed class MTHD_e745cb1c235a47ce8c26e52741f9fd8e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e745cb1c235a47ce8c26e52741f9fd8e() - { - this.Initialize("UnCalled", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass.UnCalled(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_848e5676b4ee415198a0790d27a2ff6a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_848e5676b4ee415198a0790d27a2ff6a() - { - this.Initialize("MethodV", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("fmt", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("a", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("b", typeof(bool), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).MethodV(((string)(pars[0])), ((int)(pars[1])), ((bool)(pars[2]))); - } - } - - private sealed class MTHD_57ddabec2a204daba7f51311ad7d98ed : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_57ddabec2a204daba7f51311ad7d98ed() - { - this.Initialize("MethodV", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("fmt", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("args", typeof(object[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).MethodV(((string)(pars[0])), ((object[])(pars[1]))); - } - } - - private sealed class MTHD_c8227904485d4853ba013a191119fef1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c8227904485d4853ba013a191119fef1() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(); - } - } - - private sealed class MTHD_54bf8fd5f6274e24833132dfa9608e51 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_54bf8fd5f6274e24833132dfa9608e51() - { - this.Initialize("Method1", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("b", typeof(bool), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass.Method1(((bool)(pars[0]))); - } - } - - private sealed class MTHD_c47a1a8ad4cd4579927d80f42552a3c6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c47a1a8ad4cd4579927d80f42552a3c6() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0]))); - } - } - - private sealed class MTHD_60dfd6e3c7d8438c98746f0507f11b1d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_60dfd6e3c7d8438c98746f0507f11b1d() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 1)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1]))); - } - } - - private sealed class MTHD_884ae9375b684daeb5af67d72a097c4e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_884ae9375b684daeb5af67d72a097c4e() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 2)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_0a6873e53fb34ff1baa5560987e8e5c9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0a6873e53fb34ff1baa5560987e8e5c9() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("a", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((int)(pars[0]))); - } - } - - private sealed class MTHD_02fb46d4b00145e1b47119bb19de385b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_02fb46d4b00145e1b47119bb19de385b() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ((string)(pars[1]))); - } - } - - private sealed class MTHD_ba5a6fb9366f4cc4b8567d534b8ca847 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ba5a6fb9366f4cc4b8567d534b8ca847() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, true, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ref refp_0); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0)}); - } - } - - private sealed class MTHD_ea03426c827d4625a1cd458c89ace4d8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ea03426c827d4625a1cd458c89ace4d8() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, true, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("z", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ref refp_0, ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0)}); - } - } - - private sealed class MTHD_da3e2953545544ec80167feea7e6614c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_da3e2953545544ec80167feea7e6614c() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_2bff607cfabd4828b61dc4c835daceb0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2bff607cfabd4828b61dc4c835daceb0() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_73e25b996e4e4b80b3cec420f9837132 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_73e25b996e4e4b80b3cec420f9837132() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_7da29db7e62141878c87936b0b2ab20e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7da29db7e62141878c87936b0b2ab20e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+SomeClass - private sealed class TYPE_835b52631f614895b7b48ef29d9dfe1b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_835b52631f614895b7b48ef29d9dfe1b() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_399f489e5ee141fc882ce3921ef25aa8()})); - this.AddMember("ManipulateString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ManipulateString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bad96bfebd744e9b8a7d7c76ab89f1fb()})); - this.AddMember("ConcatNums", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatNums", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_aaeef7d4465b42cfa4568842c80fa7ba(), - new MTHD_2e1e5dfffa93444caa9699db8d2b2a7f()})); - this.AddMember("SomeMethodWithLongName", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SomeMethodWithLongName", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b62e2368ea2a4919912d46b3a28e56f5()})); - this.AddMember("SetComplexRecursive", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetComplexRecursive", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_db210e12250243eabfe4e8f77adf8b16()})); - this.AddMember("SetComplexTypes", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetComplexTypes", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_345caedb6eb149fc8772d0b7373f4ca5()})); - this.AddMember("ConcatS", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatS", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_baee167a86ef472f805f4985c5f2684b()})); - this.AddMember("Format", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Format", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_87bf6ad2548e4fcb90f999106f02fbbd()})); - this.AddMember("ConcatI", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatI", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4c7a0cda196f459fb150259bb3a9c3c9()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_69120ba0c4cd43e5bb2f5254fa36c289()})); - this.AddMember("MkList", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MkList", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_45a046f77247409fb24dbf3b36ef9e90()})); - this.AddMember("CompareTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CompareTo", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f35925bd986944ffb16dc95f1609afa9()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bf20b809d3944d7c989581d44b50976d()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cda4861383d649e29a4e1a6812e9879f()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e0638a6c52ff41789f1c000727e7ff31()})); - } - - private sealed class VTDC_399f489e5ee141fc882ce3921ef25aa8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_399f489e5ee141fc882ce3921ef25aa8() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass(); - } - } - - private sealed class MTHD_bad96bfebd744e9b8a7d7c76ab89f1fb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bad96bfebd744e9b8a7d7c76ab89f1fb() - { - this.Initialize("ManipulateString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("input", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("tobeconcat", typeof(string), false, null, false, true, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lowercase", typeof(string), false, null, true, true, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - string refp_1; - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ManipulateString(((string)(pars[0])), ref refp_0, out refp_1); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_1)}); - } - } - - private sealed class MTHD_aaeef7d4465b42cfa4568842c80fa7ba : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_aaeef7d4465b42cfa4568842c80fa7ba() - { - this.Initialize("ConcatNums", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ConcatNums(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_2e1e5dfffa93444caa9699db8d2b2a7f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2e1e5dfffa93444caa9699db8d2b2a7f() - { - this.Initialize("ConcatNums", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ConcatNums(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_b62e2368ea2a4919912d46b3a28e56f5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b62e2368ea2a4919912d46b3a28e56f5() - { - this.Initialize("SomeMethodWithLongName", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("i", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).SomeMethodWithLongName(((int)(pars[0]))); - } - } - - private sealed class MTHD_db210e12250243eabfe4e8f77adf8b16 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_db210e12250243eabfe4e8f77adf8b16() - { - this.Initialize("SetComplexRecursive", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intList", typeof(System.Collections.Generic.List), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass.SetComplexRecursive(((System.Collections.Generic.List)(pars[0]))); - } - } - - private sealed class MTHD_345caedb6eb149fc8772d0b7373f4ca5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_345caedb6eb149fc8772d0b7373f4ca5() - { - this.Initialize("SetComplexTypes", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("strlist", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intlist", typeof(System.Collections.Generic.IList), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("map", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("strarray", typeof(string[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intarray", typeof(int[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass.SetComplexTypes(((System.Collections.Generic.List)(pars[0])), ((System.Collections.Generic.IList)(pars[1])), ((System.Collections.Generic.Dictionary)(pars[2])), ((string[])(pars[3])), ((int[])(pars[4]))); - } - } - - private sealed class MTHD_baee167a86ef472f805f4985c5f2684b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_baee167a86ef472f805f4985c5f2684b() - { - this.Initialize("ConcatS", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p3", typeof(System.IComparable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p4", typeof(bool), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p5", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p6", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p7", typeof(System.Text.StringBuilder), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p8", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p9", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p10", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 9)) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass.ConcatS(((int)(pars[0])), ((string)(pars[1])), ((System.IComparable)(pars[2])), ((bool)(pars[3])), ((System.Collections.Generic.List)(pars[4])), ((System.Collections.Generic.IEnumerable)(pars[5])), ((System.Text.StringBuilder)(pars[6])), ((System.Collections.Generic.Dictionary)(pars[7])), ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(pars[8]))); - } - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass.ConcatS(((int)(pars[0])), ((string)(pars[1])), ((System.IComparable)(pars[2])), ((bool)(pars[3])), ((System.Collections.Generic.List)(pars[4])), ((System.Collections.Generic.IEnumerable)(pars[5])), ((System.Text.StringBuilder)(pars[6])), ((System.Collections.Generic.Dictionary)(pars[7])), ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(pars[8])), ((int)(pars[9]))); - } - } - - private sealed class MTHD_87bf6ad2548e4fcb90f999106f02fbbd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_87bf6ad2548e4fcb90f999106f02fbbd() - { - this.Initialize("Format", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("s", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("args", typeof(object[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).Format(((string)(pars[0])), ((object[])(pars[1]))); - } - } - - private sealed class MTHD_4c7a0cda196f459fb150259bb3a9c3c9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4c7a0cda196f459fb150259bb3a9c3c9() - { - this.Initialize("ConcatI", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("s", typeof(MoonSharp.Interpreter.Script), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p3", typeof(System.IComparable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p4", typeof(bool), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p5", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p6", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p7", typeof(System.Text.StringBuilder), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p8", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p9", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p10", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 10)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ConcatI(((MoonSharp.Interpreter.Script)(pars[0])), ((int)(pars[1])), ((string)(pars[2])), ((System.IComparable)(pars[3])), ((bool)(pars[4])), ((System.Collections.Generic.List)(pars[5])), ((System.Collections.Generic.IEnumerable)(pars[6])), ((System.Text.StringBuilder)(pars[7])), ((System.Collections.Generic.Dictionary)(pars[8])), ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(pars[9]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ConcatI(((MoonSharp.Interpreter.Script)(pars[0])), ((int)(pars[1])), ((string)(pars[2])), ((System.IComparable)(pars[3])), ((bool)(pars[4])), ((System.Collections.Generic.List)(pars[5])), ((System.Collections.Generic.IEnumerable)(pars[6])), ((System.Text.StringBuilder)(pars[7])), ((System.Collections.Generic.Dictionary)(pars[8])), ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(pars[9])), ((int)(pars[10]))); - } - } - - private sealed class MTHD_69120ba0c4cd43e5bb2f5254fa36c289 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_69120ba0c4cd43e5bb2f5254fa36c289() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).ToString(); - } - } - - private sealed class MTHD_45a046f77247409fb24dbf3b36ef9e90 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_45a046f77247409fb24dbf3b36ef9e90() - { - this.Initialize("MkList", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("from", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("to", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).MkList(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_f35925bd986944ffb16dc95f1609afa9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f35925bd986944ffb16dc95f1609afa9() - { - this.Initialize("CompareTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeClass)(obj)).CompareTo(((object)(pars[0]))); - } - } - - private sealed class MTHD_bf20b809d3944d7c989581d44b50976d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bf20b809d3944d7c989581d44b50976d() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_cda4861383d649e29a4e1a6812e9879f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cda4861383d649e29a4e1a6812e9879f() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_e0638a6c52ff41789f1c000727e7ff31 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e0638a6c52ff41789f1c000727e7ff31() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+SomeOtherClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+SomeOtherClass - private sealed class TYPE_d4bc7b8842184932b3fa631f414a2cc7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_d4bc7b8842184932b3fa631f414a2cc7() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a7eecbe96e7b4b62a37e5ffa2e0e7df1()})); - this.AddMember("Test1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_56d1415b09ed436b8be56c4881f1d634()})); - this.AddMember("Test2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_edd797f159da46a2886ab6214b342b65()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_60867aee9a234a74a1326de2478c7273()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0423fdcac9e848dc972d7fbf8906247c()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3332e480f7dc44119616e4337bd6003d()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a76ec96e95d8431585c73b3706985b67()})); - } - - private sealed class MTHD_a7eecbe96e7b4b62a37e5ffa2e0e7df1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a7eecbe96e7b4b62a37e5ffa2e0e7df1() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass(); - } - } - - private sealed class MTHD_56d1415b09ed436b8be56c4881f1d634 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_56d1415b09ed436b8be56c4881f1d634() - { - this.Initialize("Test1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass)(obj)).Test1(); - } - } - - private sealed class MTHD_edd797f159da46a2886ab6214b342b65 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_edd797f159da46a2886ab6214b342b65() - { - this.Initialize("Test2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.SomeOtherClass)(obj)).Test2(); - } - } - - private sealed class MTHD_60867aee9a234a74a1326de2478c7273 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_60867aee9a234a74a1326de2478c7273() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_0423fdcac9e848dc972d7fbf8906247c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0423fdcac9e848dc972d7fbf8906247c() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_3332e480f7dc44119616e4337bd6003d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3332e480f7dc44119616e4337bd6003d() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_a76ec96e95d8431585c73b3706985b67 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a76ec96e95d8431585c73b3706985b67() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+Interface1 - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+Interface1 - private sealed class TYPE_dc0291b3e19a4bb1b9944defdb5d6a77 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_dc0291b3e19a4bb1b9944defdb5d6a77() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface1)) - { - this.AddMember("Test1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface1), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c0dd52b61452453a8a659dfe1c78f53d()})); - } - - private sealed class MTHD_c0dd52b61452453a8a659dfe1c78f53d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c0dd52b61452453a8a659dfe1c78f53d() - { - this.Initialize("Test1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface1)(obj)).Test1(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+Interface2 - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests+Interface2 - private sealed class TYPE_8b14e5a0f85c42219e8c5b4b7ff618ca : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_8b14e5a0f85c42219e8c5b4b7ff618ca() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface2)) - { - this.AddMember("Test2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface2), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_14f753dde9834623be28e1c4cd233040()})); - } - - private sealed class MTHD_14f753dde9834623be28e1c4cd233040 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_14f753dde9834623be28e1c4cd233040() - { - this.Initialize("Test2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMethodsTests.Interface2)(obj)).Test2(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ArithmOperatorsTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ArithmOperatorsTestClass - private sealed class TYPE_b7f437771da443599c33303bb0a7c864 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_b7f437771da443599c33303bb0a7c864() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8e7c558f114745bdb105b0b73def0dde(), - new VTDC_10e0f99aa6fa4bb594039e26a05a9289()})); - this.AddMember("get_Value", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_161b259cfdcd4dc2921370b3d864fe49()})); - this.AddMember("set_Value", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5252facdb0334a62b6c988fe03588b68()})); - this.AddMember("op_UnaryNegation", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_UnaryNegation", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2e36dd85696246e997ae0b4dfc7f9759()})); - this.AddMember("op_Addition", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Addition", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_758b777c5c1f43ceb42721d18b6249f7(), - new MTHD_d488186f7d5e49fda6ea90bda52ed007(), - new MTHD_75c5c59401174fe9bb1f18f37d0266c0()})); - this.AddMember("op_Subtraction", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Subtraction", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7cd625b4d58a4596adda7f055c712c01(), - new MTHD_c5e4e02eb4cd42f1ad96308cab695706(), - new MTHD_bf48360d2ba84f7aa0e92858825b57f8()})); - this.AddMember("op_Multiply", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Multiply", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f088bab030c54524940fb8acf31ab2f3(), - new MTHD_89d91a89bb7943c78037fcee56e34b8c(), - new MTHD_c6c129673e524422a30ada6be2ca7e7e()})); - this.AddMember("op_Division", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Division", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_de398a80fde04ff38eb3d5176ed757cf(), - new MTHD_f258f434adf14c808ee8489b6d783c59(), - new MTHD_ac56944ef49547c8a2453a711c1c809d()})); - this.AddMember("op_Modulus", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Modulus", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0c0ac82ae9a74a6d9cc270ae5e920a90(), - new MTHD_3c161c94b03c43079328f33c6c9c6772(), - new MTHD_f476f6ef7f4441f08fba6bdb5028c92c()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_467469038cef422baae77039398e2413()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_199d683eb1a94619be17a7c8a39bd26e()})); - this.AddMember("CompareTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CompareTo", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1b27863856cc42f88656c47fb5f18ea5()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bc0ee29e56a3473bbd1a64c162de8455()})); - this.AddMember("DefaultMethod", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("DefaultMethod", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6d56e805427240a689a8c8dac422fdbb()})); - this.AddMember("Pairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Pairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3e04fe4e6732449497021e82df7bef61()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e689e7fa94a94e20a091f19feab77ef9()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_90908c4e51794c33abcf6a592b2c73e7()})); - this.AddMember("Value", new PROP_ea8c18bafafd4d568d2bbd8c350a5187()); - this.AddMetaMember("__concat", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__concat", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ddf3c57eb4b24123b0f6af163b8dd2f3(), - new MTHD_c372de05919f4b11ba20cc097168115f(), - new MTHD_28bfa36a4fba4141a483b7f5d1707f2f()})); - this.AddMetaMember("__pow", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__pow", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_10918aa1b5e449188e6c5f32faa7ce90(), - new MTHD_ed786cbe112144c19c9efaff8c7fbc04(), - new MTHD_ccc4f0eb26754a90aa2bc54a28a32e21()})); - this.AddMetaMember("__call", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__call", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5fca4669bedb4ba2b8f4eac58c4c0e68()})); - this.AddMetaMember("__pairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__pairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9831944a762b44fd85cf62e48b2f4436()})); - this.AddMetaMember("__ipairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__ipairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4c5236fc944243e3b52c7f6968db7de3()})); - } - - private sealed class MTHD_8e7c558f114745bdb105b0b73def0dde : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8e7c558f114745bdb105b0b73def0dde() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass(((int)(pars[0]))); - } - } - - private sealed class VTDC_10e0f99aa6fa4bb594039e26a05a9289 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_10e0f99aa6fa4bb594039e26a05a9289() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass(); - } - } - - private sealed class MTHD_161b259cfdcd4dc2921370b3d864fe49 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_161b259cfdcd4dc2921370b3d864fe49() - { - this.Initialize("get_Value", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Value; - } - } - - private sealed class MTHD_5252facdb0334a62b6c988fe03588b68 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5252facdb0334a62b6c988fe03588b68() - { - this.Initialize("set_Value", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)); - tmp.Value = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_2e36dd85696246e997ae0b4dfc7f9759 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2e36dd85696246e997ae0b4dfc7f9759() - { - this.Initialize("op_UnaryNegation", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (-((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0]))); - } - } - - private sealed class MTHD_758b777c5c1f43ceb42721d18b6249f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_758b777c5c1f43ceb42721d18b6249f7() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_d488186f7d5e49fda6ea90bda52ed007 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d488186f7d5e49fda6ea90bda52ed007() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_75c5c59401174fe9bb1f18f37d0266c0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_75c5c59401174fe9bb1f18f37d0266c0() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_7cd625b4d58a4596adda7f055c712c01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7cd625b4d58a4596adda7f055c712c01() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) - ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_c5e4e02eb4cd42f1ad96308cab695706 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c5e4e02eb4cd42f1ad96308cab695706() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) - ((int)(pars[1]))); - } - } - - private sealed class MTHD_bf48360d2ba84f7aa0e92858825b57f8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bf48360d2ba84f7aa0e92858825b57f8() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) - ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_f088bab030c54524940fb8acf31ab2f3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f088bab030c54524940fb8acf31ab2f3() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) * ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_89d91a89bb7943c78037fcee56e34b8c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_89d91a89bb7943c78037fcee56e34b8c() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) * ((int)(pars[1]))); - } - } - - private sealed class MTHD_c6c129673e524422a30ada6be2ca7e7e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c6c129673e524422a30ada6be2ca7e7e() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) * ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_de398a80fde04ff38eb3d5176ed757cf : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_de398a80fde04ff38eb3d5176ed757cf() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) / ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_f258f434adf14c808ee8489b6d783c59 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f258f434adf14c808ee8489b6d783c59() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) / ((int)(pars[1]))); - } - } - - private sealed class MTHD_ac56944ef49547c8a2453a711c1c809d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ac56944ef49547c8a2453a711c1c809d() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) / ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_0c0ac82ae9a74a6d9cc270ae5e920a90 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0c0ac82ae9a74a6d9cc270ae5e920a90() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) % ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_3c161c94b03c43079328f33c6c9c6772 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3c161c94b03c43079328f33c6c9c6772() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) % ((int)(pars[1]))); - } - } - - private sealed class MTHD_f476f6ef7f4441f08fba6bdb5028c92c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f476f6ef7f4441f08fba6bdb5028c92c() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) % ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_467469038cef422baae77039398e2413 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_467469038cef422baae77039398e2413() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_199d683eb1a94619be17a7c8a39bd26e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_199d683eb1a94619be17a7c8a39bd26e() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_1b27863856cc42f88656c47fb5f18ea5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1b27863856cc42f88656c47fb5f18ea5() - { - this.Initialize("CompareTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).CompareTo(((object)(pars[0]))); - } - } - - private sealed class MTHD_bc0ee29e56a3473bbd1a64c162de8455 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bc0ee29e56a3473bbd1a64c162de8455() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_6d56e805427240a689a8c8dac422fdbb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6d56e805427240a689a8c8dac422fdbb() - { - this.Initialize("DefaultMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).DefaultMethod(); - } - } - - private sealed class MTHD_3e04fe4e6732449497021e82df7bef61 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3e04fe4e6732449497021e82df7bef61() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - - private sealed class MTHD_e689e7fa94a94e20a091f19feab77ef9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e689e7fa94a94e20a091f19feab77ef9() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_90908c4e51794c33abcf6a592b2c73e7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_90908c4e51794c33abcf6a592b2c73e7() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_ea8c18bafafd4d568d2bbd8c350a5187 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_ea8c18bafafd4d568d2bbd8c350a5187() : - base(typeof(int), "Value", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Value; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)); - tmp.Value = ((int)(value)); - } - } - - private sealed class MTHD_ddf3c57eb4b24123b0f6af163b8dd2f3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ddf3c57eb4b24123b0f6af163b8dd2f3() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_c372de05919f4b11ba20cc097168115f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c372de05919f4b11ba20cc097168115f() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_28bfa36a4fba4141a483b7f5d1707f2f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_28bfa36a4fba4141a483b7f5d1707f2f() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_10918aa1b5e449188e6c5f32faa7ce90 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_10918aa1b5e449188e6c5f32faa7ce90() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_ed786cbe112144c19c9efaff8c7fbc04 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ed786cbe112144c19c9efaff8c7fbc04() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_ccc4f0eb26754a90aa2bc54a28a32e21 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ccc4f0eb26754a90aa2bc54a28a32e21() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_5fca4669bedb4ba2b8f4eac58c4c0e68 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5fca4669bedb4ba2b8f4eac58c4c0e68() - { - this.Initialize("DefaultMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).DefaultMethod(); - } - } - - private sealed class MTHD_9831944a762b44fd85cf62e48b2f4436 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9831944a762b44fd85cf62e48b2f4436() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - - private sealed class MTHD_4c5236fc944243e3b52c7f6968db7de3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4c5236fc944243e3b52c7f6968db7de3() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ClassWithCount - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ClassWithCount - private sealed class TYPE_6a6a78e9064a45ba8885f2df3a5b58f4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_6a6a78e9064a45ba8885f2df3a5b58f4() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_d215af6892fc4be291c49c9d8d733a05()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4db47e0edd2b491eb1d8a798b035524d()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8481b1519e7044eab911ecbd3e95549b()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_11e1a87f1f964e2bab57c1d5a064b436()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3f66b77d99784435a86399c94e65817f()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae76d04d10d84e408cf2a151e38e388e()})); - this.AddMember("Count", new PROP_f60ebf3baa724a779fb5641d57a5c485()); - } - - private sealed class VTDC_d215af6892fc4be291c49c9d8d733a05 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_d215af6892fc4be291c49c9d8d733a05() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount(); - } - } - - private sealed class MTHD_4db47e0edd2b491eb1d8a798b035524d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4db47e0edd2b491eb1d8a798b035524d() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount)(obj)).Count; - } - } - - private sealed class MTHD_8481b1519e7044eab911ecbd3e95549b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8481b1519e7044eab911ecbd3e95549b() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_11e1a87f1f964e2bab57c1d5a064b436 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_11e1a87f1f964e2bab57c1d5a064b436() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_3f66b77d99784435a86399c94e65817f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3f66b77d99784435a86399c94e65817f() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_ae76d04d10d84e408cf2a151e38e388e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae76d04d10d84e408cf2a151e38e388e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_f60ebf3baa724a779fb5641d57a5c485 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_f60ebf3baa724a779fb5641d57a5c485() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithCount)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ClassWithLength - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests+ClassWithLength - private sealed class TYPE_5111a7ecd6544644a489165b35869822 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_5111a7ecd6544644a489165b35869822() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_56dc581adb424237a8b68cd94e0b181c()})); - this.AddMember("get_Length", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Length", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_73f291072e91463a9c4bda03c2248947()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a10e7b78993a4a79ab81c414a4806d46()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1905d170c0d645609a2aa37b03ecadf1()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a129ab7ae0ab454c9eb39b80a7ac4e38()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_99d0560b84bc4e579bcff91ac6db1482()})); - this.AddMember("Length", new PROP_0628dfd39daf4e5ea6bcc0d84265a622()); - } - - private sealed class VTDC_56dc581adb424237a8b68cd94e0b181c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_56dc581adb424237a8b68cd94e0b181c() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength(); - } - } - - private sealed class MTHD_73f291072e91463a9c4bda03c2248947 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_73f291072e91463a9c4bda03c2248947() - { - this.Initialize("get_Length", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength)(obj)).Length; - } - } - - private sealed class MTHD_a10e7b78993a4a79ab81c414a4806d46 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a10e7b78993a4a79ab81c414a4806d46() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_1905d170c0d645609a2aa37b03ecadf1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1905d170c0d645609a2aa37b03ecadf1() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_a129ab7ae0ab454c9eb39b80a7ac4e38 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a129ab7ae0ab454c9eb39b80a7ac4e38() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_99d0560b84bc4e579bcff91ac6db1482 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_99d0560b84bc4e579bcff91ac6db1482() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_0628dfd39daf4e5ea6bcc0d84265a622 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_0628dfd39daf4e5ea6bcc0d84265a622() : - base(typeof(int), "Length", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataMetaTests.ClassWithLength)(obj)).Length; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests+IndexerTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests+IndexerTestClass - private sealed class TYPE_837265dc0f5143f38128bce0768e5a33 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_837265dc0f5143f38128bce0768e5a33() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_71699a3fe96f4c78a42cc29499658964()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_11ba849869dc449faedb55221f81b877(), - new MTHD_44b8a9a1c1bf466b8b48f74bf4f98b8f()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6ea4fbce8dc6462bb9a1281bf4cfe0cd(), - new MTHD_796311d665404f71abd5c253a871eee1()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5cd52fa6de81418f872b8baf75a02c50()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_59c8bab0584745329353e8c3b78abefb()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_898f47a968904ee6815025ba285e2390()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_57bab4df2c7543578c5536a02b302f0e()})); - this.AddMember("mymap", new FLDV_91b7839f27f64a53a318aade6d73d5d1()); - } - - private sealed class VTDC_71699a3fe96f4c78a42cc29499658964 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_71699a3fe96f4c78a42cc29499658964() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass(); - } - } - - private sealed class MTHD_11ba849869dc449faedb55221f81b877 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_11ba849869dc449faedb55221f81b877() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_44b8a9a1c1bf466b8b48f74bf4f98b8f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_44b8a9a1c1bf466b8b48f74bf4f98b8f() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj))[((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))]; - } - } - - private sealed class MTHD_6ea4fbce8dc6462bb9a1281bf4cfe0cd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6ea4fbce8dc6462bb9a1281bf4cfe0cd() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj)); - tmp[((int)(pars[0]))] = ((int)(pars[1])); - return null; - } - } - - private sealed class MTHD_796311d665404f71abd5c253a871eee1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_796311d665404f71abd5c253a871eee1() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx3", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj)); - tmp[((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))] = ((int)(pars[3])); - return null; - } - } - - private sealed class MTHD_5cd52fa6de81418f872b8baf75a02c50 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5cd52fa6de81418f872b8baf75a02c50() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_59c8bab0584745329353e8c3b78abefb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_59c8bab0584745329353e8c3b78abefb() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_898f47a968904ee6815025ba285e2390 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_898f47a968904ee6815025ba285e2390() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_57bab4df2c7543578c5536a02b302f0e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_57bab4df2c7543578c5536a02b302f0e() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_91b7839f27f64a53a318aade6d73d5d1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_91b7839f27f64a53a318aade6d73d5d1() : - base(typeof(System.Collections.Generic.Dictionary), "mymap", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj)).mymap; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataIndexerTests.IndexerTestClass)(obj)); - tmp.mymap = ((System.Collections.Generic.Dictionary)(value)); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests+SomeClass - private sealed class TYPE_111440b2f057418ea38cba2c19403629 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_111440b2f057418ea38cba2c19403629() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new VTDC_6c162940d5c34ca49005c71200cdc7c5()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_900e0585809340b9aed50b9a11884218()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5af4ae9c86a34fb2b2f99936ecf0bf0c()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0f6fe9cb373549a684b7cdce74032701()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d28003a28229484ab1e25a5345bbd1e2()})); - this.AddMember("IntProp", new FLDV_aa541bcacbec48ccb04f380dc7e054d6()); - this.AddMember("NIntProp", new FLDV_d9323f56f1034d318581c4fc876dd8f2()); - this.AddMember("ObjProp", new FLDV_2808848aa2824d428e7d2b099926731a()); - this.AddMember("StaticProp", new FLDV_0bca3b9569f94659942305374a63277e()); - this.AddMember("ConstIntProp", new FLDV_d76eaab9ff1b455f847590c5bd41c87d()); - } - - private sealed class VTDC_6c162940d5c34ca49005c71200cdc7c5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal VTDC_6c162940d5c34ca49005c71200cdc7c5() - { - this.Initialize("__new", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass(); - } - } - - private sealed class MTHD_900e0585809340b9aed50b9a11884218 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_900e0585809340b9aed50b9a11884218() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_5af4ae9c86a34fb2b2f99936ecf0bf0c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5af4ae9c86a34fb2b2f99936ecf0bf0c() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_0f6fe9cb373549a684b7cdce74032701 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0f6fe9cb373549a684b7cdce74032701() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.ValueType)(obj)).ToString(); - } - } - - private sealed class MTHD_d28003a28229484ab1e25a5345bbd1e2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d28003a28229484ab1e25a5345bbd1e2() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_aa541bcacbec48ccb04f380dc7e054d6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_aa541bcacbec48ccb04f380dc7e054d6() : - base(typeof(int), "IntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)).IntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)); - tmp.IntProp = ((int)(value)); - } - } - - private sealed class FLDV_d9323f56f1034d318581c4fc876dd8f2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_d9323f56f1034d318581c4fc876dd8f2() : - base(typeof(System.Nullable), "NIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)).NIntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(value)); - } - } - - private sealed class FLDV_2808848aa2824d428e7d2b099926731a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_2808848aa2824d428e7d2b099926731a() : - base(typeof(object), "ObjProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)).ObjProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(value)); - } - } - - private sealed class FLDV_0bca3b9569f94659942305374a63277e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_0bca3b9569f94659942305374a63277e() : - base(typeof(string), "StaticProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass.StaticProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass.StaticProp = ((string)(value)); - } - } - - private sealed class FLDV_d76eaab9ff1b455f847590c5bd41c87d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_d76eaab9ff1b455f847590c5bd41c87d() : - base(typeof(int), "ConstIntProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.VtUserDataFieldsTests.SomeClass.ConstIntProp; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ArithmOperatorsTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ArithmOperatorsTestClass - private sealed class TYPE_79f4cd059fcf483495a03356bb8cce46 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_79f4cd059fcf483495a03356bb8cce46() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_75b54c255cef4b8aa68ea3c3ad6c2a09(), - new MTHD_19f668fdabc04de380b129b5da346b3c()})); - this.AddMember("get_Value", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4bc2bf4011424ea7af7bb56fd00f8e22()})); - this.AddMember("set_Value", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Value", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_262570a31fb04ae6b5f7af33c5f0df83()})); - this.AddMember("op_UnaryNegation", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_UnaryNegation", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e8fb197177d04f51bd40eae22ad63c07()})); - this.AddMember("op_Addition", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Addition", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_baaef081d98a4d1baa729883578810f6(), - new MTHD_135e347b01ee49d0bcdde7302678d50f(), - new MTHD_8f3170eced71499d92cc97ba2e6f7a34()})); - this.AddMember("op_Subtraction", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Subtraction", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_38d54d0d0e1340d08fcc59aba899ef4d(), - new MTHD_3e4218b64bc04d8181ee33b955185a38(), - new MTHD_1d8d35b494b54f739b8aa075fd8b171f()})); - this.AddMember("op_Multiply", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Multiply", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bcbda79ca6f14a3b8137c62fa1b394bf(), - new MTHD_38024e4e144d4923b86cae2342be2630(), - new MTHD_5aaf495753234097a203c402be1c929a()})); - this.AddMember("op_Division", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Division", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_72ea0cc1d5bb4867967741ca327be188(), - new MTHD_0b2e49af836142d38c889ffac8f34f96(), - new MTHD_38f45f9a223b48fe9621d9b8646fb28e()})); - this.AddMember("op_Modulus", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("op_Modulus", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d23ff844763a4199a16462efcb5e94cb(), - new MTHD_2b63d86fccf34a1c8fca06765bda3e6b(), - new MTHD_aead413a1e8b4835afb3e170a5563637()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6c4a9ace3fd347ec838acfe5947ab30b()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6ac935a552bb427fa70461f8863221ab()})); - this.AddMember("CompareTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CompareTo", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_98bf7b99a04a4187b67107f58f2bcd22()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9be60569387a4b2b96237437e7ed6d5c()})); - this.AddMember("DefaultMethod", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("DefaultMethod", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_36178b920506446f9c3168edd0c4c109()})); - this.AddMember("Pairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Pairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e47addbaf6f04e2e8a0d7d43cf531cc6()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d5631cb1b2f248a7a7e0c71adfa2b17a()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2043a7cd7c3646c8923b93a898686c68()})); - this.AddMember("Value", new PROP_5b742543f65743afad07e68acb2eb679()); - this.AddMetaMember("__concat", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__concat", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_deba35c2c536431ab94d9bbcd2687ad8(), - new MTHD_d8f9284ce7294764b677a27bef3528a8(), - new MTHD_2ecc5b07cfc74450be447d90a61634ad()})); - this.AddMetaMember("__pow", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__pow", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_31bd798148f34154b70a72d039dfc6a7(), - new MTHD_c10fb20101464cd38543db0c15e90e00(), - new MTHD_56c68464fdd14d678d9ba3ca61b6e237()})); - this.AddMetaMember("__call", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__call", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_630bd38c352548a69798c8cc66eb22c8()})); - this.AddMetaMember("__pairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__pairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dad374e32fd54a74bb22de8e04afb5f1()})); - this.AddMetaMember("__ipairs", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__ipairs", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0d36a9b390ac4c14b334a2204a3693bb()})); - } - - private sealed class MTHD_75b54c255cef4b8aa68ea3c3ad6c2a09 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_75b54c255cef4b8aa68ea3c3ad6c2a09() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass(); - } - } - - private sealed class MTHD_19f668fdabc04de380b129b5da346b3c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_19f668fdabc04de380b129b5da346b3c() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass(((int)(pars[0]))); - } - } - - private sealed class MTHD_4bc2bf4011424ea7af7bb56fd00f8e22 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4bc2bf4011424ea7af7bb56fd00f8e22() - { - this.Initialize("get_Value", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Value; - } - } - - private sealed class MTHD_262570a31fb04ae6b5f7af33c5f0df83 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_262570a31fb04ae6b5f7af33c5f0df83() - { - this.Initialize("set_Value", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)); - tmp.Value = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_e8fb197177d04f51bd40eae22ad63c07 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e8fb197177d04f51bd40eae22ad63c07() - { - this.Initialize("op_UnaryNegation", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (-((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0]))); - } - } - - private sealed class MTHD_baaef081d98a4d1baa729883578810f6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_baaef081d98a4d1baa729883578810f6() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_135e347b01ee49d0bcdde7302678d50f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_135e347b01ee49d0bcdde7302678d50f() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_8f3170eced71499d92cc97ba2e6f7a34 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8f3170eced71499d92cc97ba2e6f7a34() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_38d54d0d0e1340d08fcc59aba899ef4d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_38d54d0d0e1340d08fcc59aba899ef4d() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) - ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_3e4218b64bc04d8181ee33b955185a38 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3e4218b64bc04d8181ee33b955185a38() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) - ((int)(pars[1]))); - } - } - - private sealed class MTHD_1d8d35b494b54f739b8aa075fd8b171f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1d8d35b494b54f739b8aa075fd8b171f() - { - this.Initialize("op_Subtraction", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) - ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_bcbda79ca6f14a3b8137c62fa1b394bf : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bcbda79ca6f14a3b8137c62fa1b394bf() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) * ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_38024e4e144d4923b86cae2342be2630 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_38024e4e144d4923b86cae2342be2630() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) * ((int)(pars[1]))); - } - } - - private sealed class MTHD_5aaf495753234097a203c402be1c929a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5aaf495753234097a203c402be1c929a() - { - this.Initialize("op_Multiply", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) * ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_72ea0cc1d5bb4867967741ca327be188 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_72ea0cc1d5bb4867967741ca327be188() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) / ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_0b2e49af836142d38c889ffac8f34f96 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0b2e49af836142d38c889ffac8f34f96() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) / ((int)(pars[1]))); - } - } - - private sealed class MTHD_38f45f9a223b48fe9621d9b8646fb28e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_38f45f9a223b48fe9621d9b8646fb28e() - { - this.Initialize("op_Division", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) / ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_d23ff844763a4199a16462efcb5e94cb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d23ff844763a4199a16462efcb5e94cb() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) % ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_2b63d86fccf34a1c8fca06765bda3e6b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2b63d86fccf34a1c8fca06765bda3e6b() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) % ((int)(pars[1]))); - } - } - - private sealed class MTHD_aead413a1e8b4835afb3e170a5563637 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_aead413a1e8b4835afb3e170a5563637() - { - this.Initialize("op_Modulus", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) % ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_6c4a9ace3fd347ec838acfe5947ab30b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6c4a9ace3fd347ec838acfe5947ab30b() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_6ac935a552bb427fa70461f8863221ab : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6ac935a552bb427fa70461f8863221ab() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_98bf7b99a04a4187b67107f58f2bcd22 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_98bf7b99a04a4187b67107f58f2bcd22() - { - this.Initialize("CompareTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).CompareTo(((object)(pars[0]))); - } - } - - private sealed class MTHD_9be60569387a4b2b96237437e7ed6d5c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9be60569387a4b2b96237437e7ed6d5c() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_36178b920506446f9c3168edd0c4c109 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_36178b920506446f9c3168edd0c4c109() - { - this.Initialize("DefaultMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).DefaultMethod(); - } - } - - private sealed class MTHD_e47addbaf6f04e2e8a0d7d43cf531cc6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e47addbaf6f04e2e8a0d7d43cf531cc6() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - - private sealed class MTHD_d5631cb1b2f248a7a7e0c71adfa2b17a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d5631cb1b2f248a7a7e0c71adfa2b17a() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_2043a7cd7c3646c8923b93a898686c68 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2043a7cd7c3646c8923b93a898686c68() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_5b742543f65743afad07e68acb2eb679 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_5b742543f65743afad07e68acb2eb679() : - base(typeof(int), "Value", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Value; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)); - tmp.Value = ((int)(value)); - } - } - - private sealed class MTHD_deba35c2c536431ab94d9bbcd2687ad8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_deba35c2c536431ab94d9bbcd2687ad8() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_d8f9284ce7294764b677a27bef3528a8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d8f9284ce7294764b677a27bef3528a8() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_2ecc5b07cfc74450be447d90a61634ad : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2ecc5b07cfc74450be447d90a61634ad() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_31bd798148f34154b70a72d039dfc6a7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_31bd798148f34154b70a72d039dfc6a7() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_c10fb20101464cd38543db0c15e90e00 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c10fb20101464cd38543db0c15e90e00() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[0])) + ((int)(pars[1]))); - } - } - - private sealed class MTHD_56c68464fdd14d678d9ba3ca61b6e237 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_56c68464fdd14d678d9ba3ca61b6e237() - { - this.Initialize("op_Addition", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("v", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("o", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return (((int)(pars[0])) + ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(pars[1]))); - } - } - - private sealed class MTHD_630bd38c352548a69798c8cc66eb22c8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_630bd38c352548a69798c8cc66eb22c8() - { - this.Initialize("DefaultMethod", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).DefaultMethod(); - } - } - - private sealed class MTHD_dad374e32fd54a74bb22de8e04afb5f1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dad374e32fd54a74bb22de8e04afb5f1() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - - private sealed class MTHD_0d36a9b390ac4c14b334a2204a3693bb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0d36a9b390ac4c14b334a2204a3693bb() - { - this.Initialize("Pairs", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ArithmOperatorsTestClass)(obj)).Pairs(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ClassWithCount - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ClassWithCount - private sealed class TYPE_acc8a8b40d184cdf88cb69e719d37cbb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_acc8a8b40d184cdf88cb69e719d37cbb() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_61de24d0b6cd4715b7d17d38e8c50a37()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e8dd913025f24eac9003509077f9c8cb()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d6472c961bf34ddbb7e85fb51f84133b()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_00d7d1aa3931462d94ae33fa64b5cdc3()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_76edf4bc0a9f41fbbfc554aaaeae3788()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_dbfa7c8898d84c03ab51d530a2b73453()})); - this.AddMember("Count", new PROP_d475b39c5f3c4f62b85f72a7751cd240()); - } - - private sealed class MTHD_61de24d0b6cd4715b7d17d38e8c50a37 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_61de24d0b6cd4715b7d17d38e8c50a37() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount(); - } - } - - private sealed class MTHD_e8dd913025f24eac9003509077f9c8cb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e8dd913025f24eac9003509077f9c8cb() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount)(obj)).Count; - } - } - - private sealed class MTHD_d6472c961bf34ddbb7e85fb51f84133b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d6472c961bf34ddbb7e85fb51f84133b() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_00d7d1aa3931462d94ae33fa64b5cdc3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_00d7d1aa3931462d94ae33fa64b5cdc3() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_76edf4bc0a9f41fbbfc554aaaeae3788 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_76edf4bc0a9f41fbbfc554aaaeae3788() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_dbfa7c8898d84c03ab51d530a2b73453 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_dbfa7c8898d84c03ab51d530a2b73453() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_d475b39c5f3c4f62b85f72a7751cd240 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_d475b39c5f3c4f62b85f72a7751cd240() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithCount)(obj)).Count; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ClassWithLength - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests+ClassWithLength - private sealed class TYPE_849992c03f5a412f92b34315fa1849e8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_849992c03f5a412f92b34315fa1849e8() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_68d52c55706644f99694ad0b94afdaee()})); - this.AddMember("get_Length", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Length", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5deec906e6184266892957d888ab4d32()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4dd64e32e9be4cd7a41d001df314ee01()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6f50f67a5e1d4a359598eb34bb79da77()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_cc47ac17708145228307fc2f3f07834a()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d7385fd19e0945deafc58ae3d13e7331()})); - this.AddMember("Length", new PROP_757de900e5a54f78880d9a34f13bfa2e()); - } - - private sealed class MTHD_68d52c55706644f99694ad0b94afdaee : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_68d52c55706644f99694ad0b94afdaee() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength(); - } - } - - private sealed class MTHD_5deec906e6184266892957d888ab4d32 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5deec906e6184266892957d888ab4d32() - { - this.Initialize("get_Length", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength)(obj)).Length; - } - } - - private sealed class MTHD_4dd64e32e9be4cd7a41d001df314ee01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4dd64e32e9be4cd7a41d001df314ee01() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_6f50f67a5e1d4a359598eb34bb79da77 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6f50f67a5e1d4a359598eb34bb79da77() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_cc47ac17708145228307fc2f3f07834a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_cc47ac17708145228307fc2f3f07834a() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_d7385fd19e0945deafc58ae3d13e7331 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d7385fd19e0945deafc58ae3d13e7331() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_757de900e5a54f78880d9a34f13bfa2e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_757de900e5a54f78880d9a34f13bfa2e() : - base(typeof(int), "Length", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMetaTests.ClassWithLength)(obj)).Length; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests+IndexerTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests+IndexerTestClass - private sealed class TYPE_9a705002c22f4c57aaea7b4dfd2de660 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_9a705002c22f4c57aaea7b4dfd2de660() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_2a1155bc0967415da4abda10fd60b91a()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c9e85ffbef8946eeb34b6d02d4373108(), - new MTHD_74af5762712b48d99cc89dccd486f70c()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6267adf12ac0485aa9e351fb7a93e1d8(), - new MTHD_26f79de30ee741a5a7dbc2b4c376c073()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_483792c92ce646ae8bbe77b078395fd6()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b40f24bf39a54897949680144fbf61ca()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7ab0cbb6964e4906907d42534c893325()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_eb7eb228c5464c39a8cf4bd68e7c9c6c()})); - } - - private sealed class MTHD_2a1155bc0967415da4abda10fd60b91a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2a1155bc0967415da4abda10fd60b91a() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass(); - } - } - - private sealed class MTHD_c9e85ffbef8946eeb34b6d02d4373108 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c9e85ffbef8946eeb34b6d02d4373108() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_74af5762712b48d99cc89dccd486f70c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_74af5762712b48d99cc89dccd486f70c() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx3", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass)(obj))[((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))]; - } - } - - private sealed class MTHD_6267adf12ac0485aa9e351fb7a93e1d8 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6267adf12ac0485aa9e351fb7a93e1d8() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass)(obj)); - tmp[((int)(pars[0]))] = ((int)(pars[1])); - return null; - } - } - - private sealed class MTHD_26f79de30ee741a5a7dbc2b4c376c073 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_26f79de30ee741a5a7dbc2b4c376c073() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx2", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("idx3", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataIndexerTests.IndexerTestClass)(obj)); - tmp[((int)(pars[0])), ((int)(pars[1])), ((int)(pars[2]))] = ((int)(pars[3])); - return null; - } - } - - private sealed class MTHD_483792c92ce646ae8bbe77b078395fd6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_483792c92ce646ae8bbe77b078395fd6() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_b40f24bf39a54897949680144fbf61ca : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b40f24bf39a54897949680144fbf61ca() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_7ab0cbb6964e4906907d42534c893325 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7ab0cbb6964e4906907d42534c893325() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_eb7eb228c5464c39a8cf4bd68e7c9c6c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_eb7eb228c5464c39a8cf4bd68e7c9c6c() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+SomeClass - private sealed class TYPE_2d2fe58092f042eaac7ff3c4874a6eaa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_2d2fe58092f042eaac7ff3c4874a6eaa() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a375b71c91724f82b016400361991f01()})); - this.AddMember("ManipulateString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ManipulateString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e313a73f5bfd405fa15d2566a66668d0()})); - this.AddMember("ConcatNums", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatNums", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c3bfb726d6d0475f8c9a63c2074b32ff()})); - this.AddMember("SomeMethodWithLongName", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SomeMethodWithLongName", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e4849debeaa0434185addf7619aef44c()})); - this.AddMember("SetComplexRecursive", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetComplexRecursive", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_f94d628253d94b63bc26165a54db20a5()})); - this.AddMember("SetComplexTypes", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("SetComplexTypes", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_bd04b93fb3db445d8066caa046e961b1()})); - this.AddMember("ConcatS", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatS", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a8f7c32173164196ba7cfd53d085c0cc()})); - this.AddMember("Format", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Format", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e5ac5c671b5d447dbe65c41a4bde1bcd()})); - this.AddMember("ConcatI", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ConcatI", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_61f5d3fb60384969b5322f5527edc159()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_06b507cbb4794489b3244f9d5558f8d3()})); - this.AddMember("MkList", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MkList", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8d98fca592894a0294ffcb14aa704b9a()})); - this.AddMember("CompareTo", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("CompareTo", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9f18eb06425c4a93a665993c30c0f680()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_11de847915524e24aca6769a2a25ae6f()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9a59676da0884d649847c2be64aeedc6()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_053482c57be44ed989f0313147971aa5()})); - } - - private sealed class MTHD_a375b71c91724f82b016400361991f01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a375b71c91724f82b016400361991f01() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass(); - } - } - - private sealed class MTHD_e313a73f5bfd405fa15d2566a66668d0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e313a73f5bfd405fa15d2566a66668d0() - { - this.Initialize("ManipulateString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("input", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("tobeconcat", typeof(string), false, null, false, true, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("lowercase", typeof(string), false, null, true, true, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - string refp_1; - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).ManipulateString(((string)(pars[0])), ref refp_0, out refp_1); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_1)}); - } - } - - private sealed class MTHD_c3bfb726d6d0475f8c9a63c2074b32ff : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c3bfb726d6d0475f8c9a63c2074b32ff() - { - this.Initialize("ConcatNums", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).ConcatNums(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_e4849debeaa0434185addf7619aef44c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e4849debeaa0434185addf7619aef44c() - { - this.Initialize("SomeMethodWithLongName", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("i", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).SomeMethodWithLongName(((int)(pars[0]))); - } - } - - private sealed class MTHD_f94d628253d94b63bc26165a54db20a5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_f94d628253d94b63bc26165a54db20a5() - { - this.Initialize("SetComplexRecursive", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intList", typeof(System.Collections.Generic.List), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass.SetComplexRecursive(((System.Collections.Generic.List)(pars[0]))); - } - } - - private sealed class MTHD_bd04b93fb3db445d8066caa046e961b1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_bd04b93fb3db445d8066caa046e961b1() - { - this.Initialize("SetComplexTypes", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("strlist", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intlist", typeof(System.Collections.Generic.IList), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("map", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("strarray", typeof(string[]), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("intarray", typeof(int[]), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass.SetComplexTypes(((System.Collections.Generic.List)(pars[0])), ((System.Collections.Generic.IList)(pars[1])), ((System.Collections.Generic.Dictionary)(pars[2])), ((string[])(pars[3])), ((int[])(pars[4]))); - } - } - - private sealed class MTHD_a8f7c32173164196ba7cfd53d085c0cc : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a8f7c32173164196ba7cfd53d085c0cc() - { - this.Initialize("ConcatS", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p3", typeof(System.IComparable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p4", typeof(bool), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p5", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p6", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p7", typeof(System.Text.StringBuilder), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p8", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p9", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p10", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 9)) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass.ConcatS(((int)(pars[0])), ((string)(pars[1])), ((System.IComparable)(pars[2])), ((bool)(pars[3])), ((System.Collections.Generic.List)(pars[4])), ((System.Collections.Generic.IEnumerable)(pars[5])), ((System.Text.StringBuilder)(pars[6])), ((System.Collections.Generic.Dictionary)(pars[7])), ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(pars[8]))); - } - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass.ConcatS(((int)(pars[0])), ((string)(pars[1])), ((System.IComparable)(pars[2])), ((bool)(pars[3])), ((System.Collections.Generic.List)(pars[4])), ((System.Collections.Generic.IEnumerable)(pars[5])), ((System.Text.StringBuilder)(pars[6])), ((System.Collections.Generic.Dictionary)(pars[7])), ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(pars[8])), ((int)(pars[9]))); - } - } - - private sealed class MTHD_e5ac5c671b5d447dbe65c41a4bde1bcd : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e5ac5c671b5d447dbe65c41a4bde1bcd() - { - this.Initialize("Format", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("s", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("args", typeof(object[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).Format(((string)(pars[0])), ((object[])(pars[1]))); - } - } - - private sealed class MTHD_61f5d3fb60384969b5322f5527edc159 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_61f5d3fb60384969b5322f5527edc159() - { - this.Initialize("ConcatI", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("s", typeof(MoonSharp.Interpreter.Script), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p1", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p2", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p3", typeof(System.IComparable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p4", typeof(bool), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p5", typeof(System.Collections.Generic.List), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p6", typeof(System.Collections.Generic.IEnumerable), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p7", typeof(System.Text.StringBuilder), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p8", typeof(System.Collections.Generic.Dictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p9", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("p10", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 10)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).ConcatI(((MoonSharp.Interpreter.Script)(pars[0])), ((int)(pars[1])), ((string)(pars[2])), ((System.IComparable)(pars[3])), ((bool)(pars[4])), ((System.Collections.Generic.List)(pars[5])), ((System.Collections.Generic.IEnumerable)(pars[6])), ((System.Text.StringBuilder)(pars[7])), ((System.Collections.Generic.Dictionary)(pars[8])), ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(pars[9]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).ConcatI(((MoonSharp.Interpreter.Script)(pars[0])), ((int)(pars[1])), ((string)(pars[2])), ((System.IComparable)(pars[3])), ((bool)(pars[4])), ((System.Collections.Generic.List)(pars[5])), ((System.Collections.Generic.IEnumerable)(pars[6])), ((System.Text.StringBuilder)(pars[7])), ((System.Collections.Generic.Dictionary)(pars[8])), ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(pars[9])), ((int)(pars[10]))); - } - } - - private sealed class MTHD_06b507cbb4794489b3244f9d5558f8d3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_06b507cbb4794489b3244f9d5558f8d3() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).ToString(); - } - } - - private sealed class MTHD_8d98fca592894a0294ffcb14aa704b9a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8d98fca592894a0294ffcb14aa704b9a() - { - this.Initialize("MkList", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("from", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("to", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).MkList(((int)(pars[0])), ((int)(pars[1]))); - } - } - - private sealed class MTHD_9f18eb06425c4a93a665993c30c0f680 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9f18eb06425c4a93a665993c30c0f680() - { - this.Initialize("CompareTo", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeClass)(obj)).CompareTo(((object)(pars[0]))); - } - } - - private sealed class MTHD_11de847915524e24aca6769a2a25ae6f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_11de847915524e24aca6769a2a25ae6f() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_9a59676da0884d649847c2be64aeedc6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9a59676da0884d649847c2be64aeedc6() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_053482c57be44ed989f0313147971aa5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_053482c57be44ed989f0313147971aa5() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+SomeOtherClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+SomeOtherClass - private sealed class TYPE_357faad2de2b4026a781cdc01ee447d3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_357faad2de2b4026a781cdc01ee447d3() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9ecd1caff7554a22909b87f0745004c2()})); - this.AddMember("Test1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6226974cc9de4bf788fe7a3e42308630()})); - this.AddMember("Test2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c54c7c74174241b291ea029512525c5b()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e50a3bd6b9d8441586899d92620028eb()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_941dcae803c94909ad008138a8edb0bb()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_523d8d903bff4f93bca215519c4a12d5()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_79acce3cb6c04b268ea521d4114f1a75()})); - } - - private sealed class MTHD_9ecd1caff7554a22909b87f0745004c2 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9ecd1caff7554a22909b87f0745004c2() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass(); - } - } - - private sealed class MTHD_6226974cc9de4bf788fe7a3e42308630 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6226974cc9de4bf788fe7a3e42308630() - { - this.Initialize("Test1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass)(obj)).Test1(); - } - } - - private sealed class MTHD_c54c7c74174241b291ea029512525c5b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c54c7c74174241b291ea029512525c5b() - { - this.Initialize("Test2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.SomeOtherClass)(obj)).Test2(); - } - } - - private sealed class MTHD_e50a3bd6b9d8441586899d92620028eb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e50a3bd6b9d8441586899d92620028eb() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_941dcae803c94909ad008138a8edb0bb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_941dcae803c94909ad008138a8edb0bb() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_523d8d903bff4f93bca215519c4a12d5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_523d8d903bff4f93bca215519c4a12d5() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_79acce3cb6c04b268ea521d4114f1a75 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_79acce3cb6c04b268ea521d4114f1a75() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+Interface1 - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+Interface1 - private sealed class TYPE_cfa246c16d8e45c28af66bfe941f2759 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_cfa246c16d8e45c28af66bfe941f2759() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface1)) - { - this.AddMember("Test1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface1), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8373e6ed6bcd48659741c50249b3a94b()})); - } - - private sealed class MTHD_8373e6ed6bcd48659741c50249b3a94b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8373e6ed6bcd48659741c50249b3a94b() - { - this.Initialize("Test1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface1)(obj)).Test1(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+Interface2 - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests+Interface2 - private sealed class TYPE_fb4a26496fb54e9c9a36dfcdbc2bd9a1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_fb4a26496fb54e9c9a36dfcdbc2bd9a1() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface2)) - { - this.AddMember("Test2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Test2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface2), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ad8769e193f241f9bce2f43ddf7ae376()})); - } - - private sealed class MTHD_ad8769e193f241f9bce2f43ddf7ae376 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ad8769e193f241f9bce2f43ddf7ae376() - { - this.Initialize("Test2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataMethodsTests.Interface2)(obj)).Test2(); - } - } - } - #endregion - - #region Descriptor of System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - // Descriptor of System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - private sealed class TYPE_9302398a948a4cc883b9dff9976a4e80 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_9302398a948a4cc883b9dff9976a4e80() : - base(typeof(System.Collections.Generic.Dictionary)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b9d7ed39153d41bab258122efa47c8e1(), - new MTHD_388664dbee844e03b04b980258b6882a(), - new MTHD_530f155a273b4e638416c7b0b436be32(), - new MTHD_2fdff9ffb9164b51893ad083f90c41e7(), - new MTHD_3dcc0d0e2bfd464a8a18864740350a72(), - new MTHD_7547af9f280847b28e5e193ca1ff5b1b()})); - this.AddMember("get_Comparer", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Comparer", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3da4f3ce5c1243d7962fd4ba0265916e()})); - this.AddMember("get_Count", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Count", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8ba33ca4a7874f8981cf599202dd1968()})); - this.AddMember("get_Keys", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Keys", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1fa0561827eb469ebbd31cf5f5d6f3ec()})); - this.AddMember("get_Values", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Values", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_720cd57204074d8fb3e9b35ab7cea0fa()})); - this.AddMember("get_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Item", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_a0d7a2fa44c2428ba7b28f7bba46067a()})); - this.AddMember("set_Item", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_Item", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e5d01cd65b754d788a28e7455c65732f()})); - this.AddMember("Add", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Add", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b80dde7e9af54234956e6c68ad0db719()})); - this.AddMember("Clear", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Clear", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_6144c93d06674dc99c5d232c687c9a5b()})); - this.AddMember("ContainsKey", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ContainsKey", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_872b3ae4b54643419c980a77b3d65057()})); - this.AddMember("ContainsValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ContainsValue", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0f2f906a174d419092da9a3f3e0b4678()})); - this.AddMember("GetEnumerator", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetEnumerator", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e05040409d164c2993983cecde961f01()})); - this.AddMember("GetObjectData", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetObjectData", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1c7a4470e8bf4eb09a2dd2c531787e57()})); - this.AddMember("OnDeserialization", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("OnDeserialization", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_0f0524b56f474f5085760eedefcc5e58()})); - this.AddMember("Remove", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Remove", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_446f57e78543491d94ef6c0eae416781()})); - this.AddMember("TryGetValue", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("TryGetValue", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4baa0334edf747aeaea457ebefd90a88()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_9f744ddac8ad493b9ac967dce8bc841e()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_04389970393e427b8364f4efeffa1fa5()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e095873733d74b12b72ba492a982e426()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(System.Collections.Generic.Dictionary), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d8dceb0577294c869e2ce6e08b2ccac6()})); - this.AddMember("Comparer", new PROP_e0c3e99dd1574817ae1d53f97d0b41c1()); - this.AddMember("Count", new PROP_9f409cb37a07474e86f8327e6a306930()); - this.AddMember("Keys", new PROP_cd65cbb6e7c24b8394cff4758143c32f()); - this.AddMember("Values", new PROP_5d823cc5399d4962917a2dd6a622ae48()); - } - - private sealed class MTHD_b9d7ed39153d41bab258122efa47c8e1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b9d7ed39153d41bab258122efa47c8e1() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(); - } - } - - private sealed class MTHD_388664dbee844e03b04b980258b6882a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_388664dbee844e03b04b980258b6882a() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dictionary", typeof(System.Collections.Generic.IDictionary), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(((System.Collections.Generic.IDictionary)(pars[0]))); - } - } - - private sealed class MTHD_530f155a273b4e638416c7b0b436be32 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_530f155a273b4e638416c7b0b436be32() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("dictionary", typeof(System.Collections.Generic.IDictionary), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IEqualityComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(((System.Collections.Generic.IDictionary)(pars[0])), ((System.Collections.Generic.IEqualityComparer)(pars[1]))); - } - } - - private sealed class MTHD_2fdff9ffb9164b51893ad083f90c41e7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_2fdff9ffb9164b51893ad083f90c41e7() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IEqualityComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(((System.Collections.Generic.IEqualityComparer)(pars[0]))); - } - } - - private sealed class MTHD_3dcc0d0e2bfd464a8a18864740350a72 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3dcc0d0e2bfd464a8a18864740350a72() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(((int)(pars[0]))); - } - } - - private sealed class MTHD_7547af9f280847b28e5e193ca1ff5b1b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7547af9f280847b28e5e193ca1ff5b1b() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("capacity", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("comparer", typeof(System.Collections.Generic.IEqualityComparer), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new System.Collections.Generic.Dictionary(((int)(pars[0])), ((System.Collections.Generic.IEqualityComparer)(pars[1]))); - } - } - - private sealed class MTHD_3da4f3ce5c1243d7962fd4ba0265916e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3da4f3ce5c1243d7962fd4ba0265916e() - { - this.Initialize("get_Comparer", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).Comparer; - } - } - - private sealed class MTHD_8ba33ca4a7874f8981cf599202dd1968 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ba33ca4a7874f8981cf599202dd1968() - { - this.Initialize("get_Count", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).Count; - } - } - - private sealed class MTHD_1fa0561827eb469ebbd31cf5f5d6f3ec : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1fa0561827eb469ebbd31cf5f5d6f3ec() - { - this.Initialize("get_Keys", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).Keys; - } - } - - private sealed class MTHD_720cd57204074d8fb3e9b35ab7cea0fa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_720cd57204074d8fb3e9b35ab7cea0fa() - { - this.Initialize("get_Values", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).Values; - } - } - - private sealed class MTHD_a0d7a2fa44c2428ba7b28f7bba46067a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a0d7a2fa44c2428ba7b28f7bba46067a() - { - this.Initialize("get_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj))[((int)(pars[0]))]; - } - } - - private sealed class MTHD_e5d01cd65b754d788a28e7455c65732f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e5d01cd65b754d788a28e7455c65732f() - { - this.Initialize("set_Item", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - System.Collections.Generic.Dictionary tmp = ((System.Collections.Generic.Dictionary)(obj)); - tmp[((int)(pars[0]))] = ((int)(pars[1])); - return null; - } - } - - private sealed class MTHD_b80dde7e9af54234956e6c68ad0db719 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b80dde7e9af54234956e6c68ad0db719() - { - this.Initialize("Add", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.Dictionary)(obj)).Add(((int)(pars[0])), ((int)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_6144c93d06674dc99c5d232c687c9a5b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_6144c93d06674dc99c5d232c687c9a5b() - { - this.Initialize("Clear", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.Dictionary)(obj)).Clear(); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_872b3ae4b54643419c980a77b3d65057 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_872b3ae4b54643419c980a77b3d65057() - { - this.Initialize("ContainsKey", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).ContainsKey(((int)(pars[0]))); - } - } - - private sealed class MTHD_0f2f906a174d419092da9a3f3e0b4678 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0f2f906a174d419092da9a3f3e0b4678() - { - this.Initialize("ContainsValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).ContainsValue(((int)(pars[0]))); - } - } - - private sealed class MTHD_e05040409d164c2993983cecde961f01 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e05040409d164c2993983cecde961f01() - { - this.Initialize("GetEnumerator", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).GetEnumerator(); - } - } - - private sealed class MTHD_1c7a4470e8bf4eb09a2dd2c531787e57 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1c7a4470e8bf4eb09a2dd2c531787e57() - { - this.Initialize("GetObjectData", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("info", typeof(System.Runtime.Serialization.SerializationInfo), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("context", typeof(System.Runtime.Serialization.StreamingContext), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.Dictionary)(obj)).GetObjectData(((System.Runtime.Serialization.SerializationInfo)(pars[0])), ((System.Runtime.Serialization.StreamingContext)(pars[1]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_0f0524b56f474f5085760eedefcc5e58 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_0f0524b56f474f5085760eedefcc5e58() - { - this.Initialize("OnDeserialization", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("sender", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - ((System.Collections.Generic.Dictionary)(obj)).OnDeserialization(((object)(pars[0]))); - return MoonSharp.Interpreter.DynValue.Void; - } - } - - private sealed class MTHD_446f57e78543491d94ef6c0eae416781 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_446f57e78543491d94ef6c0eae416781() - { - this.Initialize("Remove", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((System.Collections.Generic.Dictionary)(obj)).Remove(((int)(pars[0]))); - } - } - - private sealed class MTHD_4baa0334edf747aeaea457ebefd90a88 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4baa0334edf747aeaea457ebefd90a88() - { - this.Initialize("TryGetValue", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("key", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, true, true, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - int refp_0; - object retv = ((System.Collections.Generic.Dictionary)(obj)).TryGetValue(((int)(pars[0])), out refp_0); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0)}); - } - } - - private sealed class MTHD_9f744ddac8ad493b9ac967dce8bc841e : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9f744ddac8ad493b9ac967dce8bc841e() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_04389970393e427b8364f4efeffa1fa5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_04389970393e427b8364f4efeffa1fa5() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_e095873733d74b12b72ba492a982e426 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e095873733d74b12b72ba492a982e426() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_d8dceb0577294c869e2ce6e08b2ccac6 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d8dceb0577294c869e2ce6e08b2ccac6() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_e0c3e99dd1574817ae1d53f97d0b41c1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_e0c3e99dd1574817ae1d53f97d0b41c1() : - base(typeof(System.Collections.Generic.IEqualityComparer), "Comparer", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.Dictionary)(obj)).Comparer; - } - } - - private sealed class PROP_9f409cb37a07474e86f8327e6a306930 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_9f409cb37a07474e86f8327e6a306930() : - base(typeof(int), "Count", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.Dictionary)(obj)).Count; - } - } - - private sealed class PROP_cd65cbb6e7c24b8394cff4758143c32f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_cd65cbb6e7c24b8394cff4758143c32f() : - base(typeof(System.Collections.Generic.Dictionary.KeyCollection), "Keys", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.Dictionary)(obj)).Keys; - } - } - - private sealed class PROP_5d823cc5399d4962917a2dd6a622ae48 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_5d823cc5399d4962917a2dd6a622ae48() : - base(typeof(System.Collections.Generic.Dictionary.ValueCollection), "Values", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((System.Collections.Generic.Dictionary)(obj)).Values; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests+OverloadsTestClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests+OverloadsTestClass - private sealed class TYPE_3f7a152fa8b348c996f851343aa9b2ad : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_3f7a152fa8b348c996f851343aa9b2ad() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ac6ba5029c964ba58a543f1c9d5cfd1b()})); - this.AddMember("MethodV", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MethodV", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_69fbc77ce40d43f29fbd23314f443f61(), - new MTHD_05bce8702b584e179dfd27b618c3eea0()})); - this.AddMember("Method1", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method1", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e38c066f887e41bd8c37011b97b7c636(), - new MTHD_729f09a74b06413d82ddce92b3a778a7(), - new MTHD_a54be43a66ef4510815cebb21555f33f(), - new MTHD_e629fe7006e64694a126044eb503778d(), - new MTHD_86201adb66b649f38022d98575fd5867(), - new MTHD_c408a16ebaee49749447cdec4bc5c2aa()})); - this.AddMember("Method2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_445ca6d9ea634658b3b19bad5c53d77b(), - new MTHD_9b43309401d24bd6ad4b134048f62c86(), - new MTHD_46669675cf7f46b698bb6ed11df62b71()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_4261eb4d6c98421f8d158d8abec17a86()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_88002768945849fdaac95f8e06adf404()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_fa85602314b042b4b19c6ee6311e6db4()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7010416eee9c4e19874844f2e4da80a1()})); - this.AddMember("Method3", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Method3", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - this.AddMember("MethodXXX", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("MethodXXX", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[0])); - } - - private sealed class MTHD_ac6ba5029c964ba58a543f1c9d5cfd1b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ac6ba5029c964ba58a543f1c9d5cfd1b() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass(); - } - } - - private sealed class MTHD_69fbc77ce40d43f29fbd23314f443f61 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_69fbc77ce40d43f29fbd23314f443f61() - { - this.Initialize("MethodV", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("fmt", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("a", typeof(int), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("b", typeof(bool), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).MethodV(((string)(pars[0])), ((int)(pars[1])), ((bool)(pars[2]))); - } - } - - private sealed class MTHD_05bce8702b584e179dfd27b618c3eea0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_05bce8702b584e179dfd27b618c3eea0() - { - this.Initialize("MethodV", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("fmt", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("args", typeof(object[]), false, null, false, false, true)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).MethodV(((string)(pars[0])), ((object[])(pars[1]))); - } - } - - private sealed class MTHD_e38c066f887e41bd8c37011b97b7c636 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e38c066f887e41bd8c37011b97b7c636() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(); - } - } - - private sealed class MTHD_729f09a74b06413d82ddce92b3a778a7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_729f09a74b06413d82ddce92b3a778a7() - { - this.Initialize("Method1", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("b", typeof(bool), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass.Method1(((bool)(pars[0]))); - } - } - - private sealed class MTHD_a54be43a66ef4510815cebb21555f33f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_a54be43a66ef4510815cebb21555f33f() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0]))); - } - } - - private sealed class MTHD_e629fe7006e64694a126044eb503778d : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e629fe7006e64694a126044eb503778d() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 1)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1]))); - } - } - - private sealed class MTHD_86201adb66b649f38022d98575fd5867 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_86201adb66b649f38022d98575fd5867() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("d", typeof(double), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(int), true, new MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.DefaultValue(), false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - if ((argscount <= 2)) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1]))); - } - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((double)(pars[0])), ((string)(pars[1])), ((int)(pars[2]))); - } - } - - private sealed class MTHD_c408a16ebaee49749447cdec4bc5c2aa : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c408a16ebaee49749447cdec4bc5c2aa() - { - this.Initialize("Method1", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("a", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method1(((int)(pars[0]))); - } - } - - private sealed class MTHD_445ca6d9ea634658b3b19bad5c53d77b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_445ca6d9ea634658b3b19bad5c53d77b() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ((string)(pars[1]))); - } - } - - private sealed class MTHD_9b43309401d24bd6ad4b134048f62c86 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_9b43309401d24bd6ad4b134048f62c86() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, true, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ref refp_0); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0)}); - } - } - - private sealed class MTHD_46669675cf7f46b698bb6ed11df62b71 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_46669675cf7f46b698bb6ed11df62b71() - { - this.Initialize("Method2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("x", typeof(string), false, null, false, false, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("y", typeof(string), false, null, false, true, false), - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("z", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - string refp_0 = ((string)(pars[1])); - object retv = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataOverloadsTests.OverloadsTestClass)(obj)).Method2(((string)(pars[0])), ref refp_0, ((int)(pars[2]))); - return MoonSharp.Interpreter.DynValue.NewTuple(new MoonSharp.Interpreter.DynValue[] { - MoonSharp.Interpreter.DynValue.FromObject(script, retv), - MoonSharp.Interpreter.DynValue.FromObject(script, refp_0)}); - } - } - - private sealed class MTHD_4261eb4d6c98421f8d158d8abec17a86 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_4261eb4d6c98421f8d158d8abec17a86() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_88002768945849fdaac95f8e06adf404 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_88002768945849fdaac95f8e06adf404() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_fa85602314b042b4b19c6ee6311e6db4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_fa85602314b042b4b19c6ee6311e6db4() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_7010416eee9c4e19874844f2e4da80a1 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7010416eee9c4e19874844f2e4da80a1() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests+SomeClass - private sealed class TYPE_a7e62b0e3ff84281b50f51f8d5504a63 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_a7e62b0e3ff84281b50f51f8d5504a63() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8ef06498c90d463f932800a7b571fad0()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e5c8850543e74adba919397fc55e5d43()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_863ae759ddf547dd99dddc7d2ff952b9()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_c711543334f34c7b9be896c85d418c31()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_642684f29aa5466ea4c09632b7f7e166()})); - this.AddMember("IntProp", new FLDV_867ce86f8745494b92cf98b9474534f7()); - this.AddMember("RoIntProp", new FLDV_8747b0f86145436e8502b625980a61f5()); - this.AddMember("NIntProp", new FLDV_a8fdf57392e14247aa2dc3627bc2e8f5()); - this.AddMember("ObjProp", new FLDV_2acfdeb87bd44df6bf0b2e7e3b751b10()); - this.AddMember("StaticProp", new FLDV_f9a3571998704baa8aa6107181680a46()); - this.AddMember("ConstIntProp", new FLDV_1a5e48fdcfbf4ed7a7f1292b1df75782()); - } - - private sealed class MTHD_8ef06498c90d463f932800a7b571fad0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8ef06498c90d463f932800a7b571fad0() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass(); - } - } - - private sealed class MTHD_e5c8850543e74adba919397fc55e5d43 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e5c8850543e74adba919397fc55e5d43() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_863ae759ddf547dd99dddc7d2ff952b9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_863ae759ddf547dd99dddc7d2ff952b9() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_c711543334f34c7b9be896c85d418c31 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_c711543334f34c7b9be896c85d418c31() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_642684f29aa5466ea4c09632b7f7e166 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_642684f29aa5466ea4c09632b7f7e166() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class FLDV_867ce86f8745494b92cf98b9474534f7 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_867ce86f8745494b92cf98b9474534f7() : - base(typeof(int), "IntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)).IntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)); - tmp.IntProp = ((int)(value)); - } - } - - private sealed class FLDV_8747b0f86145436e8502b625980a61f5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_8747b0f86145436e8502b625980a61f5() : - base(typeof(int), "RoIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)).RoIntProp; - } - } - - private sealed class FLDV_a8fdf57392e14247aa2dc3627bc2e8f5 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_a8fdf57392e14247aa2dc3627bc2e8f5() : - base(typeof(System.Nullable), "NIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)).NIntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(value)); - } - } - - private sealed class FLDV_2acfdeb87bd44df6bf0b2e7e3b751b10 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_2acfdeb87bd44df6bf0b2e7e3b751b10() : - base(typeof(object), "ObjProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)).ObjProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(value)); - } - } - - private sealed class FLDV_f9a3571998704baa8aa6107181680a46 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_f9a3571998704baa8aa6107181680a46() : - base(typeof(string), "StaticProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass.StaticProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass.StaticProp = ((string)(value)); - } - } - - private sealed class FLDV_1a5e48fdcfbf4ed7a7f1292b1df75782 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal FLDV_1a5e48fdcfbf4ed7a7f1292b1df75782() : - base(typeof(int), "ConstIntProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataFieldsTests.SomeClass.ConstIntProp; - } - } - } - #endregion - - #region Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests+SomeClass - // Descriptor of MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests+SomeClass - private sealed class TYPE_0fd7f1a4f76344ef81e0c9e5081fa739 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor - { - - internal TYPE_0fd7f1a4f76344ef81e0c9e5081fa739() : - base(typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)) - { - this.AddMember("__new", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("__new", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_51c5a27a5375469bafdf71a56669a713()})); - this.AddMember("get_IntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_IntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_7cf7890d51504bf89b230736aa37b6d3()})); - this.AddMember("set_IntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_IntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_1e3e3c4d464547ecab778ab3a58a92db()})); - this.AddMember("get_NIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_NIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_57ee34f738fe46fe91c0655b2eea7d4b()})); - this.AddMember("set_NIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_NIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_b39f4e2a9ae546c3b50c18f43b85320b()})); - this.AddMember("get_ObjProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_ObjProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_59908a65ff1e45b1a12f1d3b5a825d10()})); - this.AddMember("set_ObjProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_ObjProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_ae095249b0c442789d6e10a161de0dfb()})); - this.AddMember("get_StaticProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_StaticProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_98b29eb03a194dbca65204d8eb5e70c0()})); - this.AddMember("set_StaticProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_StaticProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_e168f00965fd4c77823a1ba317bc1b6c()})); - this.AddMember("get_RoIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_RoIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_68cc128c77784f6a8351382cdf07799a()})); - this.AddMember("get_RoIntProp2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_RoIntProp2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_8d1b545c9cbe453aa07ba962a25fb23b()})); - this.AddMember("set_WoIntProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_WoIntProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_5d2cba86024f4dbd9da95c79723d340a()})); - this.AddMember("set_WoIntProp2", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_WoIntProp2", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_3809820d025f4659bc3476818271c80a()})); - this.AddMember("set_AccessOverrProp", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("set_AccessOverrProp", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_d611da34928643498ddbc4a06d753c3c()})); - this.AddMember("get_Numbers", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("get_Numbers", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_521b030a2087439f84177b9c4e388700()})); - this.AddMember("ToString", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("ToString", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_03cefe80c9ec4db59f2998fad7b90753()})); - this.AddMember("Equals", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("Equals", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_97fae438b998485ebc098e09f799ae80()})); - this.AddMember("GetHashCode", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetHashCode", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_21022919d5a74af792b268aab53b6303()})); - this.AddMember("GetType", new MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor("GetType", typeof(MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass), new MoonSharp.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor[] { - new MTHD_00d005e3a47e447eaa898c5cfa1dedc4()})); - this.AddMember("IntProp", new PROP_6d7ed51604e546658c0439883849467b()); - this.AddMember("NIntProp", new PROP_b2c5e931837f42fa91345086ceb56fed()); - this.AddMember("ObjProp", new PROP_12abf377e0c14df9be2e689bf96e37f9()); - this.AddMember("StaticProp", new PROP_3cace3367b3f4ceba403b8bcdca4ac39()); - this.AddMember("RoIntProp", new PROP_540b3cbff80f486c90eaca9f8e7a1aad()); - this.AddMember("RoIntProp2", new PROP_473858963eda4a048d36f1343444111f()); - this.AddMember("WoIntProp", new PROP_a02918606da44a97822127b60d7a7517()); - this.AddMember("WoIntProp2", new PROP_26769f71d0824ba4be5146dc388e91db()); - this.AddMember("AccessOverrProp", new PROP_9031aef3746143ec88b3ba0d7a087975()); - this.AddMember("Numbers", new PROP_df3c3019e6de4ac98e686d4e2907b961()); - } - - private sealed class MTHD_51c5a27a5375469bafdf71a56669a713 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_51c5a27a5375469bafdf71a56669a713() - { - this.Initialize(".ctor", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return new MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass(); - } - } - - private sealed class MTHD_7cf7890d51504bf89b230736aa37b6d3 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_7cf7890d51504bf89b230736aa37b6d3() - { - this.Initialize("get_IntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).IntProp; - } - } - - private sealed class MTHD_1e3e3c4d464547ecab778ab3a58a92db : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_1e3e3c4d464547ecab778ab3a58a92db() - { - this.Initialize("set_IntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.IntProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_57ee34f738fe46fe91c0655b2eea7d4b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_57ee34f738fe46fe91c0655b2eea7d4b() - { - this.Initialize("get_NIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).NIntProp; - } - } - - private sealed class MTHD_b39f4e2a9ae546c3b50c18f43b85320b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_b39f4e2a9ae546c3b50c18f43b85320b() - { - this.Initialize("set_NIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(System.Nullable), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(pars[0])); - return null; - } - } - - private sealed class MTHD_59908a65ff1e45b1a12f1d3b5a825d10 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_59908a65ff1e45b1a12f1d3b5a825d10() - { - this.Initialize("get_ObjProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).ObjProp; - } - } - - private sealed class MTHD_ae095249b0c442789d6e10a161de0dfb : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_ae095249b0c442789d6e10a161de0dfb() - { - this.Initialize("set_ObjProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(pars[0])); - return null; - } - } - - private sealed class MTHD_98b29eb03a194dbca65204d8eb5e70c0 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_98b29eb03a194dbca65204d8eb5e70c0() - { - this.Initialize("get_StaticProp", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.StaticProp; - } - } - - private sealed class MTHD_e168f00965fd4c77823a1ba317bc1b6c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_e168f00965fd4c77823a1ba317bc1b6c() - { - this.Initialize("set_StaticProp", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(string), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.StaticProp = ((string)(pars[0])); - return null; - } - } - - private sealed class MTHD_68cc128c77784f6a8351382cdf07799a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_68cc128c77784f6a8351382cdf07799a() - { - this.Initialize("get_RoIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).RoIntProp; - } - } - - private sealed class MTHD_8d1b545c9cbe453aa07ba962a25fb23b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_8d1b545c9cbe453aa07ba962a25fb23b() - { - this.Initialize("get_RoIntProp2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).RoIntProp2; - } - } - - private sealed class MTHD_5d2cba86024f4dbd9da95c79723d340a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_5d2cba86024f4dbd9da95c79723d340a() - { - this.Initialize("set_WoIntProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_3809820d025f4659bc3476818271c80a : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_3809820d025f4659bc3476818271c80a() - { - this.Initialize("set_WoIntProp2", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp2 = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_d611da34928643498ddbc4a06d753c3c : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_d611da34928643498ddbc4a06d753c3c() - { - this.Initialize("set_AccessOverrProp", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("value", typeof(int), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.AccessOverrProp = ((int)(pars[0])); - return null; - } - } - - private sealed class MTHD_521b030a2087439f84177b9c4e388700 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_521b030a2087439f84177b9c4e388700() - { - this.Initialize("get_Numbers", true, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.Numbers; - } - } - - private sealed class MTHD_03cefe80c9ec4db59f2998fad7b90753 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_03cefe80c9ec4db59f2998fad7b90753() - { - this.Initialize("ToString", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).ToString(); - } - } - - private sealed class MTHD_97fae438b998485ebc098e09f799ae80 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_97fae438b998485ebc098e09f799ae80() - { - this.Initialize("Equals", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[] { - new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor("obj", typeof(object), false, null, false, false, false)}, false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).Equals(((object)(pars[0]))); - } - } - - private sealed class MTHD_21022919d5a74af792b268aab53b6303 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_21022919d5a74af792b268aab53b6303() - { - this.Initialize("GetHashCode", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetHashCode(); - } - } - - private sealed class MTHD_00d005e3a47e447eaa898c5cfa1dedc4 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor - { - - internal MTHD_00d005e3a47e447eaa898c5cfa1dedc4() - { - this.Initialize("GetType", false, new MoonSharp.Interpreter.Interop.BasicDescriptors.ParameterDescriptor[0], false); - } - - protected override object Invoke(MoonSharp.Interpreter.Script script, object obj, object[] pars, int argscount) - { - return ((object)(obj)).GetType(); - } - } - - private sealed class PROP_6d7ed51604e546658c0439883849467b : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_6d7ed51604e546658c0439883849467b() : - base(typeof(int), "IntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).IntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.IntProp = ((int)(value)); - } - } - - private sealed class PROP_b2c5e931837f42fa91345086ceb56fed : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_b2c5e931837f42fa91345086ceb56fed() : - base(typeof(System.Nullable), "NIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).NIntProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.NIntProp = ((System.Nullable)(value)); - } - } - - private sealed class PROP_12abf377e0c14df9be2e689bf96e37f9 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_12abf377e0c14df9be2e689bf96e37f9() : - base(typeof(object), "ObjProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).ObjProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.ObjProp = ((object)(value)); - } - } - - private sealed class PROP_3cace3367b3f4ceba403b8bcdca4ac39 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_3cace3367b3f4ceba403b8bcdca4ac39() : - base(typeof(string), "StaticProp", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(3))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.StaticProp; - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.StaticProp = ((string)(value)); - } - } - - private sealed class PROP_540b3cbff80f486c90eaca9f8e7a1aad : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_540b3cbff80f486c90eaca9f8e7a1aad() : - base(typeof(int), "RoIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).RoIntProp; - } - } - - private sealed class PROP_473858963eda4a048d36f1343444111f : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_473858963eda4a048d36f1343444111f() : - base(typeof(int), "RoIntProp2", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)).RoIntProp2; - } - } - - private sealed class PROP_a02918606da44a97822127b60d7a7517 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_a02918606da44a97822127b60d7a7517() : - base(typeof(int), "WoIntProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp = ((int)(value)); - } - } - - private sealed class PROP_26769f71d0824ba4be5146dc388e91db : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_26769f71d0824ba4be5146dc388e91db() : - base(typeof(int), "WoIntProp2", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.WoIntProp2 = ((int)(value)); - } - } - - private sealed class PROP_9031aef3746143ec88b3ba0d7a087975 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_9031aef3746143ec88b3ba0d7a087975() : - base(typeof(int), "AccessOverrProp", false, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(2))) - { - } - - protected override void SetValueImpl(MoonSharp.Interpreter.Script script, object obj, object value) - { - MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass tmp = ((MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass)(obj)); - tmp.AccessOverrProp = ((int)(value)); - } - } - - private sealed class PROP_df3c3019e6de4ac98e686d4e2907b961 : MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor - { - - internal PROP_df3c3019e6de4ac98e686d4e2907b961() : - base(typeof(System.Collections.Generic.IEnumerable), "Numbers", true, ((MoonSharp.Interpreter.Interop.BasicDescriptors.MemberDescriptorAccess)(1))) - { - } - - protected override object GetValueImpl(MoonSharp.Interpreter.Script script, object obj) - { - return MoonSharp.Interpreter.Tests.EndToEnd.UserDataPropertiesTests.SomeClass.Numbers; - } - } - } - #endregion - } -} - - -#endif diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/MoonSharp.Interpreter.Tests.Embeddable.portable40.csproj b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/MoonSharp.Interpreter.Tests.Embeddable.portable40.csproj deleted file mode 100644 index 3af4c244..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/MoonSharp.Interpreter.Tests.Embeddable.portable40.csproj +++ /dev/null @@ -1,257 +0,0 @@ - - - - - 10.0 - Debug - AnyCPU - {28B8B747-5683-46C0-B308-62E6D3C2F4CB} - Library - Properties - MoonSharp.Interpreter.Tests - MoonSharp.Interpreter.Tests - en-US - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile328 - v4.0 - true - ..\..\..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG;PCL,EMBEDTEST - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;PCL,EMBEDTEST - prompt - 4 - - - true - bin\Dev\ - TRACE;DEBUG;PCL,EMBEDTEST - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG;PCL,EMBEDTEST - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - {49f32476-fca0-45fd-8f89-0c7c0d15e409} - MoonSharp.Interpreter.portable40 - - - - - EmbeddableNUnitWrapper.cs - - - BinaryDumpTests.cs - - - ClosureTests.cs - - - CollectionsBaseInterfGenRegisteredTests.cs - - - CollectionsBaseGenRegisteredTests.cs - - - CollectionsRegisteredTests.cs - - - ConfigPropertyAssignerTests.cs - - - CoroutineTests.cs - - - DynamicTests.cs - - - ErrorHandlingTests.cs - - - GotoTests.cs - - - JsonSerializationTests.cs - - - LuaTestSuiteExtract.cs - - - Code - MetatableTests.cs - - - ProxyObjectsTests.cs - - - StringLibTests.cs - - - StructAssignmentTechnique.cs - - - TailCallTests.cs - - - UserDataEventsTests.cs - - - UserDataEnumsTest.cs - - - UserDataNestedTypesTests.cs - - - VarargsTupleTests.cs - - - VtUserDataPropertiesTests.cs - - - VtUserDataOverloadsTests.cs - - - VtUserDataMethodsTests.cs - - - VtUserDataMetaTests.cs - - - VtUserDataIndexerTests.cs - - - VtUserDataFieldsTests.cs - - - UserDataMetaTests.cs - - - UserDataIndexerTests.cs - - - UserDataMethodsTests.cs - - - UserDataOverloadsTests.cs - - - UserDataFieldsTests.cs - - - Code - UserDataPropertiesTests.cs - - - Utils.cs - - - AssemblyInfo.cs - - - SimpleTests.cs - - - TableTests.cs - - - TapRunner.cs - - - TestMoreTests.cs - - - TestRunner.cs - - - BinDumpStreamTests.cs - - - FastStackTests.cs - - - InteropTests.cs - - - _Hardwired.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Always - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/Properties/AssemblyInfo.cs deleted file mode 100644 index 4e14249e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Resources; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter.Tests.Embeddable.portable40")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.Tests.Embeddable.portable40")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("en")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/000-sanity.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/000-sanity.t deleted file mode 100644 index e2de2368..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/000-sanity.t +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua test suite - -=head2 Synopsis - - % prove 000-sanity.t - -=head2 Description - -=cut - -]] - -function f (n) - return n + 1 -end - -function g (m, p) - return m + p -end - -print('1..9') -print("ok 1 -") -print('ok', 2, "- list") -print("ok " .. 3 .. " - concatenation") -i = 4 -print("ok " .. i .. " - var") -i = i + 1 -print("ok " .. i .. " - var incr") -print("ok " .. i+1 .. " - expr") -j = f(i + 1) -print("ok " .. j .. " - call f") -k = g(i, 3) -print("ok " .. k .. " - call g") -local print = print -print("ok 9 - local") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/001-if.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/001-if.t deleted file mode 100644 index b32c4bd7..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/001-if.t +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua if statement - -=head2 Synopsis - - % prove 001-if.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..6") - -if true then - print("ok 1") -else - print("not ok 1") -end - -if not true then - print("not ok 2") -else - print("ok 2") -end - -a = 12 -b = 34 -if a < b then - print("ok 3") -else - print("not ok 3") -end - -a = 0 -b = 4 -if a < b then - print("ok 4") -elseif a == b then - print("not ok 4") -else - print("not ok 4") -end - -a = 5 -b = 5 -if a < b then - print("not ok 5") -elseif a == b then - print("ok 5") -else - print("not ok 5") -end - -a = 10 -b = 6 -if a < b then - print("not ok 6") -elseif a == b then - print("not ok 6") -else - print("ok 6") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/002-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/002-table.t deleted file mode 100644 index acf3bb28..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/002-table.t +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table - -=head2 Synopsis - - % prove 002-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - -]] - -print("1..8") - -a = {"ok 1", "ok 2", "ok 3"} -print(a[1]) -i = 2 -print(a[i]) -print(a[i+1]) -if #a == 3 then - print("ok 4 - len") -else - print("not ok 4") -end -if a[7] == nil then - print("ok 5") -else - print("not ok 5") -end - -t = {a=10, b=100} -if t['a'] == 10 then - print("ok 6") -else - print("not ok 6") -end -if t.b == 100 then - print("ok 7") -else - print("not ok 7") -end -if t.z == nil then - print("ok 8") -else - print("not ok 8") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/011-while.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/011-while.t deleted file mode 100644 index 0c5791d9..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/011-while.t +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua while statement - -=head2 Synopsis - - % prove 011-while.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..11") - -a = {} -local i = 1 -while a[i] do - i = i + 1 -end -if i == 1 then - print("ok 1 - while empty") -else - print("not ok 1 - " .. i) -end - -a = {"ok 2 - while ", "ok 3", "ok 4"} -local i = 1 -while a[i] do - print(a[i]) - i = i + 1 -end - -a = {"ok 5 - with break", "ok 6", "stop", "more"} -local i = 1 -while a[i] do - if a[i] == 'stop' then break end - print(a[i]) - i = i + 1 -end -if i == 3 then - print("ok 7 - break") -else - print("not ok 7 - " .. i) -end - -x = 3 -local i = 1 -while i<=x do - print("ok " .. 7+i) - i = i + 1 -end -if i == 4 then - print("ok 11") -else - print("not ok 11 - " .. i) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/012-repeat.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/012-repeat.t deleted file mode 100644 index 54893b1c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/012-repeat.t +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua repeat statement - -=head2 Synopsis - - % prove 012-repeat.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..8") - -a = {"ok 1 - repeat", "ok 2", "ok 3"} -local i = 0 -repeat - i = i + 1 - if a[i] then - print(a[i]) - end -until not a[i] -if i == 4 then - print("ok 4") -else - print("not ok 4 - " .. i) -end - -a = {"ok 5 - with break", "ok 6", 'stop', 'more'} -local i = 0 -repeat - i = i + 1 - if a[i] == 'stop' then break end - print(a[i]) -until not a[i] -if a[i] == 'stop' then - print("ok 7 - break") -else - print("not ok 7 - " .. a[i]) -end - -function f () return true end - -local i = 1 -repeat - local v = f() - if i == 1 then - print("ok 8 - scope") - else - print("not ok") - break - end - i = i + 1 -until v - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/014-fornum.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/014-fornum.t deleted file mode 100644 index 1cf3e61b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/014-fornum.t +++ /dev/null @@ -1,136 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 014-fornum.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..36") - -for i = 1, 10, 2 do - print("ok " .. (i+1)/2 .. " - for 1, 10, 2") -end - -for i = 1, 10, 2 do - function f () - print("ok " .. (i+11)/2 .. " - for 1, 10, 2 lex") - end - f() -end - -function f (i) - print("ok " .. (i+21)/2 .. " - for 1, 10, 2 !lex") -end -for i = 1, 10, 2 do - f(i) -end - -for i = 3, 5 do - print("ok " .. 13+i .. " - for 3, 5") - i = i + 1 -end - -for i = 5, 1, -1 do - print("ok " .. 24-i .. " - for 5, 1, -1") -end - -for i = 5, 5 do - print("ok " .. 19+i .. " - for 5, 5") -end - -for i = 5, 5, -1 do - print("ok " .. 20+i .. " - for 5, 5, -1") -end - -v = false -for i = 5, 3 do - v = true -end -if v then - print("not ok 26 - for 5, 3") -else - print("ok 26 - for 5, 3") -end - -v = false -for i = 5, 7, -1 do - v = true -end -if v then - print("not ok 27 - for 5, 7, -1") -else - print("ok 27 - for 5, 7, -1") -end - -v = false -for i = 5, 7, 0 do - v = true - break -- avoid infinite loop with luajit -end -if jit then - print("not ok 28 - for 5, 7, 0 # TODO # LuaJIT intentional.") -elseif v then - print("not ok 28 - for 5, 7, 0") -else - print("ok 28 - for 5, 7, 0") -end - -v = nil -for i = 1, 10, 2 do - if i > 4 then break end - print("ok " .. (i+57)/2 .. " - for break") - v = i -end -if v == 3 then - print("ok 31 - break") -else - print("not ok 31 - " .. v) -end - -local function first() return 1 end -local function limit() return 8 end -local function step() return 2 end -for i = first(), limit(), step() do - print("ok " .. (i+63)/2 .. " - with functions") -end - -local a = {} -for i = 1, 10 do - a[i] = function () return i end -end -local v = a[5]() -if v == 5 then - print("ok 36 - for & upval") -else - print("not ok 36 - for & upval") - print("#", v) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/015-forlist.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/015-forlist.t deleted file mode 100644 index 11aaf992..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/015-forlist.t +++ /dev/null @@ -1,99 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 015-forlist.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..18") - -a = {"ok 1 - for ipairs", "ok 2 - for ipairs", "ok 3 - for ipairs"} -for _, v in ipairs(a) do - print(v) -end -for i, v in ipairs(a) do - print("ok " .. 3+i .. " - for ipairs") -end - -r = false -t = {a=10, b=100} -for i, v in ipairs(t) do - print(i, v) - r = true -end -if r then - print("not ok 7 - for ipairs (hash)") -else - print("ok 7 - for ipairs (hash)") -end - -for k in pairs(a) do - print("ok " .. 7+k .. " - for pairs") -end - -local i = 1 -for k in pairs(t) do - if k == 'a' or k == 'b' then - print("ok " .. 10+i .. " - for pairs (hash)") - else - print("not ok " .. 10+i .. " - " .. k) - end - i = i + 1 -end - -a = {"ok 13 - for break", "ok 14 - for break", "stop", "more"} -local i -for _, v in ipairs(a) do - if v == "stop" then break end - print(v) - i = _ -end -if i == 2 then - print("ok 15 - break") -else - print("not ok 15 - " .. i) -end - -local a = {"ok 16 - for & upval", "ok 17 - for & upval", "ok 18 - for & upval"} -local b = {} -for i, v in ipairs(a) do - b[i] = function () return v end -end -for i, v in ipairs(a) do - local r = b[i]() - if r == a[i] then - print(r) - else - print("not " .. a[i]) - print("#", r) - end -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/101-boolean.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/101-boolean.t deleted file mode 100644 index 403f4766..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/101-boolean.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua boolean & coercion - -=head2 Synopsis - - % prove 101-boolean.t - -=head2 Description - -=cut - -]] - -require 'Test.More' - -plan(24) - -error_like(function () return -true end, - "^[^:]+:%d+: attempt to perform arithmetic on a %w+ value", - "-true") - -error_like(function () return #true end, - "^[^:]+:%d+: attempt to get length of a boolean value", - "#true") - -is(not false, true, "not false") - -error_like(function () return true + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true + 10") - -error_like(function () return true - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true - 2") - -error_like(function () return true * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true * 3.14") - -error_like(function () return true / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true / -7") - -error_like(function () return true % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true % 4") - -error_like(function () return true ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true ^ 3") - -error_like(function () return true .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "true .. 'end'") - -is(true == true, true, "true == true") - -is(true ~= false, true, "true ~= false") - -is(true == 1, false, "true == 1") - -is(true ~= 1, true, "true ~= 1") - -error_like(function () return true < false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true < false") - -error_like(function () return true <= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true <= false") - -error_like(function () return true > false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true > false") - -error_like(function () return true >= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true >= false") - -error_like(function () return true < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true < 0") - -error_like(function () return true <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true <= 0") - -error_like(function () return true > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true > 0") - -error_like(function () return true >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true >= 0") - -error_like(function () a = true; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = true; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/102-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/102-function.t deleted file mode 100644 index 46ab7108..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/102-function.t +++ /dev/null @@ -1,199 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua function & coercion - -=head2 Synopsis - - % prove 102-function.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -f = function () return 1 end - -error_like(function () return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-f") - -error_like(function () f = print; return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return #f end, - "^[^:]+:%d+: attempt to get length of", - "#f") - -error_like(function () f = print; return #f end, - "^[^:]+:%d+: attempt to get length of") - -is(not f, false, "not f") - -is(not print, false) - -error_like(function () return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f + 10") - -error_like(function () f = print; return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f - 2") - -error_like(function () f = print; return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f * 3.14") - -error_like(function () f = print; return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f / -7") - -error_like(function () f = print; return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f % 4") - -error_like(function () f = print; return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f ^ 3") - -error_like(function () f = print; return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "f .. 'end'") - -error_like(function () f = print; return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate") - -g = f -is(f == g, true, "f == f") - -g = print -is(g == print, true) - -g = function () return 2 end -is(f ~= g, true, "f ~= g") -h = type -is(f ~= h, true) - -is(print ~= g, true) -is(print ~= h, true) - -is(f == 1, false, "f == 1") - -is(print == 1, false) - -is(f ~= 1, true, "f ~= 1") - -is(print ~= 1, true) - -error_like(function () return f < g end, - "^[^:]+:%d+: attempt to compare two function values", - "f < g") - -error_like(function () f = print; g = type; return f < g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f <= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f <= g") - -error_like(function () f = print; g = type; return f <= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f > g end, - "^[^:]+:%d+: attempt to compare two function values", - "f > g") - -error_like(function () f = print; g = type; return f > g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f >= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f >= g") - -error_like(function () f = print; g = type; return f >= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f < 0") - -error_like(function () f = print; return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f <= 0") - -error_like(function () f = print; return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f > 0") - -error_like(function () f = print; return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f >= 0") - -error_like(function () f = print; return f >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () a = f; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; b = a[1]; end, - "^[^:]+:%d+: attempt to index") - -error_like(function () a = f; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; a[1] = 1; end, - "^[^:]+:%d+: attempt to index") - -t = {} -t[print] = true -ok(t[print]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/103-nil.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/103-nil.t deleted file mode 100644 index 904970c6..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/103-nil.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua nil & coercion - -=head2 Synopsis - - % prove 103-nil.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(24) - -error_like(function () return -nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "-nil") - -error_like(function () return #nil end, - "^[^:]+:%d+: attempt to get length of a nil value", - "#nil") - -is(not nil, true, "not nil") - -error_like(function () return nil + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil + 10") - -error_like(function () return nil - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil - 2") - -error_like(function () return nil * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil * 3.14") - -error_like(function () return nil / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil / -7") - -error_like(function () return nil % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil % 4") - -error_like(function () return nil ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil ^ 3") - -error_like(function () return nil .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a nil value", - "nil .. 'end'") - -is(nil == nil, true, "nil == nil") - -is(nil ~= nil, false, "nil ~= nil") - -is(nil == 1, false, "nil == 1") - -is(nil ~= 1, true, "nil ~= 1") - -error_like(function () return nil < nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil < nil") - -error_like(function () return nil <= nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil <= nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil > nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil >= nil") - -error_like(function () return nil < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil < 0") - -error_like(function () return nil <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil <= 0") - -error_like(function () return nil > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil > 0") - -error_like(function () return nil >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil >= 0") - -error_like(function () a = nil; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = nil; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/104-number.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/104-number.t deleted file mode 100644 index 32ea3c3e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/104-number.t +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua number & coercion - -=head2 Synopsis - - % prove 104-number.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(54) - -is(-1, -(1), "-1") - -error_like(function () return #1 end, - "^[^:]+:%d+: attempt to get length of a number value", - "#1") - -is(not 1, false, "not 1") - -is(10 + 2, 12, "10 + 2") - -is(2 - 10, -8, "2 - 10") - -is(3.14 * 1, 3.14, "3.14 * 1") - -is(-7 / 0.5, -14, "-7 / 0.5") - -type_ok(1 / 0, 'number', "1 / 0") - -is(-25 % 3, 2, "-25 % 3") - -type_ok(1 % 0, 'number', "1 % 0") - -error_like(function () return 10 + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "10 + true") - -error_like(function () return 2 - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "2 - nil") - -error_like(function () return 3.14 * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3.14 * false") - -error_like(function () return -7 / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "-7 / {}") - -error_like(function () return 3 ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3 ^ true") - -error_like(function () return -25 % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "-25 % false") - -error_like(function () return 10 + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "10 + 'text'") - -error_like(function () return 2 - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "2 - 'text'") - -error_like(function () return 3.14 * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3.14 * 'text'") - -error_like(function () return -7 / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "-7 / 'text'") - -error_like(function () return 25 % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "25 % 'text'") - -error_like(function () return 3 ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3 ^ 'text'") - -is(10 + '2', 12, "10 + '2'") - -is(2 - '10', -8, "2 - '10'") - -is(3.14 * '1', 3.14, "3.14 * '1'") - -is(-7 / '0.5', -14, "-7 / '0.5'") - -is(-25 % '3', 2, "-25 % '3'") - -is(3 ^ '3', 27, "3 ^ '3'") - -is(1 .. 'end', '1end', "1 .. 'end'") - -is(1 .. 2, '12', "1 .. 2") - -error_like(function () return 1 .. true end, - "^[^:]+:%d+: attempt to concatenate a %w+ value", - "1 .. true") - -is(1.0 == 1, true, "1.0 == 1") - -is(1 ~= 2, true, "1 ~= 2") - -is(1 == true, false, "1 == true") - -is(1 ~= nil, true, "1 ~= nil") - -is(1 == '1', false, "1 == '1'") - -is(1 ~= '1', true, "1 ~= '1'") - -is(1 < 0, false, "1 < 0") - -is(1 <= 0, false, "1 <= 0") - -is(1 > 0, true, "1 > 0") - -is(1 >= 0, true, "1 >= 0") - -error_like(function () return 1 < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < false") - -error_like(function () return 1 <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= nil") - -error_like(function () return 1 > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > true") - -error_like(function () return 1 >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= {}") - -error_like(function () return 1 < '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < '0'") - -error_like(function () return 1 <= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= '0'") - -error_like(function () return 1 > '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > '0'") - -error_like(function () return 1 >= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= '0'") - -is(tostring(1000000000), '1000000000', "number 1000000000") - -is(tostring(1e9), '1000000000', "number 1e9") - -is(tostring(1.0e+9), '1000000000', "number 1.0e+9") - -error_like(function () a= 3.14; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = 3.14; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/105-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/105-string.t deleted file mode 100644 index 3162bb74..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/105-string.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua string & coercion - -=head2 Synopsis - - % prove 105-string.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -is(- '1', -1, "-'1'") - -error_like(function () return - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on .- string value", - "-'text'") - -is(# 'text', 4, "#'text'") - -is(not 'text', false, "not 'text'") - -is('10' + 2, 12, "'10' + 2") - -is('2' - 10, -8, "'2' - 10") - -is('3.14' * 1, 3.14, "'3.14' * 1") - -is('-7' / 0.5, -14, "'-7' / 0.5") - -is('-25' % 3, 2, "'-25' % 3") - -is('3' ^ 3, 27, "'3' ^ 3") - -error_like(function () return '10' + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'10' + true") - -error_like(function () return '2' - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "'2' - nil") - -error_like(function () return '3.14' * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3.14' * false") - -error_like(function () return '-7' / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "'-7' / {}") - -error_like(function () return '-25' % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'-25' % false") - -error_like(function () return '3' ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3' ^ true") - -error_like(function () return '10' + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'10' + 'text'") - -error_like(function () return '2' - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'2' - 'text'") - -error_like(function () return '3.14' * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3.14' * 'text'") - -error_like(function () return '-7' / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-7' / 'text'") - -error_like(function () return '-25' % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-25' % 'text'") - -error_like(function () return '3' ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3' ^ 'text'") - -is('10' + '2', 12, "'10' + '2'") - -is('2' - '10', -8, "'2' - '10'") - -is('3.14' * '1', 3.14, "'3.14' * '1'") - -is('-7' / '0.5', -14, "'-7' / '0.5'") - -is('-25' % '3', 2, "'-25' % '3'") - -is('3' ^ '3', 27, "'3' ^ '3'") - -is('1' .. 'end', '1end', "'1' .. 'end'") - -is('1' .. 2, '12', "'1' .. 2") - -error_like(function () return '1' .. true end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "'1' .. true") - -is('1.0' == '1', false, "'1.0' == '1'") - -is('1' ~= '2', true, "'1' ~= '2'") - -is('1' == true, false, "'1' == true") - -is('1' ~= nil, true, "'1' ~= nil") - -is('1' == 1, false, "'1' == 1") - -is('1' ~= 1, true, "'1' ~= 1") - -is('1' < '0', false, "'1' < '0'") - -is('1' <= '0', false, "'1' <= '0'") - -is('1' > '0', true, "'1' > '0'") - -is('1' >= '0', true, "'1' >= '0'") - -error_like(function () return '1' < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < false") - -error_like(function () return '1' <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= nil") - -error_like(function () return '1' > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > true") - -error_like(function () return '1' >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >= {}") - -error_like(function () return '1' < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < 0") - -error_like(function () return '1' <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >== 0") - -a = 'text' -is(a[1], nil, "index") - -error_like(function () a = 'text'; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/106-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/106-table.t deleted file mode 100644 index 20725fb5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/106-table.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table & coercion - -=head2 Synopsis - - % prove 106-table.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(28) - -error_like(function () return -{} end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-{}") - -is(# {}, 0, "#{}") -is(# {4,5,6}, 3) - -is(not {}, false, "not {}") - -error_like(function () return {} + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} + 10") - -error_like(function () return {} - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} - 2") - -error_like(function () return {} * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} * 3.14") - -error_like(function () return {} / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} / 7") - -error_like(function () return {} % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} % 4") - -error_like(function () return {} ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} ^ 3") - -error_like(function () return {} .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "{} .. 'end'") - -is({} == {}, false, "{} == {}") - -t1 = {} -t2 = {} -is(t1 == t1, true, "t1 == t1") -is(t1 == t2, false, "t1 == t2") -is(t1 ~= t2, true, "t1 ~= t2") - -is({} == 1, false, "{} == 1") - -is({} ~= 1, true, "{} ~= 1") - -error_like(function () return t1 < t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 < t2") - -error_like(function () return t1 <= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 <= t2") - -error_like(function () return t1 > t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 > t2") - -error_like(function () return t1 >= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 >= t2") - -error_like(function () return {} < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} < 0") - -error_like(function () return {} <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} <= 0") - -error_like(function () return {} > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} > 0") - -error_like(function () return {} >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} >= 0") - -t = {} -is( t[1], nil, "index" ) -t[1] = 42 -is( t[1], 42, "index" ) - -error_like(function () t = {}; t[nil] = 42 end, - "^[^:]+:%d+: table index is nil", - "table index is nil") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/107-thread.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/107-thread.t deleted file mode 100644 index fffedec0..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/107-thread.t +++ /dev/null @@ -1,128 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua thread & coercion - -=head2 Synopsis - - % prove 107-thread.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -co = coroutine.create(function () return 1 end) - -error_like(function () return -co end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-co") - -error_like(function () return #co end, - "^[^:]+:%d+: attempt to get length of", - "#co") - -is(not co, false, "not co") - -error_like(function () return co + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co + 10") - -error_like(function () return co - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co - 2") - -error_like(function () return co * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co * 3.14") - -error_like(function () return co / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co / 7") - -error_like(function () return co % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co % 4") - -error_like(function () return co ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co ^ 3") - -error_like(function () return co .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "co .. 'end'") - -is(co == co, true, "co == co") - -co1 = coroutine.create(function () return 1 end) -co2 = coroutine.create(function () return 2 end) -is(co1 ~= co2, true, "co1 ~= co2") - -is(co == 1, false, "co == 1") - -is(co ~= 1, true, "co ~= 1") - -error_like(function () return co1 < co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 < co2") - -error_like(function () return co1 <= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 <= co2") - -error_like(function () return co1 > co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 > co2") - -error_like(function () return co1 >= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 >= co2") - -error_like(function () return co < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co < 0") - -error_like(function () return co <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co <= 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co > 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co >= 0") - -error_like(function () a = co[1] end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () co[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[co] = true -ok(t[co]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/108-userdata.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/108-userdata.t deleted file mode 100644 index c27ced46..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/108-userdata.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua userdata & coercion - -=head2 Synopsis - - % prove 108-userdata.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -u = io.stdin - -error_like(function () return -u end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-u") - -error_like(function () return #u end, - "^[^:]+:%d+: attempt to get length of", - "#u") - -is(not u, false, "not u") - -error_like(function () return u + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u + 10") - -error_like(function () return u - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u - 2") - -error_like(function () return u * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u * 3.14") - -error_like(function () return u / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u / 7") - -error_like(function () return u % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u % 4") - -error_like(function () return u ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u ^ 3") - -error_like(function () return u .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "u .. 'end'") - -is(u == u, true, "u == u") - -v = io.stdout -is(u ~= v, true, "u ~= v") - -is(u == 1, false, "u == 1") - -is(u ~= 1, true, "u ~= 1") - -error_like(function () return u < v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u < v") - -error_like(function () return u <= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u <= v") - -error_like(function () return u > v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u > v") - -error_like(function () return u >= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u >= v") - -error_like(function () return u < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u < 0") - -error_like(function () return u <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u <= 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u > 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u >= 0") - -is(u[1], nil, "index") - -error_like(function () u[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[u] = true -ok(t[u]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/200-examples.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/200-examples.t deleted file mode 100644 index 200dc4b5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/200-examples.t +++ /dev/null @@ -1,104 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 some Lua code examples - -=head2 Synopsis - - % prove 200-examples.t - -=head2 Description - -First tests in order to check infrastructure. - -=cut - ---]] - -require 'Test.More' - -plan(5) - -function factorial (n) - if n == 0 then - return 1 - else - return n * factorial(n-1) - end -end -is(factorial(7), 5040, "factorial (recursive)") - -local function local_factorial (n) - if n == 0 then - return 1 - else - return n * local_factorial(n-1) - end -end -is(local_factorial(7), 5040, "factorial (recursive)") - -function loop_factorial (n) - local a = 1 - for i = 1, n, 1 do - a = a*i - end - return a -end -is(loop_factorial(7), 5040, "factorial (loop)") - -function iter_factorial (n) - local function iter (product, counter) - if counter > n then - return product - else - return iter(counter*product, counter+1) - end - end - return iter(1, 1) -end -is(iter_factorial(7), 5040, "factorial (iter)") - ---[[ - - Knuth's "man or boy" test. - See http://en.wikipedia.org/wiki/Man_or_boy_test - -]] - -local function A (k, x1, x2, x3, x4, x5) - local function B () - k = k - 1 - return A(k, B, x1, x2, x3, x4) - end - if k <= 0 then - return x4() + x5() - else - return B() - end -end - -is(A(10, - function () return 1 end, - function () return -1 end, - function () return -1 end, - function () return 1 end, - function () return 0 end), - -67, - "man or boy" -) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/201-assign.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/201-assign.t deleted file mode 100644 index c245815a..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/201-assign.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua assignment - -=head2 Synopsis - - % prove 201-assign.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.3 "Assignment", -L. - -See "Programming in Lua", section 4.1 "Assignment". - -=cut - ---]] - -require 'Test.More' - -plan(38) - -is(b, nil, "global variable") -b = 10 -is(b, 10) -if jit then - skip("LuaJIT intentional. _ENV.", 3) -else - is(_ENV.b, 10, "_ENV") - is(_G, _ENV, "_G") - error_like([[ _ENV = nil; b = 20 ]], - "^[^:]+:%d+: attempt to index a nil value") -end -b = nil -is(b, nil) - -a = {} -i = 3 -i, a[i] = i+1, 20 --- this behavior is undefined --- see http://lua-users.org/lists/lua-l/2006-06/msg00378.html --- is(i, 4, "check eval") --- is(a[3], 20) - -x = 1. -y = 2. -x, y = y, x -- swap -is(x, 2, "check swap") -is(y, 1) - -a, b, c = 0, 1 -is(a, 0, "check padding") -is(b, 1) -is(c, nil) -a, b = a+1, b+1, a+b -is(a, 1) -is(b, 2) -a, b, c = 0 -is(a, 0) -is(b, nil) -is(c, nil) - -function f() return 1, 2 end -a, b, c, d = f() -is(a, 1, "adjust with function") -is(b, 2) -is(c, nil) -is(d, nil) - -function f() print('# f') end -a = 2 -a, b, c = f(), 3 -is(a, nil, "padding with function") -is(b, 3) -is(c, nil) - -local my_i = 1 -is(my_i, 1, "local variable") -local my_i = 2 -is(my_i, 2) - -local i = 1 -local j = i -is(i, 1, "local variable") -is(j, 1) -j = 2 -is(i, 1) -is(j, 2) - -local function f(x) return 2*x end -is(f(2), 4, "param & result of function") -a = 2 -a = f(a) -is(a, 4) -local b = 2 -b = f(b) -is(b, 4) - -local n1 = 1 -local n2 = 2 -local n3 = 3 -local n4 = 4 -n1,n2,n3,n4 = n4,n3,n2,n1 -is(n1, 4, "assignment list swap values") -is(n2, 3) -is(n3, 2) -is(n4, 1) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/202-expr.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/202-expr.t deleted file mode 100644 index 3d03f115..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/202-expr.t +++ /dev/null @@ -1,111 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua expression - -=head2 Synopsis - - % prove 202-expr.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4 "Expressions", -L. - -See "Programming in Lua", section 3 "Expressions". - -=cut - ---]] - -require 'Test.More' - -plan(39) - -x = math.pi -is(x - x%0.01, 3.14, "modulo") - -a = {}; a.x = 1; a.y = 0; -b = {}; b.x = 1; b.y = 0; -c = a -is(a == c, true, "relational op (by reference)") -is(a ~= b, true) - -is('0' == 0, false, "relational op") -is(2 < 15, true) -is('2' < '15', false) - -error_like(function () return 2 < '15' end, - "compare", - "relational op") - -error_like(function () return '2' < 15 end, - "compare", - "relational op") - -is(4 and 5, 5, "logical op") -is(nil and 13, nil) -is(false and 13, false) -is(4 or 5, 4) -is(false or 5, 5) -is(false or 'text', 'text') - -is(10 or 20, 10, "logical op") -is(10 or error(), 10) -is(nil or 'a', 'a') -is(nil and 10, nil) -is(false and error(), false) -is(false and nil, false) -is(false or nil, nil) -is(10 and 20, 20) - -is(not nil, true, "logical not") -is(not false, true) -is(not 0, false) -is(not not nil, false) -is(not 'text', false) -a = {} -is(not a, false) - -is("Hello " .. "World", "Hello World", "concatenation") -is(0 .. 1, '01') -a = "Hello" -is(a .. " World", "Hello World") -is(a, "Hello") - -is('10' + 1, 11, "coercion") -is('-5.3' * '2', -10.6) -is(10 .. 20, '1020') -is(tostring(10), '10') -is(10 .. '', '10') - -error_like(function () return 'hello' + 1 end, - "perform arithmetic", - "no coercion") - -error_like(function () - local function first() return 1 end - local function limit() return end - local function step() return 2 end - for i = first(), limit(), step() do - print(i) - end - end, - "^[^:]+:%d+: 'for' limit must be a number", - "for tonumber") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/203-lexico.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/203-lexico.t deleted file mode 100644 index d735f2b4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/203-lexico.t +++ /dev/null @@ -1,122 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Lexicography - -=head2 Synopsis - - % prove 203-lexico.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.1 "Lexical Conventions", -L. - -=cut - ---]] - -require 'Test.More' - -plan(40) - -is("\65", "A") -is("\065", "A") -is("\x41", "A") -is("\x3d", "=") -is("\x3D", "=") - -is(string.byte("\a"), 7) -is(string.byte("\b"), 8) -is(string.byte("\f"), 12) -is(string.byte("\n"), 10) -is(string.byte("\r"), 13) -is(string.byte("\t"), 9) -is(string.byte("\v"), 11) -is(string.byte("\\"), 92) - -is(string.len("A\0B"), 3) - -f, msg = load [[a = "A\300"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = "A\xyz"]] -like(msg, "^[^:]+:%d+: .- near") - -f, msg = load [[a = "A\Z"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = " unfinished string ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \ -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load "a = [[ unfinished long string " -like(msg, "^[^:]+:%d+: unfinished long string near") - -f, msg = load "a = [== invalid long string delimiter " -like(msg, "^[^:]+:%d+: invalid long string delimiter near") - -a = 'alo\n123"' -is('alo\n123"', a) -is("alo\n123\"", a) -is('\97lo\10\04923"', a) -is([[alo -123"]], a) -is([==[ -alo -123"]==], a) -is("alo\n\z -123\"", a) - -f, msg = load [[a = " escape \z unauthorized -new line" ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -is(3.0, 3) -is(314.16e-2, 3.1416) -is(0.31416E1, 3.1416) -is(0xff, 255) -is(0x56, 86) -is(0x0.1E, 0x1E / 0x100) -- 0.1171875 -is(0xA23p-4, 0xA23 / (2^4)) -- 162.1875 -is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2) - -f, msg = load [[a = 12e34e56]] -like(msg, "^[^:]+:%d+: malformed number near") - ---[===[ ---[[ ---[=[ - nested long comments ---]=] ---]] ---]===] - -f, msg = load " --[[ unfinished long comment " -like(msg, "^[^:]+:%d+: unfinished long comment near") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/204-grammar.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/204-grammar.t deleted file mode 100644 index 86636ff2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/204-grammar.t +++ /dev/null @@ -1,106 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Grammar - -=head2 Synopsis - - % prove 204-grammar.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 9 "The Complete Syntax of Lua", -L. - -=cut - ---]] - -require 'Test.More' - -plan(6) - ---[[ empty statement ]] -f, msg = load [[; a = 1]] -type_ok(f, 'function', "empty statement") - ---[[ orphan break ]] -f, msg = load [[ -function f() - print "before" - do - print "inner" - break - end - print "after" -end -]] -if jit then - like(msg, "^[^:]+:%d+: no loop to break", "orphan break") -else - like(msg, "^[^:]+:%d+: at line 5 not inside a loop", "orphan break") -end - ---[[ break anywhere ]] -lives_ok( [[ -function f() - print "before" - while true do - print "inner" - break - print "break" - end - print "after" -end -]], "break anywhere") - ---[[ goto ]] -f, msg = load [[ -::label:: -goto unknown -]] -if jit then - like(msg, ":%d+: undefined label 'unknown'", "unknown goto") -else - like(msg, ":%d+: no visible label 'unknown' for at line %d+", "unknown goto") -end - -f, msg = load [[ -::label:: -goto label -::label:: -]] -if jit then - like(msg, ":%d+: duplicate label 'label'", "duplicate label") -else - like(msg, ":%d+: label 'label' already defined on line %d+", "duplicate label") -end - -f, msg = load [[ -::e:: -goto f -local x -::f:: -goto e -]] -if jit then - like(msg, ":%d+: jumps into the scope of local 'x'", "bad goto") -else - like(msg, ":%d+: at line %d+ jumps into the scope of local 'x'", "bad goto") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/211-scope.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/211-scope.t deleted file mode 100644 index 0781c985..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/211-scope.t +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua scope - -=head2 Synopsis - - % prove 211-scope.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 4.2 "Local Variables and Blocks". - -=cut - ---]] - -require 'Test.More' - -plan(10) - ---[[ scope ]] -x = 10 -do - local x = x - is(x, 10, "scope") - x = x + 1 - do - local x = x + 1 - is(x, 12) - end - is(x, 11) -end -is(x, 10) - ---[[ scope ]] -x = 10 -local i = 1 - -while i<=x do - local x = i*2 --- print(x) - i = i + 1 -end - -if i > 20 then - local x - x = 20 - nok("scope") -else - is(x, 10, "scope") -end - -is(x, 10) - ---[[ scope ]] -local a, b = 1, 10 -if a < b then - is(a, 1, "scope") - local a - is(a, nil) -end -is(a, 1) -is(b, 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/212-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/212-function.t deleted file mode 100644 index 9882884e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/212-function.t +++ /dev/null @@ -1,268 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua functions - -=head2 Synopsis - - % prove 212-function.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.10 "Function Definitions", -L. - -See "Programming in Lua", section 5 "Functions". - -=cut - ---]] - -require 'Test.More' - -plan(63) - ---[[ add ]] -function add (a) - local sum = 0 - for i,v in ipairs(a) do - sum = sum + v - end - return sum -end - -t = { 10, 20, 30, 40 } -is(add(t), 100, "add") - ---[[ f ]] -function f(a, b) return a or b end - -is(f(3), 3, "f") -is(f(3, 4), 3) -is(f(3, 4, 5), 3) - ---[[ incCount ]] -count = 0 - -function incCount (n) - n = n or 1 - count = count + n -end - -is(count, 0, "inCount") -incCount() -is(count, 1) -incCount(2) -is(count, 3) -incCount(1) -is(count, 4) - ---[[ maximum ]] -function maximum (a) - local mi = 1 -- maximum index - local m = a[mi] -- maximum value - for i,val in ipairs(a) do - if val > m then - mi = i - m = val - end - end - return m, mi -end - -local m, mi = maximum({8,10,23,12,5}) -is(m, 23, "maximum") -is(mi, 3) - ---[[ call by value ]] -function f (n) - n = n - 1 - return n -end - -a = 12 -is(a, 12, "call by value") -b = f(a) -is(b, 11) -is(a, 12) -c = f(12) -is(c, 11) -is(a, 12) - ---[[ call by ref ]] -function f (t) - t[#t+1] = 'end' - return t -end - -a = { 'a', 'b', 'c' } -is(table.concat(a, ','), 'a,b,c', "call by ref") -b = f(a) -is(table.concat(b, ','), 'a,b,c,end') -is(table.concat(a, ','), 'a,b,c,end') - ---[[ var args ]] -local function g(a, b, ...) - local arg = {...} - is(a, 3, "vararg") - is(b, nil) - is(#arg, 0) - is(arg[1], nil) -end -g(3) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 0) - is(arg[1], nil) -end -g(3, 4) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 2) - is(arg[1], 5) - is(arg[2], 8) -end -g(3, 4, 5, 8) - ---[[ var args ]] -local function g(a, b, ...) - local c, d, e = ... - is(a, 3, "var args") - is(b, nil) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3, 4) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, 5) - is(d, 8) - is(e, nil) -end - ---[[ var args ]] -local function g(a, b, ...) - is(#{a, b, ...}, 1, "varargs") -end -g(3) - -local function g(a, b, ...) - is(#{a, b, ...}, 2) -end -g(3, 4) - -local function g(a, b, ...) - is(#{a, b, ...}, 4) -end -g(3, 4, 5, 8) - ---[[ var args ]] -function f() return 1, 2 end -function g() return 'a', f() end -function h() return f(), 'b' end -function k() return 'c', (f()) end - -x, y = f() -is(x, 1, "var args") -is(y, 2) -x, y, z = g() -is(x, 'a') -is(y, 1) -is(z, 2) -x, y = h() -is(x, 1) -is(y, 'b') -x, y, z = k() -is(x, 'c') -is(y, 1) -is(z, nil) - - ---[[ invalid var args ]] -f, msg = load [[ -function f () - print(...) -end -]] -like(msg, "^[^:]+:%d+: cannot use '...' outside a vararg function", "invalid var args") - ---[[ tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return foo(n -1) - end - return 'end', 0 -end - -eq_array({foo(3)}, {'end', 0}, "tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return (foo(n -1)) - end - return 'end', 0 -end - -is(foo(3), 'end', "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - foo(n -1) - end -end - -is(foo(3), nil, "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ sub name ]] -local function f () return 1 end -is(f(), 1, "sub name") - -local function f () return 2 end -is(f(), 2) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/213-closure.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/213-closure.t deleted file mode 100644 index 31ab2033..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/213-closure.t +++ /dev/null @@ -1,98 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua closures - -=head2 Synopsis - - % prove 213-closure.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 6.1 "Closures". - -=cut - ---]] - -require 'Test.More' - -plan(15) - ---[[ inc ]] -local counter = 0 - -function inc (x) - counter = counter + x - return counter -end - -is(inc(1), 1, "inc") -is(inc(2), 3) - ---[[ newCounter ]] -function newCounter () - local i = 0 - return function () -- anonymous function - i = i + 1 - return i - end -end - -c1 = newCounter() -is(c1(), 1, "newCounter") -is(c1(), 2) - -c2 = newCounter() -is(c2(), 1) -is(c1(), 3) -is(c2(), 2) - ---[[ -The loop creates ten closures (that is, ten instances of the anonymous -function). Each of these closures uses a different y variable, while all -of them share the same x. -]] -a = {} -local x = 20 -for i=1,10 do - local y = 0 - a[i] = function () y=y+1; return x+y end -end - -is(a[1](), 21, "ten closures") -is(a[1](), 22) -is(a[2](), 21) - - ---[[ add ]] -function add(x) - return function (y) return (x + y) end -end - -f = add(2) -type_ok(f, 'function', "add") -is(f(10), 12) -g = add(5) -is(g(1), 6) -is(g(10), 15) -is(f(1), 3) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/214-coroutine.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/214-coroutine.t deleted file mode 100644 index ed2144c2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/214-coroutine.t +++ /dev/null @@ -1,193 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua coroutines - -=head2 Synopsis - - % prove 214-coroutine.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.6 "Coroutines", -L. - -See "Programming in Lua", section 9 "Coroutines". - -=cut - ---]] - -require 'Test.More' - -plan(30) - ---[[ ]] -output = {} - -function foo1 (a) - output[#output+1] = "foo " .. a - return coroutine.yield(2*a) -end - -co = coroutine.create(function (a,b) - output[#output+1] = "co-body " .. a .." " .. b - local r = foo1(a+1) - output[#output+1] = "co-body " .. r - local r, s = coroutine.yield(a+b, a-b) - output[#output+1] = "co-body " .. r .. " " .. s - return b, 'end' - end) - -eq_array({coroutine.resume(co, 1, 10)}, {true, 4}, "foo1") -eq_array({coroutine.resume(co, 'r')}, {true, 11, -9}) -eq_array({coroutine.resume(co, "x", "y")}, {true, 10, 'end'}) -eq_array({coroutine.resume(co, "x", "y")}, {false, "cannot resume dead coroutine"}) -eq_array(output, { - 'co-body 1 10', - 'foo 2', - 'co-body r', - 'co-body x y', -}) - ---[[ ]] -co = coroutine.create(function () - output = 'hi' - end) -like(co, '^thread: 0?[Xx]?%x+$', "basics") - -is(coroutine.status(co), 'suspended') -output = '' -coroutine.resume(co) -is(output, 'hi') -is(coroutine.status(co), 'dead') - -error_like(function () coroutine.create(true) end, - "^[^:]+:%d+: bad argument #1 to 'create' %(function expected, got boolean%)") - -error_like(function () coroutine.resume(true) end, - "^[^:]+:%d+: bad argument #1 to 'resume' %(coroutine expected, got boolean%)") - -error_like(function () coroutine.status(true) end, - "^[^:]+:%d+: bad argument #1 to 'status' %(coroutine expected, got boolean%)") - ---[[ ]] -output = {} -co = coroutine.create(function () - for i=1,10 do - output[#output+1] = i - coroutine.yield() - end - end) - -coroutine.resume(co) -thr, ismain = coroutine.running(co) -type_ok(thr, 'thread', "running") -is(ismain, true, "running") -is(coroutine.status(co), 'suspended', "basics") -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -eq_array({coroutine.resume(co)}, {false, 'cannot resume dead coroutine'}) -eq_array(output, {1,2,3,4,5,6,7,8,9,10}) - ---[[ ]] -co = coroutine.create(function (a,b) - coroutine.yield(a + b, a - b) - end) - -eq_array({coroutine.resume(co, 20, 10)}, {true, 30, 10}, "basics") - ---[[ ]] -co = coroutine.create(function () - return 6, 7 - end) - -eq_array({coroutine.resume(co)}, {true, 6, 7}, "basics") - ---[[ ]] -co = coroutine.wrap(function(...) - return pcall(function(...) - return coroutine.yield(...) - end, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - ---[[ ]] -co = coroutine.wrap(function(...) - function backtrace () - return 'not a back trace' - end - return xpcall(function(...) - return coroutine.yield(...) - end, backtrace, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - - ---[[ ]] -local output = {} -co = coroutine.wrap(function() - while true do - local t = setmetatable({}, { - __eq = function(...) - return coroutine.yield(...) - end} - ) - local t2 = setmetatable({}, getmetatable(t)) - output[#output+1] = t == t2 - end -end) -co() -co(true) -co(false) -eq_array(output, {true, false}) - ---[[ ]] -co = coroutine.wrap(print) -type_ok(co, 'function') - -error_like(function () coroutine.wrap(true) end, - "^[^:]+:%d+: bad argument #1 to 'wrap' %(function expected, got boolean%)") - -co = coroutine.wrap(function () error"in coro" end) -error_like(function () co() end, - "^[^:]+:%d+: in coro$") - ---[[ ]] -co = coroutine.create(function () - error "in coro" - end) -r, msg = coroutine.resume(co) -is(r, false) -like(msg, "in coro$") - ---[[ ]] -error_like(function () coroutine.yield() end, - "attempt to yield") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/221-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/221-table.t deleted file mode 100644 index f026f77d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/221-table.t +++ /dev/null @@ -1,112 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua tables - -=head2 Synopsis - - % prove 221-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - ---]] - -require 'Test.More' - -plan(25) - ---[[ ]] -a = {} -k = 'x' -a[k] = 10 -a[20] = 'great' -is(a['x'], 10) -k = 20 -is(a[k], 'great') -a['x'] = a ['x'] + 1 -is(a['x'], 11) - ---[[ ]] -a = {} -a['x'] = 10 -b = a -is(b['x'], 10) -b['x'] = 20 -is(a['x'], 20) -a = nil -b = nil - ---[[ ]] -a = {} -for i=1,1000 do a[i] = i*2 end -is(a[9], 18) -a['x'] = 10 -is(a['x'], 10) -is(a['y'], nil) - ---[[ ]] -a = {} -x = 'y' -a[x] = 10 -is(a[x], 10) -is(a.x, nil) -is(a.y, 10) - ---[[ ]] -i = 10; j = '10'; k = '+10' -a = {} -a[i] = "one value" -a[j] = "another value" -a[k] = "yet another value" -is(a[j], "another value") -is(a[k], "yet another value") -is(a[tonumber(j)], "one value") -is(a[tonumber(k)], "one value") - -t = { {'a','b','c'}, 10 } -is(t[2], 10) -is(t[1][3], 'c') -t[1][1] = 'A' -is(table.concat(t[1],','), 'A,b,c') - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is(tt[2], 10) -is(tt[1][3], 'c') -tt[1][1] = 'A' -is(table.concat(tt[1],','), 'A,b,c') - ---[[ ]] -a = {} -error_like(function () a() end, - "^[^:]+:%d+: attempt to call") - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is((tt)[2], 10) -is((tt[1])[3], 'c'); -(tt)[1][2] = 'B' -(tt[1])[3] = 'C' -is(table.concat(tt[1],','), 'a,B,C') - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/222-constructor.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/222-constructor.t deleted file mode 100644 index 44009471..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/222-constructor.t +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Constructors - -=head2 Synopsis - - % prove 222-constructor.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.8 "Table Constructors", -L. - -See "Programming in Lua", section 3.6 "Table Constructors". - -=cut - ---]] - -require 'Test.More' - -plan(14) - ---[[ list-style init ]] -days = {'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday'} -is(days[4], 'Wednesday', "list-style init") -is(#days, 7) - ---[[ record-style init ]] -a = {x=0, y=0} -is(a.x, 0, "record-style init") -is(a.y, 0) - ---[[ ]] -w = {x=0, y=0, label='console'} -x = {0, 1, 2} -w[1] = "another field" -x.f = w -is(w['x'], 0, "ctor") -is(w[1], "another field") -is(x.f[1], "another field") -w.x = nil - ---[[ mix record-style and list-style init ]] -polyline = {color='blue', thickness=2, npoints=4, - {x=0, y=0}, - {x=-10, y=0}, - {x=-10, y=1}, - {x=0, y=1} - } -is(polyline[2].x, -10, "mix record-style and list-style init") - ---[[ ]] -opnames = {['+'] = 'add', ['-'] = 'sub', - ['*'] = 'mul', ['/'] = 'div'} -i = 20; s = '-' -a = {[i+0] = s, [i+1] = s..s, [i+2] = s..s..s} -is(opnames[s], 'sub', "ctor") -is(a[22], '---') - ---[[ ]] -local function f() return 10, 20 end - -eq_array({f()}, {10, 20}, "ctor") -eq_array({'a', f()}, {'a', 10, 20}) -eq_array({f(), 'b'}, {10, 'b'}) -eq_array({'c', (f())}, {'c', 10}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/223-iterator.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/223-iterator.t deleted file mode 100644 index 3905fc22..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/223-iterator.t +++ /dev/null @@ -1,196 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua iterators - -=head2 Synopsis - - % prove 223-iterator.t - -=head2 Description - -See "Programming in Lua", section 7 "Iterators and the Generic for" and -section 9.3 "Coroutines as Iterators". - -=cut - ---]] - -require 'Test.More' - -plan(8) - ---[[ list_iter ]] -function list_iter (t) - local i = 0 - local n = #t - return function () - i = i + 1 - if i <= n then - return t[i] - else - return nil - end - end -end - -t = {10, 20, 30} -output = {} -for element in list_iter(t) do - output[#output+1] = element -end -eq_array(output, t, "list_iter") - ---[[ values ]] -function values (t) - local i = 0 - return function () - i = i + 1 - return t[i] - end -end - -t = {10, 20, 30} -output = {} -for element in values(t) do - output[#output+1] = element -end -eq_array(output, t, "values") - ---[[ emul ipairs ]] -local function iter (a, i) - i = i + 1 - local v = a[i] - if v then - return i, v - end -end - -local function my_ipairs (a) - return iter, a, 0 -end - -a = {'one', 'two', 'three'} -output = {} -for i, v in my_ipairs(a) do - output[#output+1] = i - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ emul pairs ]] -local function my_pairs (t) - return next, t, nil -end - -a = {'one', 'two', 'three'} -output = {} -for k, v in my_pairs(a) do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ with next ]] -t = {'one', 'two', 'three'} -output = {} -for k, v in next, t do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "with next") - ---[[ permutations ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () -- iterator - local code, res = coroutine.resume(co) - return res - end -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations") - - ---[[ permutations with wrap ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - return coroutine.wrap(function () permgen(a) end) -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations with wrap") - ---[[ fibo ]] -function fibogen () - local x, y = 0, 1 - while true do - coroutine.yield(x) - x, y = y, x + y - end -end - -function fibo () - return coroutine.wrap(function () fibogen() end) -end - -output = {} -for n in fibo() do - output[#output+1] = n - if n > 30 then break end -end -eq_array(output, {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}, "fibo") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/231-metatable.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/231-metatable.t deleted file mode 100644 index fc05e7bc..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/231-metatable.t +++ /dev/null @@ -1,533 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua metatables - -=head2 Synopsis - - % prove 231-metatable.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.4 "Metatables and Metamethods", -L. - -See "Programming in Lua", section 13 "Metatables and Metamethods". - -=cut - ---]] - -require 'Test.More' - -plan(96) - -t = {} -is(getmetatable(t), nil, "metatable") -t1 = {} -is(setmetatable(t, t1), t) -is(getmetatable(t), t1) -is(setmetatable(t, nil), t) -error_like(function () setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected.+%)") - -mt = {} -mt.__metatable = "not your business" -setmetatable(t, mt) -is(getmetatable(t), "not your business", "protected metatable") -error_like(function () setmetatable(t, {}) end, - "^[^:]+:%d+: cannot change a protected metatable") - -is(getmetatable('').__index, string, "metatable for string") - -is(getmetatable(nil), nil, "metatable for nil") -is(getmetatable(false), nil, "metatable for boolean") -is(getmetatable(2), nil, "metatable for number") -is(getmetatable(print), nil, "metatable for function") - -t = {} -mt = { __tostring=function () return '__TABLE__' end } -setmetatable(t, mt) -is(tostring(t), '__TABLE__', "__tostring") - -mt = {} -a = nil -function mt.__tostring () a = "return nothing" end -setmetatable(t, mt) -is(tostring(t), nil, "__tostring no-output") -is(a, "return nothing") -error_like(function () print(t) end, - "^[^:]+:%d+: 'tostring' must return a string to 'print'") - -mt.__tostring = function () return '__FIRST__', 2 end -setmetatable(t, mt) -is(tostring(t), '__FIRST__', "__tostring too-many-output") - -t = {} -t.mt = {} -setmetatable(t, t.mt) -t.mt.__tostring = "not a function" -error_like(function () tostring(t) end, - "attempt to call", - "__tostring invalid") - -t = {} -mt = { __len=function () return 42 end } -setmetatable(t, mt) -is(#t, 42, "__len") - -t = {} -mt = { __len=function () return nil end } -setmetatable(t, mt) -if jit then - todo("LuaJIT TODO. __len.", 1) -end -error_like(function () print(table.concat(t)) end, - "object length is not a number", - "__len invalid") - -t = {} -mt = { - __tostring=function () return 't' end, - __concat=function (op1, op2) - return tostring(op1) .. '|' .. tostring(op2) - end, -} -setmetatable(t, mt) -is(t .. t .. t .. 4 ..'end', "t|t|t|4end", "__concatx") - - ---[[ Cplx ]] -Cplx = {} -Cplx.mt = {} - -function Cplx.new (re, im) - local c = {} - setmetatable(c, Cplx.mt) - c.re = tonumber(re) - if im == nil then - c.im = 0.0 - else - c.im = tonumber(im) - end - return c -end - -function Cplx.mt.__tostring (c) - return '(' .. c.re .. ',' .. c.im .. ')' -end - -function Cplx.mt.__add (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re + b.re, a.im + b.im) - return r -end - -c1 = Cplx.new(1, 3) -c2 = Cplx.new(2, -1) - -is(tostring(c1 + c2), '(3,2)', "cplx __add") -is(tostring(c1 + 3), '(4,3)') -is(tostring(-2 + c1), '(-1,3)') -is(tostring(c1 + '3'), '(4,3)') -is(tostring('-2' + c1), '(-1,3)') - -function Cplx.mt.__sub (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re - b.re, a.im - b.im) - return r -end - -is(tostring(c1 - c2), '(-1,4)', "cplx __sub") -is(tostring(c1 - 3), '(-2,3)') -is(tostring(-2 - c1), '(-3,-3)') -is(tostring(c1 - '3'), '(-2,3)') -is(tostring('-2' - c1), '(-3,-3)') - -function Cplx.mt.__mul (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re*b.re - a.im*b.im, - a.re*b.im + a.im*b.re) - return r -end - -is(tostring(c1 * c2), '(5,5)', "cplx __mul") -is(tostring(c1 * 3), '(3,9)') -is(tostring(-2 * c1), '(-2,-6)') -is(tostring(c1 * '3'), '(3,9)') -is(tostring('-2' * c1), '(-2,-6)') - -function Cplx.mt.__div (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local n = b.re*b.re + b.im*b.im - local inv = Cplx.new(b.re/n, b.im/n) - local r = Cplx.new(a.re*inv.re - a.im*inv.im, - a.re*inv.im + a.im*inv.re) - return r -end - -c1 = Cplx.new(2, 6) -c2 = Cplx.new(2, 0) - -is(tostring(c1 / c2), '(1,3)', "cplx __div") -is(tostring(c1 / 2), '(1,3)') -is(tostring(-4 / c2), '(-2,0)') -is(tostring(c1 / '2'), '(1,3)') -is(tostring('-4' / c2), '(-2,0)') - -function Cplx.mt.__unm (a) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - local r = Cplx.new(-a.re, -a.im) - return r -end - -c1 = Cplx.new(1, 3) -is(tostring(- c1), '(-1,-3)', "cplx __unm") - -function Cplx.mt.__len (a) - return math.sqrt(a.re*a.re + a.im*a.im) -end - -c1 = Cplx.new(3, 4) -is( #c1, 5, "cplx __len") - -function Cplx.mt.__eq (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - return (a.re == b.re) and (b.im == b.im) -end - -c1 = Cplx.new(2, 0) -c2 = Cplx.new(1, 3) -c3 = Cplx.new(2, 0) - -is(c1 ~= c2, true, "cplx __eq") -is(c1 == c3, true) -is(c1 == 2, false) -is(Cplx.mt.__eq(c1, 2), true) - -function Cplx.mt.__lt (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra < rb -end - -is(c1 < c2, true, "cplx __lt") -is(c1 < c3, false) -is(c1 <= c3, true) -is(c1 < 1, false) -is(c1 < 4, true) - -function Cplx.mt.__le (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra <= rb -end - -is(c1 < c2, true, "cplx __lt __le") -is(c1 < c3, false) -is(c1 <= c3, true) - -function Cplx.mt.__call (obj) - a = "Cplx.__call " .. tostring(obj) - return true -end - -c1 = Cplx.new(2, 0) -a = nil -r = c1() -is(r, true, "cplx __call (without args)") -is(a, "Cplx.__call (2,0)") - -function Cplx.mt.__call (obj, ...) - a = "Cplx.__call " .. tostring(obj) .. ", " .. table.concat({...}, ", ") - return true -end - -is(c1(), true, "cplx __call (with args)") -is(a, "Cplx.__call (2,0), ") -is(c1('a'), true) -is(a, "Cplx.__call (2,0), a") -is(c1('a', 'b', 'c'), true) -is(a, "Cplx.__call (2,0), a, b, c") - ---[[ delegate ]] - -local t = { - _VALUES = { - a = 1, - b = 'text', - c = true, - } -} -local mt = { - __pairs = function (op) - return next, op._VALUES - end -} -setmetatable(t, mt) - -r = {} -for k in pairs(t) do - r[#r+1] = k -end -table.sort(r) -is( table.concat(r, ','), 'a,b,c', "__pairs" ) - -local t = { - _VALUES = { 'a', 'b', 'c' } -} -local mt = { - __ipairs = function (op) - return ipairs(op._VALUES) - end -} -setmetatable(t, mt) - -r = '' -for i, v in ipairs(t) do - r = r .. v -end -is( r, 'abc', "__ipairs" ) - ---[[ Window ]] - --- create a namespace -Window = {} --- create a prototype with default values -Window.prototype = {x=0, y=0, width=100, heigth=100, } --- create a metatable -Window.mt = {} --- declare the constructor function -function Window.new (o) - setmetatable(o, Window.mt) - return o -end - -Window.mt.__index = function (table, key) - return Window.prototype[key] -end - -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - -Window.mt.__index = Window.prototype -- just a table -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - ---[[ tables with default values ]] -function setDefault_1 (t, d) - local mt = {__index = function () return d end} - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_1(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local mt = {__index = function (t) return t.___ end} -function setDefault_2 (t, d) - t.___ = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_2(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local key = {} -local mt = {__index = function (t) return t[key] end} -function setDefault_3 (t, d) - t[key] = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_3(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ private access ]] -t = {} -- original table --- keep a private access to original table -local _t = t --- create proxy -t = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return _t[k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - _t[k] = v -- update original table - end -} -setmetatable(t, mt) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ private access ]] --- create private index -local index = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return t[index][k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - t[index][k] = v -- update original table - end -} -function track (t) - local proxy = {} - proxy[index] = t - setmetatable(proxy, mt) - return proxy -end - -t = {} -t = track(t) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ read-only table ]] -function readOnly (t) - local proxy = {} - local mt = { - __index = t, - __newindex = function (t,k,v) - error("attempt to update a read-only table", 2) - end - } - setmetatable(proxy, mt) - return proxy -end - -days = readOnly{'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thurday', 'Friday', 'Saturday'} - -is(days[1], 'Sunday', "read-only tables") - -error_like(function () days[2] = 'Noday' end, - "^[^:]+:%d+: attempt to update a read%-only table") - ---[[ declare global ]] -function declare (name, initval) - rawset(_G, name, initval or false) -end - -setmetatable(_G, { - __newindex = function (_, n) - error("attempt to write to undeclared variable " .. n, 2) - end, - __index = function (_, n) - error("attempt to read undeclared variable" .. n, 2) - end, -}) - -error_like(function () new_a = 1 end, - "^[^:]+:%d+: attempt to write to undeclared variable new_a", - "declaring global variables") - -declare 'new_a' -new_a = 1 -is(new_a, 1) - ---[[ ]] -local newindex = {} --- create metatable -local mt = { - __newindex = newindex -} -local t = setmetatable({}, mt) -t[1] = 42 -is(newindex[1], 42, "__newindex") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/232-object.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/232-object.t deleted file mode 100644 index f00eb321..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/232-object.t +++ /dev/null @@ -1,307 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua object - -=head2 Synopsis - - % prove 232-object.t - -=head2 Description - -See "Programming in Lua", section 16 "Object-Oriented Programming". - -=cut - ---]] - -require 'Test.More' - -plan(18) - ---[[ object ]] -Account = {balance = 0} - -function Account.withdraw (self, v) - self.balance = self.balance - v -end - -a1 = Account; Account = nil -a1.withdraw(a1, 100.00) -is(a1.balance, -100, "object") - -a2 = {balance = 0, withdraw = a1.withdraw} -a2.withdraw(a2, 260.00) -is(a2.balance, -260) - ---[[ object ]] -Account = {balance = 0} - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account -a:withdraw(100.00) -is(a.balance, -100, "object") - -Account = { balance = 0, - withdraw = function (self, v) - self.balance = self.balance -v - end - } -function Account:deposit (v) - self.balance = self.balance + v -end - -Account.deposit(Account, 200.00) -is(Account.balance, 200, "object") -Account:withdraw(100.00) -is(Account.balance, 100) - ---[[ classe ]] -Account = {balance = 0} - -function Account:new (o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) - self.balance = self.balance + v -end - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account:new{balance = 0} -a:deposit(100.00) -is(a.balance, 100, "classe") - -b = Account:new() -is(b.balance, 0) -b:deposit(200.00) -is(b.balance, 200) - ---[[ inheritance ]] -Account = {balance = 0} - -function Account:new (o) --- print "Account:new" - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) --- print "Account:deposit" - self.balance = self.balance + v -end - -function Account:withdraw (v) --- print "Account:withdraw" - if v > self.balance then error"insuficient funds" end - self.balance = self.balance - v -end - -a = Account:new() -is(a.balance, 0, "inheritance") --- r, msg = pcall(Account.withdraw, a, 100) --- print(msg) - -SpecialAccount = Account:new() - -function SpecialAccount:withdraw (v) --- print "SpecialAccount:withdraw" - if self.balance - v <= -self:getLimit() then - error"insuficient funds" - end - self.balance = self.balance - v -end - -function SpecialAccount:getLimit () --- print "SpecialAccount:getLimit" - return self.limit or 0 -end - -s = SpecialAccount:new{limit=1000.00} - -s:deposit(100.00) -is(s.balance, 100) - -s:withdraw(200.00) -is(s.balance, -100) - ---[[ multiple inheritance ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - return search(k, arg) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance") -account:deposit(100.00) -is(account.balance, 100) - - ---[[ multiple inheritance (patched) ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - -- return search(k, arg) - return (search(k, arg)) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance (patched)") -account:deposit(100.00) -is(account.balance, 100) - ---[[ privacy ]] -function newAccount (initialBalance) - local self = {balance = initialBalance} - - local withdraw = function (v) - self.balance = self.balance - v - end - - local deposit = function (v) - self.balance = self.balance + v - end - - local getBalance = function () return self.balance end - - return { - withdraw = withdraw, - deposit = deposit, - getBalance = getBalance - } -end - -acc1 = newAccount(100.00) -acc1.withdraw(40.00) -is(acc1.getBalance(), 60, "privacy") - ---[[ single-method approach ]] -function newObject (value) - return function (action, v) - if action == 'get' then return value - elseif action == 'set' then value = v - else error("invalid action") - end - end -end - -d = newObject(0) -is(d('get'), 0, "single-method approach") -d('set', 10) -is(d('get'), 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/301-basic.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/301-basic.t deleted file mode 100644 index 62eb0970..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/301-basic.t +++ /dev/null @@ -1,391 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Basic Library - -=head2 Synopsis - - % prove 301-basic.t - -=head2 Description - -Tests Lua Basic Library - -See "Lua 5.2 Reference Manual", section 6.1 "Basic Functions", -L. - -=cut - ---]] - --- MoonSharp note : THIS SUITE WAS HEAVILY CUT FOR NOT APPLIABLE TESTS - - -require 'Test.More' - -plan(168) - ---[[ -if jit then - like(_VERSION, '^Lua 5%.1$', "variable _VERSION") -else - like(_VERSION, '^Lua 5%.2$', "variable _VERSION") -end --- ]] - -v, msg = assert('text', "assert string") -is(v, 'text', "function assert") -is(msg, "assert string") -v, msg = assert({}, "assert table") -is(msg, "assert table") - -error_like(function () assert(false, "ASSERTION TEST") end, - "^[^:]+:%d+: ASSERTION TEST", - "function assert(false, msg)") - -error_like(function () assert(false) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false)") - -error_like(function () assert(false, nil) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false, nil)") - - -a = {'a','b','c'} -local f, v, s = ipairs(a) -type_ok(f, 'function', "function ipairs") -type_ok(v, 'table') -is(s, 0) -s, v = f(a, s) -is(s, 1) -is(v, 'a') -s, v = f(a, s) -is(s, 2) -is(v, 'b') -s, v = f(a, s) -is(s, 3) -is(v, 'c') -s, v = f(a, s) -is(s, nil) -is(v, nil) - -t = { [[ -function bar (x) - return x -end -]] } -i = 0 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(reader)") -is(bar, nil) -f() -is(bar('ok'), 'ok') -bar = nil - -t = { [[ -function baz (x) - return x -end -]] } -i = -1 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(pathological reader)") -f() -is(baz, nil) - -t = { [[?syntax error?]] } -i = 0 -f, msg = load(reader, "errorchunk") -is(f, nil, "function load(syntax error)") ---like(msg, "^%[string \"errorchunk\"%]:%d+:") -- ERRORMSG - -f = load(function () return nil end) -type_ok(f, 'function', "when reader returns nothing") - -f, msg = load(function () return {} end) -is(f, nil, "reader function must return a string") -like(msg, "reader function must return a string") - -f = load([[ -function bar (x) - return x -end -]]) -is(bar, nil, "function load(str)") -f() -is(bar('ok'), 'ok') -bar = nil - -env = {} -f = load([[ -function bar (x) - return x -end -]], "from string", 't', env) -is(env.bar, nil, "function load(str)") -f() -is(env.bar('ok'), 'ok') - - --- ... - - -f = load([[i = i + 1]]) -i = 0 -f() -is(i, 1, "function loadstring") -f() -is(i, 2) - -i = 32 -local i = 0 -f = load([[i = i + 1; return i]]) -g = function () i = i + 1; return i end -is(f(), 33, "function loadstring") -is(g(), 1) - -f, msg = load([[?syntax error?]]) -is(f, nil, "function loadstring (syntax error)") --- like(msg, '^%[string "%?syntax error%?"%]:%d+:') -- ERRORMSG - -t = {'a','b','c'} -a = next(t, nil) -is(a, 1, "function next (array)") -a = next(t, 1) -is(a, 2) -a = next(t, 2) -is(a, 3) -a = next(t, 3) -is(a, nil) - -error_like(function () a = next() end, - "^[^:]+:%d+: bad argument #1 to 'next' %(table expected, got no value%)", - "function next (no arg)") - -error_like(function () a = next(t, 6) end, - "invalid key to 'next'", - "function next (invalid key)") - -t = {'a','b','c'} -a = next(t, 2) -is(a, 3, "function next (unorderer)") -a = next(t, 1) -is(a, 2) -a = next(t, 3) -is(a, nil) - -t = {} -a = next(t, nil) -is(a, nil, "function next (empty table)") - -a = {'a','b','c'} -local f, v, s = pairs(a) -type_ok(f, 'function', "function pairs") -type_ok(v, 'table') -is(s, nil) -s = f(v, s) -is(s, 1) -s = f(v, s) -is(s, 2) -s = f(v, s) -is(s, 3) -s = f(v, s) -is(s, nil) - -r = pcall(assert, true) -is(r, true, "function pcall") -r, msg = pcall(assert, false, 'catched') -is(r, false) -is(msg, 'catched') -r = pcall(assert) -is(r, false) - -t = {} -a = t -is(rawequal(nil, nil), true, "function rawequal -> true") -is(rawequal(false, false), true) -is(rawequal(3, 3), true) -is(rawequal('text', 'text'), true) -is(rawequal(t, a), true) -is(rawequal(print, print), true) - -is(rawequal(nil, 2), false, "function rawequal -> false") -is(rawequal(false, true), false) -is(rawequal(false, 2), false) -is(rawequal(3, 2), false) -is(rawequal(3, '2'), false) -is(rawequal('text', '2'), false) -is(rawequal('text', 2), false) -is(rawequal(t, {}), false) -is(rawequal(t, 2), false) -is(rawequal(print, format), false) -is(rawequal(print, 2), false) - -is(rawlen("text"), 4, "function rawlen (string)") -is(rawlen({ 'a', 'b', 'c'}), 3, "function rawlen (table)") -error_like(function () a = rawlen(true) end, - "^[^:]+:%d+: bad argument #1 to 'rawlen' %(table ", - "function rawlen (bad arg)") - -t = {a = 'letter a', b = 'letter b'} -is(rawget(t, 'a'), 'letter a', "function rawget") - -t = {} -is(rawset(t, 'a', 'letter a'), t, "function rawset") -is(t.a, 'letter a') - -error_like(function () t = {}; rawset(t, nil, 42) end, - "^[^:]+:%d+: table index is nil", -- changed this for MoonSharp, but we stay as it is! - "function rawset (table index is nil)") - -is(select('#'), 0, "function select") -is(select('#','a','b','c'), 3) -eq_array({select(1,'a','b','c')}, {'a','b','c'}) -eq_array({select(3,'a','b','c')}, {'c'}) -eq_array({select(5,'a','b','c')}, {}) -eq_array({select(-1,'a','b','c')}, {'c'}) -eq_array({select(-2,'a','b','c')}, {'b', 'c'}) -eq_array({select(-3,'a','b','c')}, {'a', 'b', 'c'}) - -error_like(function () select(0,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -error_like(function () select(-4,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -is(type("Hello world"), 'string', "function type") -is(type(10.4*3), 'number') -is(type(print), 'function') -is(type(type), 'function') -is(type(true), 'boolean') -is(type(nil), 'nil') --- is(type(io.stdin), 'userdata') -- no stdin in MoonSharp so far -is(type(type(X)), 'string') - -a = nil -is(type(a), 'nil', "function type") -a = 10 -is(type(a), 'number') -a = "a string!!" -is(type(a), 'string') -a = print -is(type(a), 'function') -is(type(function () end), 'function') - -error_like(function () type() end, - "^[^:]+:%d+: bad argument #1 to 'type' %(value expected%)", - "function type (no arg)") - -is(tonumber('text12'), nil, "function tonumber") -is(tonumber('12text'), nil) -is(tonumber(3.14), 3.14) -is(tonumber('3.14'), 3.14) -is(tonumber(' 3.14 '), 3.14) -is(tonumber(111, 2), 7) -is(tonumber('111', 2), 7) -is(tonumber(' 111 ', 2), 7) -is(tonumber('78', 9), 71) -is(tonumber('111 ', 3), 13) -is(tonumber('111', 4), 21) -is(tonumber('1234', 5), 194) -is(tonumber('54321', 6), 7465) - -a = {} -is(tonumber(a), nil) - -error_like(function () tonumber() end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(value expected%)", - "function tonumber (no arg)") - -error_like(function () tonumber('111', 200) end, - "^[^:]+:%d+: bad argument #2 to 'tonumber' %(base out of range%)", - "function tonumber (bad base)") - -error_like(function () tonumber('17', 6) end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(invalid character%)", - "function tonumber (bad base)") - -is(tostring('text'), 'text', "function tostring") -is(tostring(3.14), '3.14') -is(tostring(nil), 'nil') -is(tostring(true), 'true') -is(tostring(false), 'false') -like(tostring({}), '^table: 0?[Xx]?%x+$') -like(tostring(print), '^function: 0?[Xx]?[builtin]*#?%x+$') - -error_like(function () tostring() end, - "^[^:]+:%d+: bad argument #1 to 'tostring' %(value expected%)", - "function tostring (no arg)") - ---[[ MoonSharp : this is intentional - we support pack and unpack outside the table namespace (or whatever they are) -if (platform and platform.compat) or jit then - type_ok(unpack, 'function', "function unpack") -else - is(unpack, nil, "function unpack (removed)") -end -]] - - -if jit then - error_like(function () xpcall(assert, nil) end, - "bad argument #2 to 'xpcall' %(function expected, got nil%)", - "function xpcall") - error_like(function () xpcall(assert) end, - "bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall") - diag("LuaJIT intentional. xpcall") -else - is(xpcall(assert, nil), false, "function xpcall") - error_like(function () xpcall(assert) end, - "^[^:]+:%d+: bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall (no arg)") -end - -function backtrace () - return 'not a back trace' -end -r, msg = xpcall(assert, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r, msg = xpcall(function() assert(); end, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r = xpcall(assert, backtrace, true) -is(r, true, "function xpcall") - - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/304-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/304-string.t deleted file mode 100644 index f610aaed..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/304-string.t +++ /dev/null @@ -1,318 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua String Library - -=head2 Synopsis - - % prove 304-string.t - -=head2 Description - -Tests Lua String Library - -See "Lua 5.2 Reference Manual", section 6.4 "String Manipulation", -L. - -See "Programming in Lua", section 20 "The String Library". - -=cut - -]] - -require 'Test.More' - -plan(115) - -is(string.byte('ABC'), 65, "function byte") -is(string.byte('ABC', 2), 66) -is(string.byte('ABC', -1), 67) -is(string.byte('ABC', 4), nil) -is(string.byte('ABC', 0), nil) -eq_array({string.byte('ABC', 1, 3)}, {65, 66, 67}) -eq_array({string.byte('ABC', 1, 4)}, {65, 66, 67}) - -type_ok(getmetatable('ABC'), 'table', "literal string has metatable") - -s = "ABC" -is(s:byte(2), 66, "method s:byte") - -is(string.char(65, 66, 67), 'ABC', "function char") -is(string.char(), '') - -error_like(function () string.char(0, 'bad') end, - "^[^:]+:%d+: bad argument #2 to 'char' %(number expected, got string%)", - "function char (bad arg)") - - ---[[ -MoonSharp intentional : - -1) unicode chars supported! -2) plan has upvalues, and by Lua spec it shouldn't be supported! - -error_like(function () string.char(0, 9999) end, - "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)", - "function char (invalid)") - -d = string.dump(plan) -type_ok(d, 'string', "function dump") - -error_like(function () string.dump(print) end, - "^[^:]+:%d+: unable to dump given function", - "function dump (C function)") - -]] - -s = "hello world" -eq_array({string.find(s, "hello")}, {1, 5}, "function find (mode plain)") -eq_array({string.find(s, "hello", 1, true)}, {1, 5}) -eq_array({string.find(s, "hello", 1)}, {1, 5}) -is(string.sub(s, 1, 5), "hello") -eq_array({string.find(s, "world")}, {7, 11}) -eq_array({string.find(s, "l")}, {3, 3}) -is(string.find(s, "lll"), nil) -is(string.find(s, "hello", 2, true), nil) -eq_array({string.find(s, "world", 2, true)}, {7, 11}) -is(string.find(s, "hello", 20), nil) - -s = "hello world" -eq_array({string.find(s, "^h.ll.")}, {1, 5}, "function find (with regex & captures)") -eq_array({string.find(s, "w.rld", 2)}, {7, 11}) -is(string.find(s, "W.rld"), nil) -eq_array({string.find(s, "^(h.ll.)")}, {1, 5, 'hello'}) -eq_array({string.find(s, "^(h.)l(l.)")}, {1, 5, 'he', 'lo'}) -s = "Deadline is 30/05/1999, firm" -date = "%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") -date = "%f[%S]%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") - -error_like(function () string.find(s, '%f') end, - "^[^:]+:%d+: missing '%[' after '%%f' in pattern", - "function find (invalid frontier)") - -is(string.format("pi = %.4f", math.pi), 'pi = 3.1416', "function format") -d = 5; m = 11; y = 1990 -is(string.format("%02d/%02d/%04d", d, m, y), "05/11/1990") -is(string.format("%X %x", 126, 126), "7E 7e") -tag, title = "h1", "a title" -is(string.format("<%s>%s", tag, title, tag), "

a title

") - --- moonsharp : this commented out as it might fail mostly because of CRLF in windows than because of --- a moonsharp bug I think. Will see, surely not a blocking issue now. ---[==[ -is(string.format('%q', 'a string with "quotes" and \n new line'), [["a string with \"quotes\" and \ - new line"]], "function format %q") ---]==] - -is(string.format('%q', 'a string with \b and \b2'), [["a string with \8 and \0082"]], "function format %q") - -is(string.format("%s %s", 1, 2, 3), '1 2', "function format (too many arg)") - -is(string.format("%% %c %%", 65), '% A %', "function format (%%)") - -r = string.rep("ab", 100) -is(string.format("%s %d", r, r:len()), r .. " 200") - -error_like(function () string.format("%s %s", 1) end, - "^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)", - "function format (too few arg)") - -error_like(function () string.format('%d', 'toto') end, - "^[^:]+:%d+: bad argument #2 to 'format' %(number expected, got string%)", - "function format (bad arg)") - -error_like(function () string.format('%k', 'toto') end, - "^[^:]+:%d+: invalid option '%%k' to 'format'", - "function format (invalid option)") - -if jit and jit.version_num >= 20100 then - todo("LuaJIT TODO. format.", 1) -end -error_like(function () string.format('%------s', 'toto') end, - "^[^:]+:%d+: invalid format %(repeated flags%)", - "function format (invalid format)") - -error_like(function () string.format('pi = %.123f', math.pi) end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -error_like(function () string.format('% 123s', 'toto') end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -s = "hello" -output = {} -for c in string.gmatch(s, '..') do - table.insert(output, c) -end -eq_array(output, {'he', 'll'}, "function gmatch") -output = {} -for c1, c2 in string.gmatch(s, '(.)(.)') do - table.insert(output, c1) - table.insert(output, c2) -end -eq_array(output, {'h', 'e', 'l', 'l'}) -s = "hello world from Lua" -output = {} -for w in string.gmatch(s, '%a+') do - table.insert(output, w) -end -eq_array(output, {'hello', 'world', 'from', 'Lua'}) -s = "from=world, to=Lua" -output = {} -for k, v in string.gmatch(s, '(%w+)=(%w+)') do - table.insert(output, k) - table.insert(output, v) -end -eq_array(output, {'from', 'world', 'to', 'Lua'}) - -is(string.gsub("hello world", "(%w+)", "%1 %1"), "hello hello world world", "function gsub") -is(string.gsub("hello world", "%w+", "%0 %0", 1), "hello hello world") - - -is(string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1"), "world hello Lua from") - - -if jit then - todo("LuaJIT TODO. gsub.", 1) -end - -error_like(function () string.gsub("hello world", "%w+", "%e") end, - "^[^:]+:%d+: invalid use of '%%' in replacement string", - "function gsub (invalid replacement string)") - -is(string.gsub("home = $HOME, user = $USER", "%$(%w+)", string.reverse), "home = EMOH, user = RESU") -is(string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) return load(s)() end), "4+5 = 9") -local t = {name='lua', version='5.1'} -is(string.gsub("$name-$version.tar.gz", "%$(%w+)", t), "lua-5.1.tar.gz") -is(string.gsub("Lua is cute", 'cute', 'great'), "Lua is great") -is(string.gsub("all lii", 'l', 'x'), "axx xii") -is(string.gsub("Lua is great", '^Sol', 'Sun'), "Lua is great") -is(string.gsub("all lii", 'l', 'x', 1), "axl lii") -is(string.gsub("all lii", 'l', 'x', 2), "axx lii") -is(select(2, string.gsub("string with 3 spaces", ' ', ' ')), 3) - -eq_array({string.gsub("hello, up-down!", '%A', '.')}, {"hello..up.down.", 4}) -text = "hello world" -nvow = select(2, string.gsub(text, '[AEIOUaeiou]', '')) -is(nvow, 3) -eq_array({string.gsub("one, and two; and three", '%a+', 'word')}, {"word, word word; word word", 5}) -test = "int x; /* x */ int y; /* y */" -eq_array({string.gsub(test, "/%*.*%*/", '')}, {"int x; ", 1}) -eq_array({string.gsub(test, "/%*.-%*/", '')}, {"int x; int y; ", 2}) -s = "a (enclosed (in) parentheses) line" -eq_array({string.gsub(s, '%b()', '')}, {"a line", 1}) - -error_like(function () string.gsub(s, '%b(', '') end, - "^[^:]+:%d+: .- pattern", - "function gsub (malformed pattern)") - -eq_array({string.gsub("hello Lua!", "%a", "%0-%0")}, {"h-he-el-ll-lo-o L-Lu-ua-a!", 8}) -eq_array({string.gsub("hello Lua", "(.)(.)", "%2%1")}, {"ehll ouLa", 4}) - -function expand (s) - return (string.gsub(s, '$(%w+)', _G)) -end -name = 'Lua'; status= 'great' -is(expand("$name is $status, isn't it?"), "Lua is great, isn't it?") -is(expand("$othername is $status, isn't it?"), "$othername is great, isn't it?") - -function expand (s) - return (string.gsub(s, '$(%w+)', function (n) - return tostring(_G[n]), 1 - end)) -end -like(expand("print = $print; a = $a"), "^print = function: [0]?[Xx]?[builtin]*#?%x+; a = nil") - -error_like(function () string.gsub("hello world", '(%w+)', '%2 %2') end, - "^[^:]+:%d+: invalid capture index", - "function gsub (invalid index)") - -error_like(function () string.gsub("hello world", '(%w+)', true) end, - "^[^:]+:%d+: bad argument #3 to 'gsub' %(string/function/table expected%)", - "function gsub (bad type)") - -error_like(function () - function expand (s) - return (string.gsub(s, '$(%w+)', _G)) - end - - name = 'Lua'; status= true - expand("$name is $status, isn't it?") - end, - "^[^:]+:%d+: invalid replacement value %(a boolean%)", - "function gsub (invalid value)") - -is(string.len(''), 0, "function len") -is(string.len('test'), 4) -is(string.len("a\000b\000c"), 5) -is(string.len('"'), 1) - -is(string.lower('Test'), 'test', "function lower") -is(string.lower('TeSt'), 'test') - -s = "hello world" -is(string.match(s, '^hello'), 'hello', "function match") -is(string.match(s, 'world', 2), 'world') -is(string.match(s, 'World'), nil) -eq_array({string.match(s, '^(h.ll.)')}, {'hello'}) -eq_array({string.match(s, '^(h.)l(l.)')}, {'he', 'lo'}) -date = "Today is 17/7/1990" -is(string.match(date, '%d+/%d+/%d+'), '17/7/1990') -eq_array({string.match(date, '(%d+)/(%d+)/(%d+)')}, {'17', '7', '1990'}) -is(string.match("The number 1298 is even", '%d+'), '1298') -pair = "name = Anna" -eq_array({string.match(pair, '(%a+)%s*=%s*(%a+)')}, {'name', 'Anna'}) - -s = [[then he said: "it's all right"!]] -eq_array({string.match(s, "([\"'])(.-)%1")}, {'"', "it's all right"}, "function match (back ref)") -p = "%[(=*)%[(.-)%]%1%]" -s = "a = [=[[[ something ]] ]==]x]=]; print(a)" -eq_array({string.match(s, p)}, {'=', '[[ something ]] ]==]x'}) - -is(string.match(s, "%g"), "a", "match graphic char") - -error_like(function () string.match("hello world", "%1") end, - "^[^:]+:%d+: invalid capture index", - "function match invalid capture") - -error_like(function () string.match("hello world", "%w)") end, - "^[^:]+:%d+: invalid pattern capture", - "function match invalid capture") - -is(string.rep('ab', 3), 'ababab', "function rep") -is(string.rep('ab', 0), '') -is(string.rep('ab', -1), '') -is(string.rep('', 5), '') -is(string.rep('ab', 3, ','), 'ab,ab,ab', "with sep") - -is(string.reverse('abcde'), 'edcba', "function reverse") -is(string.reverse('abcd'), 'dcba') -is(string.reverse(''), '') - -is(string.sub('abcde', 1, 2), 'ab', "function sub") -is(string.sub('abcde', 3, 4), 'cd') -is(string.sub('abcde', -2), 'de') -is(string.sub('abcde', 3, 2), '') - -is(string.upper('Test'), 'TEST', "function upper") -is(string.upper('TeSt'), 'TEST') -is(string.upper(string.rep('Test', 10000)), string.rep('TEST', 10000)) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/305-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/305-table.t deleted file mode 100644 index 0c40f3a5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/305-table.t +++ /dev/null @@ -1,253 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Library - -=head2 Synopsis - - % prove 305-table.t - -=head2 Description - -Tests Lua Table Library - -See "Lua 5.2 Reference Manual", section 6.5 "Table Manipulation", -L. - -See "Programming in Lua", section 19 "The Table Library". - -=cut - ---]] - -require 'Test.More' - -plan(44) - -t = {'a','b','c','d','e'} -is(table.concat(t), 'abcde', "function concat") -is(table.concat(t, ','), 'a,b,c,d,e') -is(table.concat(t, ',',2), 'b,c,d,e') -is(table.concat(t, ',', 2, 4), 'b,c,d') -is(table.concat(t, ',', 4, 2), '') - -t = {'a','b',3,'d','e'} -is(table.concat(t,','), 'a,b,3,d,e', "function concat (number)") - -t = {'a','b','c','d','e'} -error_like(function () table.concat(t, ',', 2, 7) end, - "^[^:]+:%d+: invalid value %(nil%) at index 6 in table for 'concat'", - "function concat (out of range)") - -t = {'a','b',true,'d','e'} -error_like(function () table.concat(t, ',') end, - "^[^:]+:%d+: invalid value %(boolean%) at index 3 in table for 'concat'", - "function concat (non-string)") - -a = {10, 20, 30} -table.insert(a, 1, 15) -is(table.concat(a,','), '15,10,20,30', "function insert") -t = {} -table.insert(t, 'a') -is(table.concat(t, ','), 'a') -table.insert(t, 'b') -is(table.concat(t, ','), 'a,b') -table.insert(t, 1, 'c') -is(table.concat(t, ','), 'c,a,b') -table.insert(t, 2, 'd') -is(table.concat(t, ','), 'c,d,a,b') -table.insert(t, 5, 'e') -is(table.concat(t, ','), 'c,d,a,b,e') - -if jit then - todo("LuaJIT TODO. table.insert.", 2) -end -error_like(function () table.insert(t, 7, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, -9, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, 2, 'g', 'h') end, - "^[^:]+:%d+: wrong number of arguments to 'insert'", - "function insert (too many arg)") - -if (platform and platform.compat) or jit then - t = {} - is(table.maxn(t), 0, "function maxn") - t[1] = 'a' - t[2] = 'b' - is(table.maxn(t), 2) - t[6] = 'g' - is(table.maxn(t), 6) - a = {} - a[10000] = 1 - is(table.maxn(a), 10000) -else - is(table.maxn, nil, "maxn (removed)") - skip("maxn (removed)", 3) -end - -t = table.pack("abc", "def", "ghi") -eq_array(t, { - "abc", - "def", - "ghi" -}, "function pack") -is(t.n, 3) - -t = table.pack() -eq_array(t, {}, "function pack (no element)") -is(t.n, 0) - -t = {} -a = table.remove(t) -is(a, nil, "function remove") -t = {'a','b','c','d','e'} -a = table.remove(t) -is(a, 'e') -is(table.concat(t, ','), 'a,b,c,d') -a = table.remove(t,3) -is(a, 'c') -is(table.concat(t, ','), 'a,b,d') -a = table.remove(t,1) -is(a, 'a') -is(table.concat(t, ','), 'b,d') - -if jit then - todo("LuaJIT TODO. table.remove.", 1) -end -error_like(function () table.remove(t,7) end, - "^[^:]+:%d+: bad argument #1 to 'remove' %(position out of bounds%)", - "function remove (out of bounds)") - -lines = { - luaH_set = 10, - luaH_get = 24, - luaH_present = 48, -} -a = {} -for n in pairs(lines) do a[#a + 1] = n end -table.sort(a) -output = {} -for _, n in ipairs(a) do - table.insert(output, n) -end -eq_array(output, {'luaH_get', 'luaH_present', 'luaH_set'}, "function sort") - -function pairsByKeys (t, f) - local a = {} - for n in pairs(t) do a[#a + 1] = n end - table.sort(a, f) - local i = 0 -- iterator variable - return function () -- iterator function - i = i + 1 - return a[i], t[a[i]] - end -end - -output = {} -for name, line in pairsByKeys(lines) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - -output = {} -for name, line in pairsByKeys(lines, function (a, b) return a < b end) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - - - -function permgen (a, n) - n = n or #a - if n <= 1 then - coroutine.yield(a) - else - for i=1,n do - a[n], a[i] = a[i], a[n] - permgen(a, n - 1) - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () - local code, res = coroutine.resume(co) - return res - end -end - -local t = {} -output = {} -for _, v in ipairs{'a', 'b', 'c', 'd', 'e', 'f', 'g'} do - table.insert(t, v) - local ref = table.concat(t, ' ') - table.insert(output, ref) - local n = 0 - for p in permutations(t) do - local c = {} - for i, v in ipairs(p) do - c[i] = v - end - table.sort(c) - assert(ref == table.concat(c, ' '), table.concat(p, ' ')) - n = n + 1 - end - table.insert(output, n) -end - -eq_array(output, { - 'a', 1, - 'a b', 2, - 'a b c', 6, - 'a b c d', 24, - 'a b c d e', 120, - 'a b c d e f', 720, - 'a b c d e f g', 5040, -}, "function sort (all permutations)") - ---[[ - -MoonSharp: Sort callbacks work --]] - - -error_like(function () - local t = { 1 } - table.sort( { t, t, t, t, }, function (a, b) return a[1] == b[1] end ) - end, - "^[^:]+:%d+: invalid order function for sorting", - "function sort (bad func)") - - -eq_array({table.unpack({})}, {}, "function unpack") -eq_array({table.unpack({'a'})}, {'a'}) -eq_array({table.unpack({'a','b','c'})}, {'a','b','c'}) -eq_array({(table.unpack({'a','b','c'}))}, {'a'}) -eq_array({table.unpack({'a','b','c','d','e'},2,4)}, {'b','c','d'}) -eq_array({table.unpack({'a','b','c'},2,4)}, {'b','c'}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/306-math.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/306-math.t deleted file mode 100644 index c68dac55..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/306-math.t +++ /dev/null @@ -1,153 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Mathematic Library - -=head2 Synopsis - - % prove 306-math.t - -=head2 Description - -Tests Lua Mathematic Library - -See "Lua 5.2 Reference Manual", section 6.6 "Mathematical Functions", -L. - -See "Programming in Lua", section 18 "The Mathematical Library". - -=cut - ---]] - -require 'Test.More' - -plan(47) - -like(tostring(math.pi), '^3%.14', "variable pi") - -type_ok(math.huge, 'number', "variable huge") - -is(math.abs(-12.34), 12.34, "function abs") -is(math.abs(12.34), 12.34) - -like(math.acos(0.5), '^1%.047', "function acos") - -like(math.asin(0.5), '^0%.523', "function asin") - -like(math.atan(0.5), '^0%.463', "function atan") - -like(math.atan2(1, 2), '^0%.463', "function atan2") - -is(math.ceil(12.34), 13, "function ceil") -is(math.ceil(-12.34), -12) - -like(math.cos(0), '^1$', "function cos") - -like(math.cosh(0), '^1$', "function cosh") - -is(math.deg(math.pi), 180, "function deg") - -like(math.exp(1.0), '^2%.718', "function exp") - -is(math.floor(12.34), 12, "function floor") -is(math.floor(-12.34), -13) - -is(math.fmod(7, 3), 1, "function fmod") -is(math.fmod(-7, 3), -1) - -eq_array({math.frexp(1.5)}, {0.75, 1}, "function frexp") - -is(math.ldexp(1.2, 3), 9.6, "function ldexp") - -like(math.log(47), '^3%.85', "function log") -like(math.log(47, 2), '^5%.554', "function log (base 2)") -like(math.log(47, 10), '^1%.672', "function log (base 10)") - -if (platform and platform.compat) or jit then - like(math.log10(47), '^1%.672', "function log10") -else - is(math.log10, nil, "function log10 (removed)") -end - -error_like(function () math.max() end, - "^[^:]+:%d+: bad argument #1 to 'max' %(number expected, got no value%)", - "function max 0") - -is(math.max(1), 1, "function max") -is(math.max(1, 2), 2) -is(math.max(1, 2, 3, -4), 3) - -error_like(function () math.min() end, - "^[^:]+:%d+: bad argument #1 to 'min' %(number expected, got no value%)", - "function min 0") - -is(math.min(1), 1, "function min") -is(math.min(1, 2), 1) -is(math.min(1, 2, 3, -4), -4) - -eq_array({math.modf(2.25)}, {2, 0.25}, "function modf") - -is(math.pow(-2, 3), -8, "function pow") - -like(math.rad(180), '^3%.14', "function rad") - -like(math.random(), '^%d%.%d+', "function random no arg") - -like(math.random(9), '^%d$', "function random 1 arg") - -like(math.random(10, 19), '^1%d$', "function random 2 arg") - ---[[ -MoonSharp : math.random normalizes inputs, and we are happy with that - -if jit then - todo("LuaJIT intentional. Don't check empty interval.", 2) -end -error_like(function () math.random(0) end, - "^[^:]+:%d+: bad argument #1 to 'random' %(interval is empty%)", - "function random empty interval") - -error_like(function () math.random(19, 10) end, - "^[^:]+:%d+: bad argument #2 to 'random' %(interval is empty%)", - "function random empty interval") - -if jit then - todo("LuaJIT intentional. Don't care about extra arguments.") -end -error_like(function () math.random(1, 2, 3) end, - "^[^:]+:%d+: wrong number of arguments", - "function random too many arg") - --]] - -math.randomseed(12) -a = math.random() -math.randomseed(12) -b = math.random() -is(a, b, "function randomseed") - -like(math.sin(math.pi/2), '^1$', "function sin") - -like(math.sinh(1), '^1%.175', "function sinh") - -like(math.sqrt(2), '^1%.414', "function sqrt") - -like(math.tan(math.pi/3), '^1%.732', "function tan") - -like(math.tanh(1), '^0%.761', "function sinh") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/307-bit.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/307-bit.t deleted file mode 100644 index 69487518..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/307-bit.t +++ /dev/null @@ -1,94 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Bitwise Library - -=head2 Synopsis - - % prove 307-bit.t - -=head2 Description - -Tests Lua Bitwise Library - -See "Lua 5.2 Reference Manual", section 6.7 "Bitwise operations", -L. - -=cut - ---]] - -require 'Test.More' - -if jit then - skip_all("LuaJIT. bit32") -end - -plan(20) - -is(bit32.band(0x01, 0x03, 0x07), 0x01, "function band") - -is(bit32.bnot(0x03), (-1 - 0x03) % 2^32, "function bnot") - -is(bit32.bor(0x01, 0x03, 0x07), 0x07, "function bor") - -is(bit32.btest(0x01), true, "function btest") -is(bit32.btest(0x00), false, "function btest") - -is(bit32.bxor(0x01, 0x03, 0x07), 0x05, "function bxor") - -is(bit32.lrotate(0x03, 2), 0x0C, "function lrotate") - -is(bit32.rrotate(0x06, 1), 0x03, "function rrotate") - -is(bit32.arshift(0x06, 1), 0x03, "function arshift") - -is(bit32.arshift(-3, 1), bit32.arshift(-6, 2), "function arshift") - -is(bit32.lshift(0x03, 2), 0x0C, "function lshift") - -is(bit32.rshift(0x06, 1), 0x03, "function rshift") - -is(bit32.extract(0xFFFF, 3, 3), 0x07, "function extract") - -error_like(function () bit32.extract(0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function extract (non-existent bits)") - -error_like(function () bit32.extract(0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #2 to 'extract' %(field cannot be negative%)", - "function extract (negatif field)") - -error_like(function () bit32.extract(0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #3 to 'extract' %(width must be positive%)", - "function extract (negative width)") - -is(bit32.replace(0x0000, 0xFFFF, 3, 3), 0x38, "function replace") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function replace (non-existent bits)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #3 to 'replace' %(field cannot be negative%)", - "function replace (negatif field)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #4 to 'replace' %(width must be positive%)", - "function replace (negative width)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/308-io.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/308-io.t deleted file mode 100644 index 2ca3b852..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/308-io.t +++ /dev/null @@ -1,258 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Input/Output Library - -=head2 Synopsis - - % prove 308-io.t - -=head2 Description - -Tests Lua Input/Output Library - -See "Lua 5.2 Reference Manual", section 6.8 "Input and Output Facilities", -L. - -See "Programming in Lua", section 21 "The I/O Library". - -=cut - ---]] - -require 'Test.More' - -local lua = [[\git\moonsharp\src\Tools\lua52.exe]] - -plan(67) - -like(io.stdin, '^file %(0?[Xx]?%x+%)$', "variable stdin") - -like(io.stdout, '^file %(0?[Xx]?%x+%)$', "variable stdout") - -like(io.stderr, '^file %(0?[Xx]?%x+%)$', "variable stderr") - -r, msg = io.close(io.stderr) -is(r, nil, "close (std)") -is(msg, "cannot close standard file") - -is(io.flush(), true, "function flush") - -os.remove('file.no') -f, msg = io.open("file.no") -is(f, nil, "function open") -is(msg, "file.no: No such file or directory") - -os.remove('file.txt') -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() -f = io.open('file.txt') -like(f, '^file %(0?[Xx]?%x+%)$', "function open") - - -is(io.close(f), true, "function close") - -error_like(function () io.close(f) end, - "^[^:]+:%d+: attempt to use a closed file", - "function close (closed)") - -if jit then - todo("LuaJIT TODO. open mode") -end -error_like(function () io.open('file.txt', 'baz') end, - "^[^:]+:%d+: bad argument #2 to 'open' %(invalid mode%)", - "function open (bad mode)") - - -is(io.type("not a file"), nil, "function type") -f = io.open('file.txt') -is(io.type(f), 'file') -like(tostring(f), '^file %(0?[Xx]?%x+%)$') -io.close(f) -is(io.type(f), 'closed file') -is(tostring(f), 'file (closed)') - -is(io.stdin, io.input(), "function input") -is(io.stdin, io.input(nil)) -f = io.stdin - -like(io.input('file.txt'), '^file %(0?[Xx]?%x+%)$') -is(f, io.input(f)) - -is(io.output(), io.stdout, "function output") -is(io.output(nil), io.stdout) -f = io.stdout -like(io.output('output.new'), '^file %(0?[Xx]?%x+%)$') -is(f, io.output(f)) -os.remove('output.new') - -r, f = pcall(io.popen, lua .. [[ -e "print 'standard output'"]]) -if r then - is(io.type(f), 'file', "popen (read)") - is(f:read(), "standard output") - is(io.close(f), true) -else - skip("io.popen not supported", 3) -end - -r, f = pcall(io.popen, lua .. [[ -e "for line in io.lines() do print((line:gsub('e', 'a'))) end"]], 'w') -if r then - is(io.type(f), 'file', "popen (write)") - f:write("# hello\n") -- not tested : hallo - is(io.close(f), true) -else - skip("io.popen not supported", 2) -end - -for line in io.lines('file.txt') do - is(line, "file with text", "function lines(filename)") -end - -error_like(function () io.lines('file.no') end, - "No such file or directory", - "function lines(no filename)") - -f = io.tmpfile() -is(io.type(f), 'file', "function tmpfile") -f:write("some text") -f:close() - -io.write() -- not tested -io.write('# text', 12, "\n") -- not tested : # text12 - -r, msg = io.stderr:close() -is(r, nil, "method close (std)") -is(msg, "cannot close standard file") - -f = io.open('file.txt') -is(f:close(), true, "method close") - -is(io.stderr:flush(), true, "method flush") - -error_like(function () f:flush() end, - "^[^:]+:%d+: attempt to use a closed file", - "method flush (closed)") - -error_like(function () f:read() end, - "^[^:]+:%d+: attempt to use a closed file", - "method read (closed)") - -f = io.open('file.txt') -s = f:read() -is(s:len(), 14, "method read") -is(s, "file with text") -s = f:read() -is(s, nil) -f:close() - -f = io.open('file.txt') -error_like(function () f:read('*z') end, - "^[^:]+:%d+: bad argument #1 to 'read' %(invalid %w+%)", - "method read (invalid)") -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*l', '*l') -is(s1:len(), 14, "method read *l") -is(s1, "file with text") -is(s2, nil) -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*L', '*L') -is(s1:len(), 15, "method read *L") -is(s1, "file with text\n") -is(s2, nil) -f:close() - -f = io.open('file.txt') -n1, n2 = f:read('*n', '*n') -is(n1, nil, "method read *n") -is(n2, nil) -f:close() - -f = io.open('file.txt') -s = f:read('*a') -is(s:len(), 15, "method read *a") -is(s, "file with text\n") -f:close() - -f = io.open('file.txt') -is(f:read(0), '', "method read number") -eq_array({f:read(5, 5, 15)}, {'file ', 'with ', "text\n"}) --- print(f:read(0)) -f:close() - -f = io.open('file.txt') -for line in f:lines() do - is(line, "file with text", "method lines") -end -is(io.type(f), 'file') -f:close() -is(io.type(f), 'closed file') - -f = io.open('file.txt') -for two_char in f:lines(2) do - is(two_char, "fi", "method lines (with read option)") - break -end -f:close() - -error_like(function () f:seek('end', 0) end, - "^[^:]+:%d+: attempt to use a closed file", - "method seek (closed)") - -f = io.open('file.txt') -error_like(function () f:seek('bad', 0) end, - "^[^:]+:%d+: bad argument #1 to 'seek' %(invalid option 'bad'%)", - "method seek (invalid)") - -f = io.open('file.txt') -if platform and platform.osname == 'MSWin32' then - is(f:seek('end', 0), 16, "method seek") -else - is(f:seek('end', 0), 15, "method seek") -end -f:close() - -f = io.open('file.txt') -is(f:setvbuf('no'), true, "method setvbuf 'no'") - -is(f:setvbuf('full', 4096), true, "method setvbuf 'full'") - -is(f:setvbuf('line', 132), true, "method setvbuf 'line'") -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('file.out', 'w') -f:close() -error_like(function () f:write('end') end, - "^[^:]+:%d+: attempt to use a closed file", - "method write (closed)") - -f = io.open('file.out', 'w') -is(f:write('end'), f, "method write") -f:close() - -os.remove('file.out') --clean up - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - ---]==] - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/309-os.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/309-os.t deleted file mode 100644 index c551fb7b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/309-os.t +++ /dev/null @@ -1,198 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Operating System Library - -=head2 Synopsis - - % prove 309-os.t - -=head2 Description - -Tests Lua Operating System Library - -See "Lua 5.2 Reference Manual", section 6.9 "Operating System Facilities", -L. - -See "Programming in Lua", section 22 "The Operating System Library". - -=cut - ---]] - -require 'Test.More' - -plan(54) - -local lua = "lua.exe" - -clk = os.clock() -type_ok(clk, 'number', "function clock") -ok(clk <= os.clock()) - -d = os.date('!*t', 0) -is(d.year, 1970, "function date") -is(d.month, 1) -is(d.day, 1) -is(d.hour, 0) -is(d.min, 0) -is(d.sec, 0) -is(d.wday, 5) -is(d.yday, 1) -is(d.isdst, false) - -is(os.date('!%d/%m/%y %H:%M:%S', 0), '01/01/70 00:00:00', "function date") - -like(os.date('%H:%M:%S'), '^%d%d:%d%d:%d%d', "function date") - -if jit and jit.version_num < 20100 then - todo("LuaJIT TODO. invalid strftime.", 1) -end -is(os.date('%Oy', 0), '70') -if jit then - todo("LuaJIT TODO. invalid strftime.", 1) -end - - - -error_like(function () os.date('%Ja', 0) end, - "^[^:]+:%d+: bad argument #1 to 'date' %(invalid conversion specifier '%%Ja'%)", - "function date (invalid)") - -is(os.difftime(1234, 1200), 34, "function difftime") -is(os.difftime(1234), 1234) - -r = os.execute() -is(r, true, "function execute") - -r, s, n = os.execute('__IMPROBABLE__') -is(r, nil, "function execute") -is(s, 'exit') -type_ok(n, 'number') - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(2)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 2, "exit value") - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(false)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 1, "exit value") - --- cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(true, true)"]] --- is(os.execute(cmd), true, "function execute & exit") - -cmd = lua .. [[ -e "print 'reached'; os.exit(); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - code = f:close() - is(code, true, "exit code") -else - skip("io.popen not supported", 3) -end - -cmd = lua .. [[ -e "print 'reached'; os.exit(3); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - r, s, n = f:close() - is(r, nil) - is(s, 'exit', "exit code") - is(n, 3, "exit value") -else - skip("io.popen not supported", 5) -end - -is(os.getenv('__IMPROBABLE__'), nil, "function getenv") - -user = os.getenv('LOGNAME') or os.getenv('USERNAME') -type_ok(user, 'string', "function getenv") - -local f = io.open('file.rm', 'w') -f:write("file to remove") -f:close() -r = os.remove("file.rm") -is(r, true, "function remove") - -r, msg = os.remove('file.rm') -is(r, nil, "function remove") -like(msg, '^file.rm: No such file or directory') - -local f = io.open('file.old', 'w') -f:write("file to rename") -f:close() -os.remove('file.new') -r = os.rename('file.old', 'file.new') -is(r, true, "function rename") -os.remove('file.new') -- clean up - -r, msg = os.rename('file.old', 'file.new') -is(r, nil, "function rename") -like(msg, 'No such file or directory') - ---[[ setlocale NOT supported! -is(os.setlocale('C', 'all'), 'C', "function setlocale") -is(os.setlocale(), 'C') - -is(os.setlocale('unk_loc', 'all'), nil, "function setlocale (unknown locale)") - -]] - -like(os.time(), '^%d+%.?%d*$', "function time") - -like(os.time(nil), '^%d+%.?%d*$', "function time") - -like(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 2000, - isdst = 0, -}), '^946%d+$', "function time") - -if platform and platform.intsize == 8 then - todo("pb on 64bit platforms") - -- os.time returns nil when C mktime returns < 0 - -- this test needs a out of range value on any platform -end -is(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 1000, - isdst = 0, -}), nil, "function time -> nil") - -error_like(function () os.time{} end, - "^[^:]+:%d+: field 'day' missing in date table", - "function time (missing field)") - -fname = os.tmpname() -type_ok(fname, 'string', "function tmpname") -ok(fname ~= os.tmpname()) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/310-debug.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/310-debug.t deleted file mode 100644 index 76055802..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/310-debug.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Debug Library - -=head2 Synopsis - - % prove 310-debug.t - -=head2 Description - -Tests Lua Debug Library - -See "Lua 5.2 Reference Manual", section 6.10 "The Debug Library", -L. - -See "Programming in Lua", section 23 "The Debug Library". - -=cut - -]] - -require 'Test.More' - -plan(51) - -debug = require 'debug' - -info = debug.getinfo(is) -type_ok(info, 'table', "function getinfo (function)") -is(info.func, is, " .func") - -info = debug.getinfo(is, 'L') -type_ok(info, 'table', "function getinfo (function, opt)") -type_ok(info.activelines, 'table') - -info = debug.getinfo(1) -type_ok(info, 'table', "function getinfo (level)") -like(info.func, "^function: [0]?[Xx]?%x+", " .func") - -is(debug.getinfo(12), nil, "function getinfo (too depth)") - -error_like(function () debug.getinfo('bad') end, - "bad argument #1 to 'getinfo' %(function or level expected%)", - "function getinfo (bad arg)") - -error_like(function () debug.getinfo(is, 'X') end, - "bad argument #2 to 'getinfo' %(invalid option%)", - "function getinfo (bad opt)") - -local name, value = debug.getlocal(0, 1) -type_ok(name, 'string', "function getlocal (level)") -is(value, 0) - -error_like(function () debug.getlocal(42, 1) end, - "bad argument #1 to 'getlocal' %(level out of range%)", - "function getlocal (out of range)") - -local name, value = debug.getlocal(like, 1) -type_ok(name, 'string', "function getlocal (func)") -is(value, nil) - -t = {} -is(debug.getmetatable(t), nil, "function getmetatable") -t1 = {} -debug.setmetatable(t, t1) -is(debug.getmetatable(t), t1) - -a = true -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -a = 3.14 -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -local reg = debug.getregistry() -type_ok(reg, 'table', "function getregistry") -type_ok(reg._LOADED, 'table') - -local name = debug.getupvalue(plan, 1) -type_ok(name, 'string', "function getupvalue") - -debug.sethook() -hook, mask, count = debug.gethook() -is(hook, nil, "function gethook") -is(mask, '') -is(count, 0) -local function f () end -debug.sethook(f, 'c', 42) -hook , mask, count = debug.gethook() -is(hook, f, "function gethook") -is(mask, 'c') -is(count, 42) - -co = coroutine.create(function () print "thread" end) -hook = debug.gethook(co) -if jit then - todo("LuaJIT TODO. debug.gethook(thread)", 1) -end -is(hook, nil, "function gethook(thread)") - -local name = debug.setlocal(0, 1, 0) -type_ok(name, 'string', "function setlocal (level)") - -local name = debug.setlocal(0, 42, 0) -is(name, nil, "function setlocal (level)") - -error_like(function () debug.setlocal(42, 1, true) end, - "bad argument #1 to 'setlocal' %(level out of range%)", - "function getlocal (out of range)") - -t = {} -t1 = {} -is(debug.setmetatable(t, t1), t, "function setmetatable") -is(getmetatable(t), t1) - -error_like(function () debug.setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected%)") - -local name = debug.setupvalue(plan, 1, require 'Test.Builder':new()) -type_ok(name, 'string', "function setupvalue") - -local name = debug.setupvalue(plan, 42, true) -is(name, nil) - -local u = io.tmpfile() -local old = debug.getuservalue(u) -if jit then - type_ok(old, 'table', "function getuservalue") -else - is(old, nil, "function getuservalue") -end -is(debug.getuservalue(true), nil) -local data = {} -r = debug.setuservalue(u, data) -is(r, u, "function setuservalue") -is(debug.getuservalue(u), data) -r = debug.setuservalue(u, old) -is(debug.getuservalue(u), old) - -error_like(function () debug.setuservalue({}, data) end, - "^[^:]+:%d+: bad argument #1 to 'setuservalue' %(userdata expected, got table%)") - -error_like(function () debug.setuservalue(u, true) end, - "^[^:]+:%d+: bad argument #2 to 'setuservalue' %(table expected, got boolean%)") - -like(debug.traceback(), "^stack traceback:\n", "function traceback") - -like(debug.traceback("message\n"), "^message\n\nstack traceback:\n", "function traceback with message") - -like(debug.traceback(false), "false", "function traceback") - -local id = debug.upvalueid(plan, 1) -type_ok(id, 'userdata', "function upvalueid") - -debug.upvaluejoin (pass, 1, fail, 1) - -error_like(function () debug.upvaluejoin(true, 1, nil, 1) end, - "bad argument #1 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - -error_like(function () debug.upvaluejoin(pass, 1, true, 1) end, - "bad argument #3 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/314-regex.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/314-regex.t deleted file mode 100644 index 89d89142..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/314-regex.t +++ /dev/null @@ -1,346 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Regex Compiler - -=head2 Synopsis - - % prove 314-regex.t - -=head2 Description - -Tests Lua Regex - -Individual tests are stored in the C files in the same directory; -There is one test per line: each test consists of the following -columns (separated by one *or more* tabs): - -=over 4 - -=item pattern - -The Lua regex to test. - -=item target - -The string that will be matched against the pattern. Use '' to indicate -an empty string. - -=item result - -The expected result of the match. - -=item description - -Description of the test. - -=back - -=cut - ---]] - -local test_patterns = { - [===[(a.)..(..) zzzabcdefzzz ab\tef basic match]===], - [===[(a(b(c))(d)) abcd abcd\tbc\tc\td nested match]===], - [===[((%w+)) abcd abcd\tabcd nested match]===], - [===[(a*(.)%w(%s*)) aa!b c aa!b \t!\t nested match]===], - [===[(a?).. abcd a opt]===], - [===[(A?).. abcd '' opt]===], - [===[()aa() flaaap 3\t5 empty capture]===], - [===[(.)%1 bookkeeper o backreference]===], - [===[(%w+)%s+%1 hello hello hello backreference]===], - [===[(.*)x 123x 123 repeated dot capture]===], - [===[$(%w+) $abc= abc not escaped]===], - [===[[c] abcdef c character class]===], - [===[^[a] abcdef a anchored character class]===], - [===[[^e] abcdef a negated character class]===], - [===[^[a]? abcdef a anchored optional character class]===], - [===[[^e]? abcdef a negated optional character class]===], - [===[^[^e] abcdef a anchored negated character class]===], - [===[^[^a] abcdef nil anchored negated character class]===], - [===[[b-d] abcdef b character range]===], - [===[[b-d] abxxef b character range]===], - [===[[b-d] axcxef c character range]===], - [===[[b-d] axxdef d character range]===], - [===[[b-d] axxxef nil character range]===], - [===[[^b-d] abcdef a negated character range]===], - [===[[^b-d] bbccdd nil negated character range]===], - [===[[-] ab-def - unescaped hyphen]===], - [===[[%-] ab-def - escaped hyphen]===], - [===[[%-] abcdef nil escaped hyphen]===], - [===[[^%-] ---x-- x negated escaped hyphen]===], - [===[[^%-] ------ nil negated escaped hyphen]===], - [===[[%-+] ab-def - escaped hyphen in range]===], - [===[[%-+] ab+def + escaped hyphen in range]===], - [===[[%-+] abcdef nil escaped hyphen in range]===], - [===[[+%-] ab-def - escaped hyphen in range]===], - [===[[+%-] ab+def + escaped hyphen in range]===], - [===[[+%-] abcdef nil escaped hyphen in range]===], - [===[[^%-+] ---x-- x negated escaped hyphen in range]===], - [===[[^%-+] ------ nil negated escaped hyphen in range]===], - [===[[^+%-] ---x-- x negated escaped hyphen in range]===], - [===[[^+%-] ------ nil negated escaped hyphen in range]===], - [===[["\\] \\ \ escaped backslash]===], - [===[[%]] ] ] escaped close bracket]===], - [===[[%] \\]] /malformed pattern %(missing ']'%)/ unescaped backslash (or no closing brace)]===], - [===[ab\\cd ab\092cd ab\cd literal match with backslash]===], - [===[%? ab --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Library - -=head2 Synopsis - - % prove 320-stdin.t - -=head2 Description - -Tests Lua Basic & IO Libraries with stdin - -=cut - ---]] - -require 'Test.More' - -local lua = (platform and platform.lua) or arg[-1] - -if not pcall(io.popen, lua .. [[ -e "a=1"]]) then - skip_all "io.popen not supported" -end - -plan(12) - -f = io.open('lib1.lua', 'w') -f:write[[ -function norm (x, y) - return (x^2 + y^2)^0.5 -end - -function twice (x) - return 2*x -end -]] -f:close() - -cmd = lua .. [[ -e "dofile(); n = norm(3.4, 1.0); print(twice(n))" < lib1.lua]] -f = io.popen(cmd) -like(f:read'*l', '^7%.088', "function dofile (stdin)") -f:close() - -os.remove('lib1.lua') -- clean up - -f = io.open('foo.lua', 'w') -f:write[[ -function foo (x) - return x -end -]] -f:close() - -cmd = lua .. [[ -e "f = loadfile(); print(foo); f(); print(foo('ok'))" < foo.lua]] -f = io.popen(cmd) -is(f:read'*l', 'nil', "function loadfile (stdin)") -is(f:read'*l', 'ok') -f:close() - -os.remove('foo.lua') -- clean up - -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() - -cmd = lua .. [[ -e "print(io.read'*l'); print(io.read'*l'); print(io.type(io.stdin))" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.read *l") -is(f:read'*l', 'nil') -is(f:read'*l', 'file') -f:close() - -f = io.open('number.txt', 'w') -f:write("6.0 -3.23 15e12\n") -f:write("4.3 234 1000001\n") -f:close() - -cmd = lua .. [[ -e "while true do local n1, n2, n3 = io.read('*number', '*number', '*number'); if not n1 then break end; print(math.max(n1, n2, n3)) end" < number.txt]] -f = io.popen(cmd) -is(f:read'*l', '15000000000000', "function io:read *number") -is(f:read'*l', '1000001') -f:close() - -os.remove('number.txt') -- clean up - -cmd = lua .. [[ -e "for line in io.lines() do print(line) end" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.lines") -is(f:read'*l', nil) -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('dbg.txt', 'w') -f:write("print 'ok'\n") -f:write("error 'dbg'\n") -f:write("cont\n") -f:close() - -cmd = lua .. [[ -e "debug.debug()" < dbg.txt]] -f = io.popen(cmd) -is(f:read'*l', 'ok', "function debug.debug") -is(f:read'*l', nil) -f:close() - -os.remove('dbg.txt') -- clean up - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Makefile b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Makefile deleted file mode 100644 index 7593592c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Makefile +++ /dev/null @@ -1,67 +0,0 @@ - -LUA = ../../lua-5.2.3/src/lua -LUAJIT = luajit -LUA_COVER = ../../gh-pages/lua-TestMore/lua-5.2.3/src/lua - -LUA_VERSION = $(shell $(LUA) -e "print(_VERSION)") -OSNAME = $(shell perl -MConfig -e "print Config->{osname}") -ARCHNAME = $(shell perl -MConfig -e "print Config->{archname}") -INTSIZE = $(shell perl -MConfig -e "print Config->{longsize}") - -export LUA_PATH=;;../src/?.lua -export LUA_INIT=platform = { osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -version: - @echo $(LUA_VERSION) - -harness: - prove --exec=$(LUA) *.t - -sanity: - prove --exec=$(LUA) 0*.t - -luajit: - prove --exec=$(LUAJIT) *.t - -coverage: - prove --exec=$(LUA_COVER) *.t - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA), $(LUA_VERSION)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: - -prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e '$(upload_pl)' diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/Builder.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/Builder.lua deleted file mode 100644 index 9fc87c9b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/Builder.lua +++ /dev/null @@ -1,392 +0,0 @@ - --- --- lua-TestMore : --- - -local debug = nil; -- require 'debug' -local io = nil; -- require 'io' -local os = nil; -- require 'os' -local error = error -local gsub = require 'string'.gsub -local match = require 'string'.match -local pairs = pairs -local pcall = pcall -local print = print -local rawget = rawget -local setmetatable = setmetatable -local tconcat = require 'table'.concat -local tonumber = tonumber -local tostring = tostring -local type = type - -_ENV = nil -local m = {} - -local testout = io and io.stdout -local testerr = io and (io.stderr or io.stdout) - -function m.puts (f, str) - f:write(str) -end - -local function _print_to_fh (self, f, ...) - -- if f then - -- local msg = tconcat({...}) - -- gsub(msg, "\n", "\n" .. self.indent) - -- m.puts(f, self.indent .. msg .. "\n") - -- else - print(self.indent, ...) - -- end -end - -local function _print (self, ...) - _print_to_fh(self, self:output(), ...) -end - -local function print_comment (self, f, ...) - local arg = {...} - for k, v in pairs(arg) do - arg[k] = tostring(v) - end - local msg = tconcat(arg) - msg = gsub(msg, "\n", "\n# ") - msg = gsub(msg, "\n# \n", "\n#\n") - msg = gsub(msg, "\n# $", '') - _print_to_fh(self, f, "# ", msg) -end - -function m.create () - local o = { - data = setmetatable({}, { __index = m }), - } - setmetatable(o, { - __index = function (t, k) - return rawget(t, 'data')[k] - end, - __newindex = function (t, k, v) - rawget(o, 'data')[k] = v - end, - }) - o:reset() - return o -end - -local test -function m.new () - test = test or m.create() - return test -end - -local function in_todo (self) - return self.todo_upto >= self.curr_test -end - -function m:child (name) - if self.child_name then - error("You already have a child named (" .. self.child_name .. " running") - end - local child = m.create() - child.indent = self.indent .. ' ' - child.out_file = self.out_file - child.fail_file = in_todo(self) and self.todo_file or self.fail_file - child.todo_file = self.todo_file - child.parent = self - self.child_name = name - return child -end - -local function plan_handled (self) - return self.have_plan or self.no_plan or self._skip_all -end - -function m:subtest (name, func) - if type(func) ~= 'function' then - error("subtest()'s second argument must be a function") - end - self:diag('Subtest: ' .. name) - local child = self:child(name) - local parent = self.data - self.data = child.data - local r, msg = pcall(func) - child.data = self.data - self.data = parent - if not r and not child._skip_all then - error(msg, 0) - end - if not plan_handled(child) then - child:done_testing() - end - child:finalize() -end - -function m:finalize () - if not self.parent then - return - end - if self.child_name then - error("Can't call finalize() with child (" .. self.child_name .. " active") - end - local parent = self.parent - local name = parent.child_name - parent.child_name = nil - if self._skip_all then - parent:skip(self._skip_all) - elseif self.curr_test == 0 then - parent:ok(false, "No tests run for subtest \"" .. name .. "\"", 2) - else - parent:ok(self.is_passing, name, 2) - end - self.parent = nil -end - -function m:reset () - self.curr_test = 0 - self._done_testing = false - self.expected_tests = 0 - self.is_passing = true - self.todo_upto = -1 - self.todo_reason = nil - self.have_plan = false - self.no_plan = false - self._skip_all = false - self.have_output_plan = false - self.indent = '' - self.parent = false - self.child_name = false - self:reset_outputs() -end - -local function _output_plan (self, max, directive, reason) - if self.have_output_plan then - error("The plan was already output") - end - local out = "1.." .. max - if directive then - out = out .. " # " .. directive - end - if reason then - out = out .. " " .. reason - end - _print(self, out) - self.have_output_plan = true -end - -function m:plan (arg) - if self.have_plan then - error("You tried to plan twice") - end - if type(arg) == 'string' and arg == 'no_plan' then - self.have_plan = true - self.no_plan = true - return true - elseif type(arg) ~= 'number' then - error("Need a number of tests") - elseif arg < 0 then - error("Number of tests must be a positive integer. You gave it '" .. arg .."'.") - else - self.expected_tests = arg - self.have_plan = true - _output_plan(self, arg) - return arg - end -end - -function m:done_testing (num_tests) - if num_tests then - self.no_plan = false - end - num_tests = num_tests or self.curr_test - if self._done_testing then - tb:ok(false, "done_testing() was already called") - return - end - self._done_testing = true - if self.expected_tests > 0 and num_tests ~= self.expected_tests then - self:ok(false, "planned to run " .. self.expected_tests - .. " but done_testing() expects " .. num_tests) - else - self.expected_tests = num_tests - end - if not self.have_output_plan then - _output_plan(self, num_tests) - end - self.have_plan = true - -- The wrong number of tests were run - if self.expected_tests ~= self.curr_test then - self.is_passing = false - end - -- No tests were run - if self.curr_test == 0 then - self.is_passing = false - end -end - -function m:has_plan () - if self.expected_tests > 0 then - return self.expected_tests - end - if self.no_plan then - return 'no_plan' - end - return nil -end - -function m:skip_all (reason) - if self.have_plan then - error("You tried to plan twice") - end - self._skip_all = reason - _output_plan(self, 0, 'SKIP', reason) - if self.parent then - error("skip_all in child", 0) - end - -- os.exit(0) -end - -local function _check_is_passing_plan (self) - local plan = self:has_plan() - if not plan or not tonumber(plan) then - return - end - if plan < self.curr_test then - self.is_passing = false - end -end - -function m:ok (test, name, level) - if self.child_name then - name = name or 'unnamed test' - self.is_passing = false - error("Cannot run test (" .. name .. ") with active children") - end - name = name or '' - level = level or 0 - self.curr_test = self.curr_test + 1 - name = tostring(name) - if match(name, '^[%d%s]+$') then - self:diag(" You named your test '" .. name .."'. You shouldn't use numbers for your test names." - .. "\n Very confusing.") - end - local out = '' - if not test then - out = "not " - end - out = out .. "ok " .. self.curr_test - if name ~= '' then - out = out .. " - " .. name - end - if self.todo_reason and in_todo(self) then - out = out .. " # TODO " .. self.todo_reason - end - _print(self, out) - if not test then - local msg = in_todo(self) and "Failed (TODO)" or "Failed" - local info = debug and debug.getinfo(3 + level) - if info then - local file = info.short_src - local line = info.currentline - self:diag(" " .. msg .. " test (" .. file .. " at line " .. line .. ")") - else - self:diag(" " .. msg .. " test") - end - end - if not test and not in_todo(self) then - self.is_passing = false - end - _check_is_passing_plan(self) -end - -function m:BAIL_OUT (reason) - local out = "Bail out!" - if reason then - out = out .. " " .. reason - end - _print(self, out) - os.exit(255) -end - -function m:current_test (num) - if num then - self.curr_test = num - end - return self.curr_test -end - -function m:todo (reason, count) - count = count or 1 - self.todo_upto = self.curr_test + count - self.todo_reason = reason -end - -function m:skip (reason) - local name = "# skip" - if reason then - name = name .. " " .. reason - end - self:ok(true, name, 1) -end - -function m:todo_skip (reason) - local name = "# TODO & SKIP" - if reason then - name = name .. " " .. reason - end - self:ok(false, name, 1) -end - -function m:skip_rest (reason) - for i = self.curr_test, self.expected_tests do - tb:skip(reason) - end -end - -local function diag_file (self) - if in_todo(self) then - return self:todo_output() - else - return self:failure_output() - end -end - -function m:diag (...) - print_comment(self, diag_file(self), ...) -end - -function m:note (...) - print_comment(self, self:output(), ...) -end - -function m:output (f) - if f then - self.out_file = f - end - return self.out_file -end - -function m:failure_output (f) - if f then - self.fail_file = f - end - return self.fail_file -end - -function m:todo_output (f) - if f then - self.todo_file = f - end - return self.todo_file -end - -function m:reset_outputs () - self:output(testout) - self:failure_output(testerr) - self:todo_output(testout) -end - -return m --- --- Copyright (c) 2009-2012 Francois Perrad --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/More.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/More.lua deleted file mode 100644 index 9f417ca4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/Modules/Test/More.lua +++ /dev/null @@ -1,383 +0,0 @@ - --- --- lua-TestMore : --- - -local loadstring = loadstring or load -local pairs = pairs -local pcall = pcall -local require = require -local tostring = tostring -local type = type -local match = require 'string'.match -local unpack = require 'table'.unpack or unpack -local _G = _G - -local tb = require 'Test.Builder'.new() - -_ENV = nil -local m = {} - -function m.plan (arg) - tb:plan(arg) -end - -function m.done_testing (num_tests) - tb:done_testing(num_tests) -end - -function m.skip_all (reason) - tb:skip_all(reason) -end - -function m.BAIL_OUT (reason) - tb:BAIL_OUT(reason) -end - -function m.ok (test, name) - tb:ok(test, name) -end - -function m.nok (test, name) - tb:ok(not test, name) -end - -function m.is (got, expected, name) - local pass = got == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: " .. tostring(expected)) - end -end - -function m.isnt (got, expected, name) - local pass = got ~= expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: anything else") - end -end - -function m.like (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end -end - -function m.unlike (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = not match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n matches '" .. pattern .. "'") - end -end - -local cmp = { - ['<'] = function (a, b) return a < b end, - ['<='] = function (a, b) return a <= b end, - ['>'] = function (a, b) return a > b end, - ['>='] = function (a, b) return a >= b end, - ['=='] = function (a, b) return a == b end, - ['~='] = function (a, b) return a ~= b end, -} - -function m.cmp_ok (this, op, that, name) - local f = cmp[op] - if not f then - tb:ok(false, name) - tb:diag("unknown operator : " .. tostring(op)) - return - end - local pass = f(this, that) - tb:ok(pass, name) - if not pass then - tb:diag(" " .. tostring(this) - .. "\n " .. op - .. "\n " .. tostring(that)) - end -end - -function m.type_ok (val, t, name) - if type(t) ~= 'string' then - tb:ok(false, name) - tb:diag("type isn't a string : " .. tostring(t)) - return - end - if type(val) == t then - tb:ok(true, name) - else - tb:ok(false, name) - tb:diag(" " .. tostring(val) .. " isn't a '" .. t .."' it's a '" .. type(val) .. "'") - end -end - -function m.subtest (name, func) - tb:subtest(name, func) -end - -function m.pass (name) - tb:ok(true, name) -end - -function m.fail (name) - tb:ok(false, name) -end - -function m.require_ok (mod) - local r, msg = pcall(require, mod) - tb:ok(r, "require '" .. tostring(mod) .. "'") - if not r then - tb:diag(" " .. msg) - end - return r -end - -function m.eq_array (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - for i = 1, #expected do - local v = expected[i] - local val = got[i] - if val ~= v then - tb:ok(false, name) - tb:diag(" at index: " .. tostring(i) - .. "\n got: " .. tostring(val) - .. "\n expected: " .. tostring(v)) - return - end - end - local extra = #got - #expected - if extra ~= 0 then - tb:ok(false, name) - tb:diag(" " .. tostring(extra) .. " unexpected item(s)") - else - tb:ok(true, name) - end -end - -function m.is_deeply (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - local msg1 - local msg2 - local seen = {} - - local function deep_eq (t1, t2, key_path) - if t1 == t2 or seen[t1] then - return true - end - seen[t1] = true - for k, v2 in pairs(t2) do - local v1 = t1[k] - if type(v1) == 'table' and type(v2) == 'table' then - local r = deep_eq(v1, v2, key_path .. "." .. tostring(k)) - if not r then - return false - end - else - if v1 ~= v2 then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(v1) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - end - for k in pairs(t1) do - local v2 = t2[k] - if v2 == nil then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(t1[k]) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - return true - end -- deep_eq - - local pass = deep_eq(got, expected, '') - tb:ok(pass, name) - if not pass then - tb:diag(" Tables begin differing at:") - tb:diag(" " .. msg1) - tb:diag(" " .. msg2) - end -end - -function m.error_is (code, arg2, arg3, arg4) - local params, expected, name - if type(arg2) == 'table' then - params = arg2 - expected = arg3 - name = arg4 - else - params = {} - expected = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(expected)) - else - local pass = msg == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. msg - .. "\n expected: " .. tostring(expected)) - end - end -end - -function m.error_like (code, arg2, arg3, arg4) - local params, pattern, name - if type(arg2) == 'table' then - params = arg2 - pattern = arg3 - name = arg4 - else - params = {} - pattern = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(pattern)) - else - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - local pass = match(msg, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. msg .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end - end -end - -function m.lives_ok (code, arg2, arg3) - local params, name - if type(arg2) == 'table' then - params = arg2 - name = arg3 - else - params = {} - name = arg2 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - tb:ok(r, name) - if not r then - tb:diag(" " .. msg) - end -end - -function m.diag (msg) - tb:diag(msg) -end - -function m.note (msg) - tb:note(msg) -end - -function m.skip (reason, count) - count = count or 1 - for i = 1, count do - tb:skip(reason) - end -end - -function m.todo_skip (reason, count) - count = count or 1 - for i = 1, count do - tb:todo_skip(reason) - end -end - -function m.skip_rest (reason) - tb:skip_rest(reason) -end - -function m.todo (reason, count) - tb:todo(reason, count) -end - -for k, v in pairs(m) do -- injection - _G[k] = v -end - -m._VERSION = "0.3.1" -m._DESCRIPTION = "lua-TestMore : an Unit Testing Framework" -m._COPYRIGHT = "Copyright (c) 2009-2012 Francois Perrad" -return m --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/makefile.mak b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/makefile.mak deleted file mode 100644 index e593ef85..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/makefile.mak +++ /dev/null @@ -1,68 +0,0 @@ -# nmake /F makefile.mak - -LUAJIT = luajit.exe -LUA = lua.exe -LUAC = luac.exe - -RUN_LUA = $(LUA) -RUN_LUAC = $(LUAC) -OSNAME = MSWin32 -ARCHNAME = MSWin32-x86-multi-thread -INTSIZE = 4 - -harness: env - @prove --exec=$(LUA) *.t - -sanity: env - @prove --exec=$(LUA) 0*.t - -luajit: env - @prove --exec=$(LUAJIT) *.t - -llvm-lua: env - @prove --exec=$(LLVM_LUA) *.t - -env: - @set LUA_PATH=;;../src/?.lua - @set LUA_INIT=platform = { lua=[[$(RUN_LUA)]], luac=[[$(RUN_LUAC)]], osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/public_projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/public_projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: env - -@prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e "$(upload_pl)" - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/_NUnitWrapper.cs b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/_NUnitWrapper.cs deleted file mode 100644 index df8ff7ca..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/_NUnitWrapper.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NUnit.Framework -{ - class _NUnitWrapper - { - } -} diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/MoonSharp.Interpreter.Tests.net40-client.csproj b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/MoonSharp.Interpreter.Tests.net40-client.csproj deleted file mode 100644 index 18489fdf..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/MoonSharp.Interpreter.Tests.net40-client.csproj +++ /dev/null @@ -1,376 +0,0 @@ - - - - Debug - AnyCPU - {4E54A863-7B53-4914-B9E0-C2172DE9DF72} - Library - Properties - MoonSharp.Interpreter.Tests.net40_client - MoonSharp.Interpreter.Tests.net40-client - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - true - ..\..\..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG;HASDYNAMIC - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;HASDYNAMIC - prompt - 4 - - - true - bin\Dev\ - TRACE;DEBUG;HASDYNAMIC - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG;HASDYNAMIC - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - - 3.5 - - - - - - - - - - - - - - - - - EmbeddableNUnitWrapper.cs - - - BinaryDumpTests.cs - - - ClosureTests.cs - - - CollectionsBaseInterfGenRegisteredTests.cs - - - CollectionsBaseGenRegisteredTests.cs - - - CollectionsRegisteredTests.cs - - - ConfigPropertyAssignerTests.cs - - - CoroutineTests.cs - - - DynamicTests.cs - - - ErrorHandlingTests.cs - - - GotoTests.cs - - - JsonSerializationTests.cs - - - LuaTestSuiteExtract.cs - - - Code - MetatableTests.cs - - - ProxyObjectsTests.cs - - - StringLibTests.cs - - - StructAssignmentTechnique.cs - - - TailCallTests.cs - - - UserDataEventsTests.cs - - - UserDataEnumsTest.cs - - - UserDataNestedTypesTests.cs - - - VarargsTupleTests.cs - - - VtUserDataPropertiesTests.cs - - - VtUserDataOverloadsTests.cs - - - VtUserDataMethodsTests.cs - - - VtUserDataMetaTests.cs - - - VtUserDataIndexerTests.cs - - - VtUserDataFieldsTests.cs - - - UserDataMetaTests.cs - - - UserDataIndexerTests.cs - - - UserDataMethodsTests.cs - - - UserDataOverloadsTests.cs - - - UserDataFieldsTests.cs - - - Code - UserDataPropertiesTests.cs - - - Utils.cs - - - AssemblyInfo.cs - - - SimpleTests.cs - - - TableTests.cs - - - TapRunner.cs - - - TestMoreTests.cs - - - TestRunner.cs - - - BinDumpStreamTests.cs - - - FastStackTests.cs - - - InteropTests.cs - - - _Hardwired.cs - - - - - {88d2880c-a863-4b16-abef-f67bd1e98bd1} - MoonSharp.Interpreter.net40-client - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/Properties/AssemblyInfo.cs deleted file mode 100644 index c81e3069..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter.Tests.net40-client")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.Tests.net40-client")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e38b2794-2a3e-42a2-bc24-ce2f1b119dc3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/000-sanity.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/000-sanity.t deleted file mode 100644 index e2de2368..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/000-sanity.t +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua test suite - -=head2 Synopsis - - % prove 000-sanity.t - -=head2 Description - -=cut - -]] - -function f (n) - return n + 1 -end - -function g (m, p) - return m + p -end - -print('1..9') -print("ok 1 -") -print('ok', 2, "- list") -print("ok " .. 3 .. " - concatenation") -i = 4 -print("ok " .. i .. " - var") -i = i + 1 -print("ok " .. i .. " - var incr") -print("ok " .. i+1 .. " - expr") -j = f(i + 1) -print("ok " .. j .. " - call f") -k = g(i, 3) -print("ok " .. k .. " - call g") -local print = print -print("ok 9 - local") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/001-if.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/001-if.t deleted file mode 100644 index b32c4bd7..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/001-if.t +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua if statement - -=head2 Synopsis - - % prove 001-if.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..6") - -if true then - print("ok 1") -else - print("not ok 1") -end - -if not true then - print("not ok 2") -else - print("ok 2") -end - -a = 12 -b = 34 -if a < b then - print("ok 3") -else - print("not ok 3") -end - -a = 0 -b = 4 -if a < b then - print("ok 4") -elseif a == b then - print("not ok 4") -else - print("not ok 4") -end - -a = 5 -b = 5 -if a < b then - print("not ok 5") -elseif a == b then - print("ok 5") -else - print("not ok 5") -end - -a = 10 -b = 6 -if a < b then - print("not ok 6") -elseif a == b then - print("not ok 6") -else - print("ok 6") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/002-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/002-table.t deleted file mode 100644 index acf3bb28..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/002-table.t +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table - -=head2 Synopsis - - % prove 002-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - -]] - -print("1..8") - -a = {"ok 1", "ok 2", "ok 3"} -print(a[1]) -i = 2 -print(a[i]) -print(a[i+1]) -if #a == 3 then - print("ok 4 - len") -else - print("not ok 4") -end -if a[7] == nil then - print("ok 5") -else - print("not ok 5") -end - -t = {a=10, b=100} -if t['a'] == 10 then - print("ok 6") -else - print("not ok 6") -end -if t.b == 100 then - print("ok 7") -else - print("not ok 7") -end -if t.z == nil then - print("ok 8") -else - print("not ok 8") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/011-while.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/011-while.t deleted file mode 100644 index 0c5791d9..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/011-while.t +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua while statement - -=head2 Synopsis - - % prove 011-while.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..11") - -a = {} -local i = 1 -while a[i] do - i = i + 1 -end -if i == 1 then - print("ok 1 - while empty") -else - print("not ok 1 - " .. i) -end - -a = {"ok 2 - while ", "ok 3", "ok 4"} -local i = 1 -while a[i] do - print(a[i]) - i = i + 1 -end - -a = {"ok 5 - with break", "ok 6", "stop", "more"} -local i = 1 -while a[i] do - if a[i] == 'stop' then break end - print(a[i]) - i = i + 1 -end -if i == 3 then - print("ok 7 - break") -else - print("not ok 7 - " .. i) -end - -x = 3 -local i = 1 -while i<=x do - print("ok " .. 7+i) - i = i + 1 -end -if i == 4 then - print("ok 11") -else - print("not ok 11 - " .. i) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/012-repeat.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/012-repeat.t deleted file mode 100644 index 54893b1c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/012-repeat.t +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua repeat statement - -=head2 Synopsis - - % prove 012-repeat.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..8") - -a = {"ok 1 - repeat", "ok 2", "ok 3"} -local i = 0 -repeat - i = i + 1 - if a[i] then - print(a[i]) - end -until not a[i] -if i == 4 then - print("ok 4") -else - print("not ok 4 - " .. i) -end - -a = {"ok 5 - with break", "ok 6", 'stop', 'more'} -local i = 0 -repeat - i = i + 1 - if a[i] == 'stop' then break end - print(a[i]) -until not a[i] -if a[i] == 'stop' then - print("ok 7 - break") -else - print("not ok 7 - " .. a[i]) -end - -function f () return true end - -local i = 1 -repeat - local v = f() - if i == 1 then - print("ok 8 - scope") - else - print("not ok") - break - end - i = i + 1 -until v - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/014-fornum.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/014-fornum.t deleted file mode 100644 index 1cf3e61b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/014-fornum.t +++ /dev/null @@ -1,136 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 014-fornum.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..36") - -for i = 1, 10, 2 do - print("ok " .. (i+1)/2 .. " - for 1, 10, 2") -end - -for i = 1, 10, 2 do - function f () - print("ok " .. (i+11)/2 .. " - for 1, 10, 2 lex") - end - f() -end - -function f (i) - print("ok " .. (i+21)/2 .. " - for 1, 10, 2 !lex") -end -for i = 1, 10, 2 do - f(i) -end - -for i = 3, 5 do - print("ok " .. 13+i .. " - for 3, 5") - i = i + 1 -end - -for i = 5, 1, -1 do - print("ok " .. 24-i .. " - for 5, 1, -1") -end - -for i = 5, 5 do - print("ok " .. 19+i .. " - for 5, 5") -end - -for i = 5, 5, -1 do - print("ok " .. 20+i .. " - for 5, 5, -1") -end - -v = false -for i = 5, 3 do - v = true -end -if v then - print("not ok 26 - for 5, 3") -else - print("ok 26 - for 5, 3") -end - -v = false -for i = 5, 7, -1 do - v = true -end -if v then - print("not ok 27 - for 5, 7, -1") -else - print("ok 27 - for 5, 7, -1") -end - -v = false -for i = 5, 7, 0 do - v = true - break -- avoid infinite loop with luajit -end -if jit then - print("not ok 28 - for 5, 7, 0 # TODO # LuaJIT intentional.") -elseif v then - print("not ok 28 - for 5, 7, 0") -else - print("ok 28 - for 5, 7, 0") -end - -v = nil -for i = 1, 10, 2 do - if i > 4 then break end - print("ok " .. (i+57)/2 .. " - for break") - v = i -end -if v == 3 then - print("ok 31 - break") -else - print("not ok 31 - " .. v) -end - -local function first() return 1 end -local function limit() return 8 end -local function step() return 2 end -for i = first(), limit(), step() do - print("ok " .. (i+63)/2 .. " - with functions") -end - -local a = {} -for i = 1, 10 do - a[i] = function () return i end -end -local v = a[5]() -if v == 5 then - print("ok 36 - for & upval") -else - print("not ok 36 - for & upval") - print("#", v) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/015-forlist.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/015-forlist.t deleted file mode 100644 index 11aaf992..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/015-forlist.t +++ /dev/null @@ -1,99 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 015-forlist.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..18") - -a = {"ok 1 - for ipairs", "ok 2 - for ipairs", "ok 3 - for ipairs"} -for _, v in ipairs(a) do - print(v) -end -for i, v in ipairs(a) do - print("ok " .. 3+i .. " - for ipairs") -end - -r = false -t = {a=10, b=100} -for i, v in ipairs(t) do - print(i, v) - r = true -end -if r then - print("not ok 7 - for ipairs (hash)") -else - print("ok 7 - for ipairs (hash)") -end - -for k in pairs(a) do - print("ok " .. 7+k .. " - for pairs") -end - -local i = 1 -for k in pairs(t) do - if k == 'a' or k == 'b' then - print("ok " .. 10+i .. " - for pairs (hash)") - else - print("not ok " .. 10+i .. " - " .. k) - end - i = i + 1 -end - -a = {"ok 13 - for break", "ok 14 - for break", "stop", "more"} -local i -for _, v in ipairs(a) do - if v == "stop" then break end - print(v) - i = _ -end -if i == 2 then - print("ok 15 - break") -else - print("not ok 15 - " .. i) -end - -local a = {"ok 16 - for & upval", "ok 17 - for & upval", "ok 18 - for & upval"} -local b = {} -for i, v in ipairs(a) do - b[i] = function () return v end -end -for i, v in ipairs(a) do - local r = b[i]() - if r == a[i] then - print(r) - else - print("not " .. a[i]) - print("#", r) - end -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/101-boolean.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/101-boolean.t deleted file mode 100644 index 403f4766..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/101-boolean.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua boolean & coercion - -=head2 Synopsis - - % prove 101-boolean.t - -=head2 Description - -=cut - -]] - -require 'Test.More' - -plan(24) - -error_like(function () return -true end, - "^[^:]+:%d+: attempt to perform arithmetic on a %w+ value", - "-true") - -error_like(function () return #true end, - "^[^:]+:%d+: attempt to get length of a boolean value", - "#true") - -is(not false, true, "not false") - -error_like(function () return true + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true + 10") - -error_like(function () return true - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true - 2") - -error_like(function () return true * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true * 3.14") - -error_like(function () return true / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true / -7") - -error_like(function () return true % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true % 4") - -error_like(function () return true ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true ^ 3") - -error_like(function () return true .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "true .. 'end'") - -is(true == true, true, "true == true") - -is(true ~= false, true, "true ~= false") - -is(true == 1, false, "true == 1") - -is(true ~= 1, true, "true ~= 1") - -error_like(function () return true < false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true < false") - -error_like(function () return true <= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true <= false") - -error_like(function () return true > false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true > false") - -error_like(function () return true >= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true >= false") - -error_like(function () return true < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true < 0") - -error_like(function () return true <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true <= 0") - -error_like(function () return true > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true > 0") - -error_like(function () return true >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true >= 0") - -error_like(function () a = true; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = true; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/102-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/102-function.t deleted file mode 100644 index 46ab7108..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/102-function.t +++ /dev/null @@ -1,199 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua function & coercion - -=head2 Synopsis - - % prove 102-function.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -f = function () return 1 end - -error_like(function () return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-f") - -error_like(function () f = print; return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return #f end, - "^[^:]+:%d+: attempt to get length of", - "#f") - -error_like(function () f = print; return #f end, - "^[^:]+:%d+: attempt to get length of") - -is(not f, false, "not f") - -is(not print, false) - -error_like(function () return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f + 10") - -error_like(function () f = print; return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f - 2") - -error_like(function () f = print; return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f * 3.14") - -error_like(function () f = print; return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f / -7") - -error_like(function () f = print; return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f % 4") - -error_like(function () f = print; return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f ^ 3") - -error_like(function () f = print; return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "f .. 'end'") - -error_like(function () f = print; return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate") - -g = f -is(f == g, true, "f == f") - -g = print -is(g == print, true) - -g = function () return 2 end -is(f ~= g, true, "f ~= g") -h = type -is(f ~= h, true) - -is(print ~= g, true) -is(print ~= h, true) - -is(f == 1, false, "f == 1") - -is(print == 1, false) - -is(f ~= 1, true, "f ~= 1") - -is(print ~= 1, true) - -error_like(function () return f < g end, - "^[^:]+:%d+: attempt to compare two function values", - "f < g") - -error_like(function () f = print; g = type; return f < g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f <= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f <= g") - -error_like(function () f = print; g = type; return f <= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f > g end, - "^[^:]+:%d+: attempt to compare two function values", - "f > g") - -error_like(function () f = print; g = type; return f > g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f >= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f >= g") - -error_like(function () f = print; g = type; return f >= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f < 0") - -error_like(function () f = print; return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f <= 0") - -error_like(function () f = print; return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f > 0") - -error_like(function () f = print; return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f >= 0") - -error_like(function () f = print; return f >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () a = f; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; b = a[1]; end, - "^[^:]+:%d+: attempt to index") - -error_like(function () a = f; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; a[1] = 1; end, - "^[^:]+:%d+: attempt to index") - -t = {} -t[print] = true -ok(t[print]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/103-nil.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/103-nil.t deleted file mode 100644 index 904970c6..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/103-nil.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua nil & coercion - -=head2 Synopsis - - % prove 103-nil.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(24) - -error_like(function () return -nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "-nil") - -error_like(function () return #nil end, - "^[^:]+:%d+: attempt to get length of a nil value", - "#nil") - -is(not nil, true, "not nil") - -error_like(function () return nil + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil + 10") - -error_like(function () return nil - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil - 2") - -error_like(function () return nil * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil * 3.14") - -error_like(function () return nil / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil / -7") - -error_like(function () return nil % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil % 4") - -error_like(function () return nil ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil ^ 3") - -error_like(function () return nil .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a nil value", - "nil .. 'end'") - -is(nil == nil, true, "nil == nil") - -is(nil ~= nil, false, "nil ~= nil") - -is(nil == 1, false, "nil == 1") - -is(nil ~= 1, true, "nil ~= 1") - -error_like(function () return nil < nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil < nil") - -error_like(function () return nil <= nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil <= nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil > nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil >= nil") - -error_like(function () return nil < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil < 0") - -error_like(function () return nil <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil <= 0") - -error_like(function () return nil > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil > 0") - -error_like(function () return nil >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil >= 0") - -error_like(function () a = nil; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = nil; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/104-number.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/104-number.t deleted file mode 100644 index 32ea3c3e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/104-number.t +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua number & coercion - -=head2 Synopsis - - % prove 104-number.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(54) - -is(-1, -(1), "-1") - -error_like(function () return #1 end, - "^[^:]+:%d+: attempt to get length of a number value", - "#1") - -is(not 1, false, "not 1") - -is(10 + 2, 12, "10 + 2") - -is(2 - 10, -8, "2 - 10") - -is(3.14 * 1, 3.14, "3.14 * 1") - -is(-7 / 0.5, -14, "-7 / 0.5") - -type_ok(1 / 0, 'number', "1 / 0") - -is(-25 % 3, 2, "-25 % 3") - -type_ok(1 % 0, 'number', "1 % 0") - -error_like(function () return 10 + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "10 + true") - -error_like(function () return 2 - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "2 - nil") - -error_like(function () return 3.14 * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3.14 * false") - -error_like(function () return -7 / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "-7 / {}") - -error_like(function () return 3 ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3 ^ true") - -error_like(function () return -25 % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "-25 % false") - -error_like(function () return 10 + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "10 + 'text'") - -error_like(function () return 2 - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "2 - 'text'") - -error_like(function () return 3.14 * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3.14 * 'text'") - -error_like(function () return -7 / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "-7 / 'text'") - -error_like(function () return 25 % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "25 % 'text'") - -error_like(function () return 3 ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3 ^ 'text'") - -is(10 + '2', 12, "10 + '2'") - -is(2 - '10', -8, "2 - '10'") - -is(3.14 * '1', 3.14, "3.14 * '1'") - -is(-7 / '0.5', -14, "-7 / '0.5'") - -is(-25 % '3', 2, "-25 % '3'") - -is(3 ^ '3', 27, "3 ^ '3'") - -is(1 .. 'end', '1end', "1 .. 'end'") - -is(1 .. 2, '12', "1 .. 2") - -error_like(function () return 1 .. true end, - "^[^:]+:%d+: attempt to concatenate a %w+ value", - "1 .. true") - -is(1.0 == 1, true, "1.0 == 1") - -is(1 ~= 2, true, "1 ~= 2") - -is(1 == true, false, "1 == true") - -is(1 ~= nil, true, "1 ~= nil") - -is(1 == '1', false, "1 == '1'") - -is(1 ~= '1', true, "1 ~= '1'") - -is(1 < 0, false, "1 < 0") - -is(1 <= 0, false, "1 <= 0") - -is(1 > 0, true, "1 > 0") - -is(1 >= 0, true, "1 >= 0") - -error_like(function () return 1 < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < false") - -error_like(function () return 1 <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= nil") - -error_like(function () return 1 > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > true") - -error_like(function () return 1 >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= {}") - -error_like(function () return 1 < '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < '0'") - -error_like(function () return 1 <= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= '0'") - -error_like(function () return 1 > '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > '0'") - -error_like(function () return 1 >= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= '0'") - -is(tostring(1000000000), '1000000000', "number 1000000000") - -is(tostring(1e9), '1000000000', "number 1e9") - -is(tostring(1.0e+9), '1000000000', "number 1.0e+9") - -error_like(function () a= 3.14; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = 3.14; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/105-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/105-string.t deleted file mode 100644 index 3162bb74..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/105-string.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua string & coercion - -=head2 Synopsis - - % prove 105-string.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -is(- '1', -1, "-'1'") - -error_like(function () return - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on .- string value", - "-'text'") - -is(# 'text', 4, "#'text'") - -is(not 'text', false, "not 'text'") - -is('10' + 2, 12, "'10' + 2") - -is('2' - 10, -8, "'2' - 10") - -is('3.14' * 1, 3.14, "'3.14' * 1") - -is('-7' / 0.5, -14, "'-7' / 0.5") - -is('-25' % 3, 2, "'-25' % 3") - -is('3' ^ 3, 27, "'3' ^ 3") - -error_like(function () return '10' + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'10' + true") - -error_like(function () return '2' - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "'2' - nil") - -error_like(function () return '3.14' * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3.14' * false") - -error_like(function () return '-7' / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "'-7' / {}") - -error_like(function () return '-25' % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'-25' % false") - -error_like(function () return '3' ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3' ^ true") - -error_like(function () return '10' + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'10' + 'text'") - -error_like(function () return '2' - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'2' - 'text'") - -error_like(function () return '3.14' * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3.14' * 'text'") - -error_like(function () return '-7' / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-7' / 'text'") - -error_like(function () return '-25' % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-25' % 'text'") - -error_like(function () return '3' ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3' ^ 'text'") - -is('10' + '2', 12, "'10' + '2'") - -is('2' - '10', -8, "'2' - '10'") - -is('3.14' * '1', 3.14, "'3.14' * '1'") - -is('-7' / '0.5', -14, "'-7' / '0.5'") - -is('-25' % '3', 2, "'-25' % '3'") - -is('3' ^ '3', 27, "'3' ^ '3'") - -is('1' .. 'end', '1end', "'1' .. 'end'") - -is('1' .. 2, '12', "'1' .. 2") - -error_like(function () return '1' .. true end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "'1' .. true") - -is('1.0' == '1', false, "'1.0' == '1'") - -is('1' ~= '2', true, "'1' ~= '2'") - -is('1' == true, false, "'1' == true") - -is('1' ~= nil, true, "'1' ~= nil") - -is('1' == 1, false, "'1' == 1") - -is('1' ~= 1, true, "'1' ~= 1") - -is('1' < '0', false, "'1' < '0'") - -is('1' <= '0', false, "'1' <= '0'") - -is('1' > '0', true, "'1' > '0'") - -is('1' >= '0', true, "'1' >= '0'") - -error_like(function () return '1' < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < false") - -error_like(function () return '1' <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= nil") - -error_like(function () return '1' > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > true") - -error_like(function () return '1' >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >= {}") - -error_like(function () return '1' < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < 0") - -error_like(function () return '1' <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >== 0") - -a = 'text' -is(a[1], nil, "index") - -error_like(function () a = 'text'; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/106-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/106-table.t deleted file mode 100644 index 20725fb5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/106-table.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table & coercion - -=head2 Synopsis - - % prove 106-table.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(28) - -error_like(function () return -{} end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-{}") - -is(# {}, 0, "#{}") -is(# {4,5,6}, 3) - -is(not {}, false, "not {}") - -error_like(function () return {} + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} + 10") - -error_like(function () return {} - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} - 2") - -error_like(function () return {} * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} * 3.14") - -error_like(function () return {} / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} / 7") - -error_like(function () return {} % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} % 4") - -error_like(function () return {} ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} ^ 3") - -error_like(function () return {} .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "{} .. 'end'") - -is({} == {}, false, "{} == {}") - -t1 = {} -t2 = {} -is(t1 == t1, true, "t1 == t1") -is(t1 == t2, false, "t1 == t2") -is(t1 ~= t2, true, "t1 ~= t2") - -is({} == 1, false, "{} == 1") - -is({} ~= 1, true, "{} ~= 1") - -error_like(function () return t1 < t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 < t2") - -error_like(function () return t1 <= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 <= t2") - -error_like(function () return t1 > t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 > t2") - -error_like(function () return t1 >= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 >= t2") - -error_like(function () return {} < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} < 0") - -error_like(function () return {} <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} <= 0") - -error_like(function () return {} > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} > 0") - -error_like(function () return {} >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} >= 0") - -t = {} -is( t[1], nil, "index" ) -t[1] = 42 -is( t[1], 42, "index" ) - -error_like(function () t = {}; t[nil] = 42 end, - "^[^:]+:%d+: table index is nil", - "table index is nil") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/107-thread.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/107-thread.t deleted file mode 100644 index fffedec0..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/107-thread.t +++ /dev/null @@ -1,128 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua thread & coercion - -=head2 Synopsis - - % prove 107-thread.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -co = coroutine.create(function () return 1 end) - -error_like(function () return -co end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-co") - -error_like(function () return #co end, - "^[^:]+:%d+: attempt to get length of", - "#co") - -is(not co, false, "not co") - -error_like(function () return co + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co + 10") - -error_like(function () return co - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co - 2") - -error_like(function () return co * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co * 3.14") - -error_like(function () return co / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co / 7") - -error_like(function () return co % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co % 4") - -error_like(function () return co ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co ^ 3") - -error_like(function () return co .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "co .. 'end'") - -is(co == co, true, "co == co") - -co1 = coroutine.create(function () return 1 end) -co2 = coroutine.create(function () return 2 end) -is(co1 ~= co2, true, "co1 ~= co2") - -is(co == 1, false, "co == 1") - -is(co ~= 1, true, "co ~= 1") - -error_like(function () return co1 < co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 < co2") - -error_like(function () return co1 <= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 <= co2") - -error_like(function () return co1 > co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 > co2") - -error_like(function () return co1 >= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 >= co2") - -error_like(function () return co < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co < 0") - -error_like(function () return co <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co <= 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co > 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co >= 0") - -error_like(function () a = co[1] end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () co[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[co] = true -ok(t[co]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/108-userdata.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/108-userdata.t deleted file mode 100644 index c27ced46..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/108-userdata.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua userdata & coercion - -=head2 Synopsis - - % prove 108-userdata.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -u = io.stdin - -error_like(function () return -u end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-u") - -error_like(function () return #u end, - "^[^:]+:%d+: attempt to get length of", - "#u") - -is(not u, false, "not u") - -error_like(function () return u + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u + 10") - -error_like(function () return u - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u - 2") - -error_like(function () return u * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u * 3.14") - -error_like(function () return u / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u / 7") - -error_like(function () return u % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u % 4") - -error_like(function () return u ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u ^ 3") - -error_like(function () return u .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "u .. 'end'") - -is(u == u, true, "u == u") - -v = io.stdout -is(u ~= v, true, "u ~= v") - -is(u == 1, false, "u == 1") - -is(u ~= 1, true, "u ~= 1") - -error_like(function () return u < v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u < v") - -error_like(function () return u <= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u <= v") - -error_like(function () return u > v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u > v") - -error_like(function () return u >= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u >= v") - -error_like(function () return u < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u < 0") - -error_like(function () return u <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u <= 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u > 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u >= 0") - -is(u[1], nil, "index") - -error_like(function () u[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[u] = true -ok(t[u]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/200-examples.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/200-examples.t deleted file mode 100644 index 200dc4b5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/200-examples.t +++ /dev/null @@ -1,104 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 some Lua code examples - -=head2 Synopsis - - % prove 200-examples.t - -=head2 Description - -First tests in order to check infrastructure. - -=cut - ---]] - -require 'Test.More' - -plan(5) - -function factorial (n) - if n == 0 then - return 1 - else - return n * factorial(n-1) - end -end -is(factorial(7), 5040, "factorial (recursive)") - -local function local_factorial (n) - if n == 0 then - return 1 - else - return n * local_factorial(n-1) - end -end -is(local_factorial(7), 5040, "factorial (recursive)") - -function loop_factorial (n) - local a = 1 - for i = 1, n, 1 do - a = a*i - end - return a -end -is(loop_factorial(7), 5040, "factorial (loop)") - -function iter_factorial (n) - local function iter (product, counter) - if counter > n then - return product - else - return iter(counter*product, counter+1) - end - end - return iter(1, 1) -end -is(iter_factorial(7), 5040, "factorial (iter)") - ---[[ - - Knuth's "man or boy" test. - See http://en.wikipedia.org/wiki/Man_or_boy_test - -]] - -local function A (k, x1, x2, x3, x4, x5) - local function B () - k = k - 1 - return A(k, B, x1, x2, x3, x4) - end - if k <= 0 then - return x4() + x5() - else - return B() - end -end - -is(A(10, - function () return 1 end, - function () return -1 end, - function () return -1 end, - function () return 1 end, - function () return 0 end), - -67, - "man or boy" -) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/201-assign.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/201-assign.t deleted file mode 100644 index c245815a..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/201-assign.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua assignment - -=head2 Synopsis - - % prove 201-assign.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.3 "Assignment", -L. - -See "Programming in Lua", section 4.1 "Assignment". - -=cut - ---]] - -require 'Test.More' - -plan(38) - -is(b, nil, "global variable") -b = 10 -is(b, 10) -if jit then - skip("LuaJIT intentional. _ENV.", 3) -else - is(_ENV.b, 10, "_ENV") - is(_G, _ENV, "_G") - error_like([[ _ENV = nil; b = 20 ]], - "^[^:]+:%d+: attempt to index a nil value") -end -b = nil -is(b, nil) - -a = {} -i = 3 -i, a[i] = i+1, 20 --- this behavior is undefined --- see http://lua-users.org/lists/lua-l/2006-06/msg00378.html --- is(i, 4, "check eval") --- is(a[3], 20) - -x = 1. -y = 2. -x, y = y, x -- swap -is(x, 2, "check swap") -is(y, 1) - -a, b, c = 0, 1 -is(a, 0, "check padding") -is(b, 1) -is(c, nil) -a, b = a+1, b+1, a+b -is(a, 1) -is(b, 2) -a, b, c = 0 -is(a, 0) -is(b, nil) -is(c, nil) - -function f() return 1, 2 end -a, b, c, d = f() -is(a, 1, "adjust with function") -is(b, 2) -is(c, nil) -is(d, nil) - -function f() print('# f') end -a = 2 -a, b, c = f(), 3 -is(a, nil, "padding with function") -is(b, 3) -is(c, nil) - -local my_i = 1 -is(my_i, 1, "local variable") -local my_i = 2 -is(my_i, 2) - -local i = 1 -local j = i -is(i, 1, "local variable") -is(j, 1) -j = 2 -is(i, 1) -is(j, 2) - -local function f(x) return 2*x end -is(f(2), 4, "param & result of function") -a = 2 -a = f(a) -is(a, 4) -local b = 2 -b = f(b) -is(b, 4) - -local n1 = 1 -local n2 = 2 -local n3 = 3 -local n4 = 4 -n1,n2,n3,n4 = n4,n3,n2,n1 -is(n1, 4, "assignment list swap values") -is(n2, 3) -is(n3, 2) -is(n4, 1) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/202-expr.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/202-expr.t deleted file mode 100644 index 3d03f115..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/202-expr.t +++ /dev/null @@ -1,111 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua expression - -=head2 Synopsis - - % prove 202-expr.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4 "Expressions", -L. - -See "Programming in Lua", section 3 "Expressions". - -=cut - ---]] - -require 'Test.More' - -plan(39) - -x = math.pi -is(x - x%0.01, 3.14, "modulo") - -a = {}; a.x = 1; a.y = 0; -b = {}; b.x = 1; b.y = 0; -c = a -is(a == c, true, "relational op (by reference)") -is(a ~= b, true) - -is('0' == 0, false, "relational op") -is(2 < 15, true) -is('2' < '15', false) - -error_like(function () return 2 < '15' end, - "compare", - "relational op") - -error_like(function () return '2' < 15 end, - "compare", - "relational op") - -is(4 and 5, 5, "logical op") -is(nil and 13, nil) -is(false and 13, false) -is(4 or 5, 4) -is(false or 5, 5) -is(false or 'text', 'text') - -is(10 or 20, 10, "logical op") -is(10 or error(), 10) -is(nil or 'a', 'a') -is(nil and 10, nil) -is(false and error(), false) -is(false and nil, false) -is(false or nil, nil) -is(10 and 20, 20) - -is(not nil, true, "logical not") -is(not false, true) -is(not 0, false) -is(not not nil, false) -is(not 'text', false) -a = {} -is(not a, false) - -is("Hello " .. "World", "Hello World", "concatenation") -is(0 .. 1, '01') -a = "Hello" -is(a .. " World", "Hello World") -is(a, "Hello") - -is('10' + 1, 11, "coercion") -is('-5.3' * '2', -10.6) -is(10 .. 20, '1020') -is(tostring(10), '10') -is(10 .. '', '10') - -error_like(function () return 'hello' + 1 end, - "perform arithmetic", - "no coercion") - -error_like(function () - local function first() return 1 end - local function limit() return end - local function step() return 2 end - for i = first(), limit(), step() do - print(i) - end - end, - "^[^:]+:%d+: 'for' limit must be a number", - "for tonumber") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/203-lexico.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/203-lexico.t deleted file mode 100644 index d735f2b4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/203-lexico.t +++ /dev/null @@ -1,122 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Lexicography - -=head2 Synopsis - - % prove 203-lexico.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.1 "Lexical Conventions", -L. - -=cut - ---]] - -require 'Test.More' - -plan(40) - -is("\65", "A") -is("\065", "A") -is("\x41", "A") -is("\x3d", "=") -is("\x3D", "=") - -is(string.byte("\a"), 7) -is(string.byte("\b"), 8) -is(string.byte("\f"), 12) -is(string.byte("\n"), 10) -is(string.byte("\r"), 13) -is(string.byte("\t"), 9) -is(string.byte("\v"), 11) -is(string.byte("\\"), 92) - -is(string.len("A\0B"), 3) - -f, msg = load [[a = "A\300"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = "A\xyz"]] -like(msg, "^[^:]+:%d+: .- near") - -f, msg = load [[a = "A\Z"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = " unfinished string ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \ -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load "a = [[ unfinished long string " -like(msg, "^[^:]+:%d+: unfinished long string near") - -f, msg = load "a = [== invalid long string delimiter " -like(msg, "^[^:]+:%d+: invalid long string delimiter near") - -a = 'alo\n123"' -is('alo\n123"', a) -is("alo\n123\"", a) -is('\97lo\10\04923"', a) -is([[alo -123"]], a) -is([==[ -alo -123"]==], a) -is("alo\n\z -123\"", a) - -f, msg = load [[a = " escape \z unauthorized -new line" ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -is(3.0, 3) -is(314.16e-2, 3.1416) -is(0.31416E1, 3.1416) -is(0xff, 255) -is(0x56, 86) -is(0x0.1E, 0x1E / 0x100) -- 0.1171875 -is(0xA23p-4, 0xA23 / (2^4)) -- 162.1875 -is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2) - -f, msg = load [[a = 12e34e56]] -like(msg, "^[^:]+:%d+: malformed number near") - ---[===[ ---[[ ---[=[ - nested long comments ---]=] ---]] ---]===] - -f, msg = load " --[[ unfinished long comment " -like(msg, "^[^:]+:%d+: unfinished long comment near") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/204-grammar.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/204-grammar.t deleted file mode 100644 index 86636ff2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/204-grammar.t +++ /dev/null @@ -1,106 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Grammar - -=head2 Synopsis - - % prove 204-grammar.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 9 "The Complete Syntax of Lua", -L. - -=cut - ---]] - -require 'Test.More' - -plan(6) - ---[[ empty statement ]] -f, msg = load [[; a = 1]] -type_ok(f, 'function', "empty statement") - ---[[ orphan break ]] -f, msg = load [[ -function f() - print "before" - do - print "inner" - break - end - print "after" -end -]] -if jit then - like(msg, "^[^:]+:%d+: no loop to break", "orphan break") -else - like(msg, "^[^:]+:%d+: at line 5 not inside a loop", "orphan break") -end - ---[[ break anywhere ]] -lives_ok( [[ -function f() - print "before" - while true do - print "inner" - break - print "break" - end - print "after" -end -]], "break anywhere") - ---[[ goto ]] -f, msg = load [[ -::label:: -goto unknown -]] -if jit then - like(msg, ":%d+: undefined label 'unknown'", "unknown goto") -else - like(msg, ":%d+: no visible label 'unknown' for at line %d+", "unknown goto") -end - -f, msg = load [[ -::label:: -goto label -::label:: -]] -if jit then - like(msg, ":%d+: duplicate label 'label'", "duplicate label") -else - like(msg, ":%d+: label 'label' already defined on line %d+", "duplicate label") -end - -f, msg = load [[ -::e:: -goto f -local x -::f:: -goto e -]] -if jit then - like(msg, ":%d+: jumps into the scope of local 'x'", "bad goto") -else - like(msg, ":%d+: at line %d+ jumps into the scope of local 'x'", "bad goto") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/211-scope.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/211-scope.t deleted file mode 100644 index 0781c985..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/211-scope.t +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua scope - -=head2 Synopsis - - % prove 211-scope.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 4.2 "Local Variables and Blocks". - -=cut - ---]] - -require 'Test.More' - -plan(10) - ---[[ scope ]] -x = 10 -do - local x = x - is(x, 10, "scope") - x = x + 1 - do - local x = x + 1 - is(x, 12) - end - is(x, 11) -end -is(x, 10) - ---[[ scope ]] -x = 10 -local i = 1 - -while i<=x do - local x = i*2 --- print(x) - i = i + 1 -end - -if i > 20 then - local x - x = 20 - nok("scope") -else - is(x, 10, "scope") -end - -is(x, 10) - ---[[ scope ]] -local a, b = 1, 10 -if a < b then - is(a, 1, "scope") - local a - is(a, nil) -end -is(a, 1) -is(b, 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/212-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/212-function.t deleted file mode 100644 index 9882884e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/212-function.t +++ /dev/null @@ -1,268 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua functions - -=head2 Synopsis - - % prove 212-function.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.10 "Function Definitions", -L. - -See "Programming in Lua", section 5 "Functions". - -=cut - ---]] - -require 'Test.More' - -plan(63) - ---[[ add ]] -function add (a) - local sum = 0 - for i,v in ipairs(a) do - sum = sum + v - end - return sum -end - -t = { 10, 20, 30, 40 } -is(add(t), 100, "add") - ---[[ f ]] -function f(a, b) return a or b end - -is(f(3), 3, "f") -is(f(3, 4), 3) -is(f(3, 4, 5), 3) - ---[[ incCount ]] -count = 0 - -function incCount (n) - n = n or 1 - count = count + n -end - -is(count, 0, "inCount") -incCount() -is(count, 1) -incCount(2) -is(count, 3) -incCount(1) -is(count, 4) - ---[[ maximum ]] -function maximum (a) - local mi = 1 -- maximum index - local m = a[mi] -- maximum value - for i,val in ipairs(a) do - if val > m then - mi = i - m = val - end - end - return m, mi -end - -local m, mi = maximum({8,10,23,12,5}) -is(m, 23, "maximum") -is(mi, 3) - ---[[ call by value ]] -function f (n) - n = n - 1 - return n -end - -a = 12 -is(a, 12, "call by value") -b = f(a) -is(b, 11) -is(a, 12) -c = f(12) -is(c, 11) -is(a, 12) - ---[[ call by ref ]] -function f (t) - t[#t+1] = 'end' - return t -end - -a = { 'a', 'b', 'c' } -is(table.concat(a, ','), 'a,b,c', "call by ref") -b = f(a) -is(table.concat(b, ','), 'a,b,c,end') -is(table.concat(a, ','), 'a,b,c,end') - ---[[ var args ]] -local function g(a, b, ...) - local arg = {...} - is(a, 3, "vararg") - is(b, nil) - is(#arg, 0) - is(arg[1], nil) -end -g(3) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 0) - is(arg[1], nil) -end -g(3, 4) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 2) - is(arg[1], 5) - is(arg[2], 8) -end -g(3, 4, 5, 8) - ---[[ var args ]] -local function g(a, b, ...) - local c, d, e = ... - is(a, 3, "var args") - is(b, nil) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3, 4) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, 5) - is(d, 8) - is(e, nil) -end - ---[[ var args ]] -local function g(a, b, ...) - is(#{a, b, ...}, 1, "varargs") -end -g(3) - -local function g(a, b, ...) - is(#{a, b, ...}, 2) -end -g(3, 4) - -local function g(a, b, ...) - is(#{a, b, ...}, 4) -end -g(3, 4, 5, 8) - ---[[ var args ]] -function f() return 1, 2 end -function g() return 'a', f() end -function h() return f(), 'b' end -function k() return 'c', (f()) end - -x, y = f() -is(x, 1, "var args") -is(y, 2) -x, y, z = g() -is(x, 'a') -is(y, 1) -is(z, 2) -x, y = h() -is(x, 1) -is(y, 'b') -x, y, z = k() -is(x, 'c') -is(y, 1) -is(z, nil) - - ---[[ invalid var args ]] -f, msg = load [[ -function f () - print(...) -end -]] -like(msg, "^[^:]+:%d+: cannot use '...' outside a vararg function", "invalid var args") - ---[[ tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return foo(n -1) - end - return 'end', 0 -end - -eq_array({foo(3)}, {'end', 0}, "tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return (foo(n -1)) - end - return 'end', 0 -end - -is(foo(3), 'end', "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - foo(n -1) - end -end - -is(foo(3), nil, "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ sub name ]] -local function f () return 1 end -is(f(), 1, "sub name") - -local function f () return 2 end -is(f(), 2) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/213-closure.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/213-closure.t deleted file mode 100644 index 31ab2033..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/213-closure.t +++ /dev/null @@ -1,98 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua closures - -=head2 Synopsis - - % prove 213-closure.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 6.1 "Closures". - -=cut - ---]] - -require 'Test.More' - -plan(15) - ---[[ inc ]] -local counter = 0 - -function inc (x) - counter = counter + x - return counter -end - -is(inc(1), 1, "inc") -is(inc(2), 3) - ---[[ newCounter ]] -function newCounter () - local i = 0 - return function () -- anonymous function - i = i + 1 - return i - end -end - -c1 = newCounter() -is(c1(), 1, "newCounter") -is(c1(), 2) - -c2 = newCounter() -is(c2(), 1) -is(c1(), 3) -is(c2(), 2) - ---[[ -The loop creates ten closures (that is, ten instances of the anonymous -function). Each of these closures uses a different y variable, while all -of them share the same x. -]] -a = {} -local x = 20 -for i=1,10 do - local y = 0 - a[i] = function () y=y+1; return x+y end -end - -is(a[1](), 21, "ten closures") -is(a[1](), 22) -is(a[2](), 21) - - ---[[ add ]] -function add(x) - return function (y) return (x + y) end -end - -f = add(2) -type_ok(f, 'function', "add") -is(f(10), 12) -g = add(5) -is(g(1), 6) -is(g(10), 15) -is(f(1), 3) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/214-coroutine.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/214-coroutine.t deleted file mode 100644 index ed2144c2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/214-coroutine.t +++ /dev/null @@ -1,193 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua coroutines - -=head2 Synopsis - - % prove 214-coroutine.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.6 "Coroutines", -L. - -See "Programming in Lua", section 9 "Coroutines". - -=cut - ---]] - -require 'Test.More' - -plan(30) - ---[[ ]] -output = {} - -function foo1 (a) - output[#output+1] = "foo " .. a - return coroutine.yield(2*a) -end - -co = coroutine.create(function (a,b) - output[#output+1] = "co-body " .. a .." " .. b - local r = foo1(a+1) - output[#output+1] = "co-body " .. r - local r, s = coroutine.yield(a+b, a-b) - output[#output+1] = "co-body " .. r .. " " .. s - return b, 'end' - end) - -eq_array({coroutine.resume(co, 1, 10)}, {true, 4}, "foo1") -eq_array({coroutine.resume(co, 'r')}, {true, 11, -9}) -eq_array({coroutine.resume(co, "x", "y")}, {true, 10, 'end'}) -eq_array({coroutine.resume(co, "x", "y")}, {false, "cannot resume dead coroutine"}) -eq_array(output, { - 'co-body 1 10', - 'foo 2', - 'co-body r', - 'co-body x y', -}) - ---[[ ]] -co = coroutine.create(function () - output = 'hi' - end) -like(co, '^thread: 0?[Xx]?%x+$', "basics") - -is(coroutine.status(co), 'suspended') -output = '' -coroutine.resume(co) -is(output, 'hi') -is(coroutine.status(co), 'dead') - -error_like(function () coroutine.create(true) end, - "^[^:]+:%d+: bad argument #1 to 'create' %(function expected, got boolean%)") - -error_like(function () coroutine.resume(true) end, - "^[^:]+:%d+: bad argument #1 to 'resume' %(coroutine expected, got boolean%)") - -error_like(function () coroutine.status(true) end, - "^[^:]+:%d+: bad argument #1 to 'status' %(coroutine expected, got boolean%)") - ---[[ ]] -output = {} -co = coroutine.create(function () - for i=1,10 do - output[#output+1] = i - coroutine.yield() - end - end) - -coroutine.resume(co) -thr, ismain = coroutine.running(co) -type_ok(thr, 'thread', "running") -is(ismain, true, "running") -is(coroutine.status(co), 'suspended', "basics") -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -eq_array({coroutine.resume(co)}, {false, 'cannot resume dead coroutine'}) -eq_array(output, {1,2,3,4,5,6,7,8,9,10}) - ---[[ ]] -co = coroutine.create(function (a,b) - coroutine.yield(a + b, a - b) - end) - -eq_array({coroutine.resume(co, 20, 10)}, {true, 30, 10}, "basics") - ---[[ ]] -co = coroutine.create(function () - return 6, 7 - end) - -eq_array({coroutine.resume(co)}, {true, 6, 7}, "basics") - ---[[ ]] -co = coroutine.wrap(function(...) - return pcall(function(...) - return coroutine.yield(...) - end, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - ---[[ ]] -co = coroutine.wrap(function(...) - function backtrace () - return 'not a back trace' - end - return xpcall(function(...) - return coroutine.yield(...) - end, backtrace, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - - ---[[ ]] -local output = {} -co = coroutine.wrap(function() - while true do - local t = setmetatable({}, { - __eq = function(...) - return coroutine.yield(...) - end} - ) - local t2 = setmetatable({}, getmetatable(t)) - output[#output+1] = t == t2 - end -end) -co() -co(true) -co(false) -eq_array(output, {true, false}) - ---[[ ]] -co = coroutine.wrap(print) -type_ok(co, 'function') - -error_like(function () coroutine.wrap(true) end, - "^[^:]+:%d+: bad argument #1 to 'wrap' %(function expected, got boolean%)") - -co = coroutine.wrap(function () error"in coro" end) -error_like(function () co() end, - "^[^:]+:%d+: in coro$") - ---[[ ]] -co = coroutine.create(function () - error "in coro" - end) -r, msg = coroutine.resume(co) -is(r, false) -like(msg, "in coro$") - ---[[ ]] -error_like(function () coroutine.yield() end, - "attempt to yield") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/221-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/221-table.t deleted file mode 100644 index f026f77d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/221-table.t +++ /dev/null @@ -1,112 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua tables - -=head2 Synopsis - - % prove 221-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - ---]] - -require 'Test.More' - -plan(25) - ---[[ ]] -a = {} -k = 'x' -a[k] = 10 -a[20] = 'great' -is(a['x'], 10) -k = 20 -is(a[k], 'great') -a['x'] = a ['x'] + 1 -is(a['x'], 11) - ---[[ ]] -a = {} -a['x'] = 10 -b = a -is(b['x'], 10) -b['x'] = 20 -is(a['x'], 20) -a = nil -b = nil - ---[[ ]] -a = {} -for i=1,1000 do a[i] = i*2 end -is(a[9], 18) -a['x'] = 10 -is(a['x'], 10) -is(a['y'], nil) - ---[[ ]] -a = {} -x = 'y' -a[x] = 10 -is(a[x], 10) -is(a.x, nil) -is(a.y, 10) - ---[[ ]] -i = 10; j = '10'; k = '+10' -a = {} -a[i] = "one value" -a[j] = "another value" -a[k] = "yet another value" -is(a[j], "another value") -is(a[k], "yet another value") -is(a[tonumber(j)], "one value") -is(a[tonumber(k)], "one value") - -t = { {'a','b','c'}, 10 } -is(t[2], 10) -is(t[1][3], 'c') -t[1][1] = 'A' -is(table.concat(t[1],','), 'A,b,c') - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is(tt[2], 10) -is(tt[1][3], 'c') -tt[1][1] = 'A' -is(table.concat(tt[1],','), 'A,b,c') - ---[[ ]] -a = {} -error_like(function () a() end, - "^[^:]+:%d+: attempt to call") - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is((tt)[2], 10) -is((tt[1])[3], 'c'); -(tt)[1][2] = 'B' -(tt[1])[3] = 'C' -is(table.concat(tt[1],','), 'a,B,C') - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/222-constructor.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/222-constructor.t deleted file mode 100644 index 44009471..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/222-constructor.t +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Constructors - -=head2 Synopsis - - % prove 222-constructor.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.8 "Table Constructors", -L. - -See "Programming in Lua", section 3.6 "Table Constructors". - -=cut - ---]] - -require 'Test.More' - -plan(14) - ---[[ list-style init ]] -days = {'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday'} -is(days[4], 'Wednesday', "list-style init") -is(#days, 7) - ---[[ record-style init ]] -a = {x=0, y=0} -is(a.x, 0, "record-style init") -is(a.y, 0) - ---[[ ]] -w = {x=0, y=0, label='console'} -x = {0, 1, 2} -w[1] = "another field" -x.f = w -is(w['x'], 0, "ctor") -is(w[1], "another field") -is(x.f[1], "another field") -w.x = nil - ---[[ mix record-style and list-style init ]] -polyline = {color='blue', thickness=2, npoints=4, - {x=0, y=0}, - {x=-10, y=0}, - {x=-10, y=1}, - {x=0, y=1} - } -is(polyline[2].x, -10, "mix record-style and list-style init") - ---[[ ]] -opnames = {['+'] = 'add', ['-'] = 'sub', - ['*'] = 'mul', ['/'] = 'div'} -i = 20; s = '-' -a = {[i+0] = s, [i+1] = s..s, [i+2] = s..s..s} -is(opnames[s], 'sub', "ctor") -is(a[22], '---') - ---[[ ]] -local function f() return 10, 20 end - -eq_array({f()}, {10, 20}, "ctor") -eq_array({'a', f()}, {'a', 10, 20}) -eq_array({f(), 'b'}, {10, 'b'}) -eq_array({'c', (f())}, {'c', 10}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/223-iterator.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/223-iterator.t deleted file mode 100644 index 3905fc22..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/223-iterator.t +++ /dev/null @@ -1,196 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua iterators - -=head2 Synopsis - - % prove 223-iterator.t - -=head2 Description - -See "Programming in Lua", section 7 "Iterators and the Generic for" and -section 9.3 "Coroutines as Iterators". - -=cut - ---]] - -require 'Test.More' - -plan(8) - ---[[ list_iter ]] -function list_iter (t) - local i = 0 - local n = #t - return function () - i = i + 1 - if i <= n then - return t[i] - else - return nil - end - end -end - -t = {10, 20, 30} -output = {} -for element in list_iter(t) do - output[#output+1] = element -end -eq_array(output, t, "list_iter") - ---[[ values ]] -function values (t) - local i = 0 - return function () - i = i + 1 - return t[i] - end -end - -t = {10, 20, 30} -output = {} -for element in values(t) do - output[#output+1] = element -end -eq_array(output, t, "values") - ---[[ emul ipairs ]] -local function iter (a, i) - i = i + 1 - local v = a[i] - if v then - return i, v - end -end - -local function my_ipairs (a) - return iter, a, 0 -end - -a = {'one', 'two', 'three'} -output = {} -for i, v in my_ipairs(a) do - output[#output+1] = i - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ emul pairs ]] -local function my_pairs (t) - return next, t, nil -end - -a = {'one', 'two', 'three'} -output = {} -for k, v in my_pairs(a) do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ with next ]] -t = {'one', 'two', 'three'} -output = {} -for k, v in next, t do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "with next") - ---[[ permutations ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () -- iterator - local code, res = coroutine.resume(co) - return res - end -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations") - - ---[[ permutations with wrap ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - return coroutine.wrap(function () permgen(a) end) -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations with wrap") - ---[[ fibo ]] -function fibogen () - local x, y = 0, 1 - while true do - coroutine.yield(x) - x, y = y, x + y - end -end - -function fibo () - return coroutine.wrap(function () fibogen() end) -end - -output = {} -for n in fibo() do - output[#output+1] = n - if n > 30 then break end -end -eq_array(output, {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}, "fibo") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/231-metatable.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/231-metatable.t deleted file mode 100644 index fc05e7bc..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/231-metatable.t +++ /dev/null @@ -1,533 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua metatables - -=head2 Synopsis - - % prove 231-metatable.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.4 "Metatables and Metamethods", -L. - -See "Programming in Lua", section 13 "Metatables and Metamethods". - -=cut - ---]] - -require 'Test.More' - -plan(96) - -t = {} -is(getmetatable(t), nil, "metatable") -t1 = {} -is(setmetatable(t, t1), t) -is(getmetatable(t), t1) -is(setmetatable(t, nil), t) -error_like(function () setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected.+%)") - -mt = {} -mt.__metatable = "not your business" -setmetatable(t, mt) -is(getmetatable(t), "not your business", "protected metatable") -error_like(function () setmetatable(t, {}) end, - "^[^:]+:%d+: cannot change a protected metatable") - -is(getmetatable('').__index, string, "metatable for string") - -is(getmetatable(nil), nil, "metatable for nil") -is(getmetatable(false), nil, "metatable for boolean") -is(getmetatable(2), nil, "metatable for number") -is(getmetatable(print), nil, "metatable for function") - -t = {} -mt = { __tostring=function () return '__TABLE__' end } -setmetatable(t, mt) -is(tostring(t), '__TABLE__', "__tostring") - -mt = {} -a = nil -function mt.__tostring () a = "return nothing" end -setmetatable(t, mt) -is(tostring(t), nil, "__tostring no-output") -is(a, "return nothing") -error_like(function () print(t) end, - "^[^:]+:%d+: 'tostring' must return a string to 'print'") - -mt.__tostring = function () return '__FIRST__', 2 end -setmetatable(t, mt) -is(tostring(t), '__FIRST__', "__tostring too-many-output") - -t = {} -t.mt = {} -setmetatable(t, t.mt) -t.mt.__tostring = "not a function" -error_like(function () tostring(t) end, - "attempt to call", - "__tostring invalid") - -t = {} -mt = { __len=function () return 42 end } -setmetatable(t, mt) -is(#t, 42, "__len") - -t = {} -mt = { __len=function () return nil end } -setmetatable(t, mt) -if jit then - todo("LuaJIT TODO. __len.", 1) -end -error_like(function () print(table.concat(t)) end, - "object length is not a number", - "__len invalid") - -t = {} -mt = { - __tostring=function () return 't' end, - __concat=function (op1, op2) - return tostring(op1) .. '|' .. tostring(op2) - end, -} -setmetatable(t, mt) -is(t .. t .. t .. 4 ..'end', "t|t|t|4end", "__concatx") - - ---[[ Cplx ]] -Cplx = {} -Cplx.mt = {} - -function Cplx.new (re, im) - local c = {} - setmetatable(c, Cplx.mt) - c.re = tonumber(re) - if im == nil then - c.im = 0.0 - else - c.im = tonumber(im) - end - return c -end - -function Cplx.mt.__tostring (c) - return '(' .. c.re .. ',' .. c.im .. ')' -end - -function Cplx.mt.__add (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re + b.re, a.im + b.im) - return r -end - -c1 = Cplx.new(1, 3) -c2 = Cplx.new(2, -1) - -is(tostring(c1 + c2), '(3,2)', "cplx __add") -is(tostring(c1 + 3), '(4,3)') -is(tostring(-2 + c1), '(-1,3)') -is(tostring(c1 + '3'), '(4,3)') -is(tostring('-2' + c1), '(-1,3)') - -function Cplx.mt.__sub (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re - b.re, a.im - b.im) - return r -end - -is(tostring(c1 - c2), '(-1,4)', "cplx __sub") -is(tostring(c1 - 3), '(-2,3)') -is(tostring(-2 - c1), '(-3,-3)') -is(tostring(c1 - '3'), '(-2,3)') -is(tostring('-2' - c1), '(-3,-3)') - -function Cplx.mt.__mul (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re*b.re - a.im*b.im, - a.re*b.im + a.im*b.re) - return r -end - -is(tostring(c1 * c2), '(5,5)', "cplx __mul") -is(tostring(c1 * 3), '(3,9)') -is(tostring(-2 * c1), '(-2,-6)') -is(tostring(c1 * '3'), '(3,9)') -is(tostring('-2' * c1), '(-2,-6)') - -function Cplx.mt.__div (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local n = b.re*b.re + b.im*b.im - local inv = Cplx.new(b.re/n, b.im/n) - local r = Cplx.new(a.re*inv.re - a.im*inv.im, - a.re*inv.im + a.im*inv.re) - return r -end - -c1 = Cplx.new(2, 6) -c2 = Cplx.new(2, 0) - -is(tostring(c1 / c2), '(1,3)', "cplx __div") -is(tostring(c1 / 2), '(1,3)') -is(tostring(-4 / c2), '(-2,0)') -is(tostring(c1 / '2'), '(1,3)') -is(tostring('-4' / c2), '(-2,0)') - -function Cplx.mt.__unm (a) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - local r = Cplx.new(-a.re, -a.im) - return r -end - -c1 = Cplx.new(1, 3) -is(tostring(- c1), '(-1,-3)', "cplx __unm") - -function Cplx.mt.__len (a) - return math.sqrt(a.re*a.re + a.im*a.im) -end - -c1 = Cplx.new(3, 4) -is( #c1, 5, "cplx __len") - -function Cplx.mt.__eq (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - return (a.re == b.re) and (b.im == b.im) -end - -c1 = Cplx.new(2, 0) -c2 = Cplx.new(1, 3) -c3 = Cplx.new(2, 0) - -is(c1 ~= c2, true, "cplx __eq") -is(c1 == c3, true) -is(c1 == 2, false) -is(Cplx.mt.__eq(c1, 2), true) - -function Cplx.mt.__lt (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra < rb -end - -is(c1 < c2, true, "cplx __lt") -is(c1 < c3, false) -is(c1 <= c3, true) -is(c1 < 1, false) -is(c1 < 4, true) - -function Cplx.mt.__le (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra <= rb -end - -is(c1 < c2, true, "cplx __lt __le") -is(c1 < c3, false) -is(c1 <= c3, true) - -function Cplx.mt.__call (obj) - a = "Cplx.__call " .. tostring(obj) - return true -end - -c1 = Cplx.new(2, 0) -a = nil -r = c1() -is(r, true, "cplx __call (without args)") -is(a, "Cplx.__call (2,0)") - -function Cplx.mt.__call (obj, ...) - a = "Cplx.__call " .. tostring(obj) .. ", " .. table.concat({...}, ", ") - return true -end - -is(c1(), true, "cplx __call (with args)") -is(a, "Cplx.__call (2,0), ") -is(c1('a'), true) -is(a, "Cplx.__call (2,0), a") -is(c1('a', 'b', 'c'), true) -is(a, "Cplx.__call (2,0), a, b, c") - ---[[ delegate ]] - -local t = { - _VALUES = { - a = 1, - b = 'text', - c = true, - } -} -local mt = { - __pairs = function (op) - return next, op._VALUES - end -} -setmetatable(t, mt) - -r = {} -for k in pairs(t) do - r[#r+1] = k -end -table.sort(r) -is( table.concat(r, ','), 'a,b,c', "__pairs" ) - -local t = { - _VALUES = { 'a', 'b', 'c' } -} -local mt = { - __ipairs = function (op) - return ipairs(op._VALUES) - end -} -setmetatable(t, mt) - -r = '' -for i, v in ipairs(t) do - r = r .. v -end -is( r, 'abc', "__ipairs" ) - ---[[ Window ]] - --- create a namespace -Window = {} --- create a prototype with default values -Window.prototype = {x=0, y=0, width=100, heigth=100, } --- create a metatable -Window.mt = {} --- declare the constructor function -function Window.new (o) - setmetatable(o, Window.mt) - return o -end - -Window.mt.__index = function (table, key) - return Window.prototype[key] -end - -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - -Window.mt.__index = Window.prototype -- just a table -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - ---[[ tables with default values ]] -function setDefault_1 (t, d) - local mt = {__index = function () return d end} - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_1(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local mt = {__index = function (t) return t.___ end} -function setDefault_2 (t, d) - t.___ = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_2(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local key = {} -local mt = {__index = function (t) return t[key] end} -function setDefault_3 (t, d) - t[key] = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_3(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ private access ]] -t = {} -- original table --- keep a private access to original table -local _t = t --- create proxy -t = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return _t[k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - _t[k] = v -- update original table - end -} -setmetatable(t, mt) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ private access ]] --- create private index -local index = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return t[index][k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - t[index][k] = v -- update original table - end -} -function track (t) - local proxy = {} - proxy[index] = t - setmetatable(proxy, mt) - return proxy -end - -t = {} -t = track(t) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ read-only table ]] -function readOnly (t) - local proxy = {} - local mt = { - __index = t, - __newindex = function (t,k,v) - error("attempt to update a read-only table", 2) - end - } - setmetatable(proxy, mt) - return proxy -end - -days = readOnly{'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thurday', 'Friday', 'Saturday'} - -is(days[1], 'Sunday', "read-only tables") - -error_like(function () days[2] = 'Noday' end, - "^[^:]+:%d+: attempt to update a read%-only table") - ---[[ declare global ]] -function declare (name, initval) - rawset(_G, name, initval or false) -end - -setmetatable(_G, { - __newindex = function (_, n) - error("attempt to write to undeclared variable " .. n, 2) - end, - __index = function (_, n) - error("attempt to read undeclared variable" .. n, 2) - end, -}) - -error_like(function () new_a = 1 end, - "^[^:]+:%d+: attempt to write to undeclared variable new_a", - "declaring global variables") - -declare 'new_a' -new_a = 1 -is(new_a, 1) - ---[[ ]] -local newindex = {} --- create metatable -local mt = { - __newindex = newindex -} -local t = setmetatable({}, mt) -t[1] = 42 -is(newindex[1], 42, "__newindex") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/232-object.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/232-object.t deleted file mode 100644 index f00eb321..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/232-object.t +++ /dev/null @@ -1,307 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua object - -=head2 Synopsis - - % prove 232-object.t - -=head2 Description - -See "Programming in Lua", section 16 "Object-Oriented Programming". - -=cut - ---]] - -require 'Test.More' - -plan(18) - ---[[ object ]] -Account = {balance = 0} - -function Account.withdraw (self, v) - self.balance = self.balance - v -end - -a1 = Account; Account = nil -a1.withdraw(a1, 100.00) -is(a1.balance, -100, "object") - -a2 = {balance = 0, withdraw = a1.withdraw} -a2.withdraw(a2, 260.00) -is(a2.balance, -260) - ---[[ object ]] -Account = {balance = 0} - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account -a:withdraw(100.00) -is(a.balance, -100, "object") - -Account = { balance = 0, - withdraw = function (self, v) - self.balance = self.balance -v - end - } -function Account:deposit (v) - self.balance = self.balance + v -end - -Account.deposit(Account, 200.00) -is(Account.balance, 200, "object") -Account:withdraw(100.00) -is(Account.balance, 100) - ---[[ classe ]] -Account = {balance = 0} - -function Account:new (o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) - self.balance = self.balance + v -end - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account:new{balance = 0} -a:deposit(100.00) -is(a.balance, 100, "classe") - -b = Account:new() -is(b.balance, 0) -b:deposit(200.00) -is(b.balance, 200) - ---[[ inheritance ]] -Account = {balance = 0} - -function Account:new (o) --- print "Account:new" - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) --- print "Account:deposit" - self.balance = self.balance + v -end - -function Account:withdraw (v) --- print "Account:withdraw" - if v > self.balance then error"insuficient funds" end - self.balance = self.balance - v -end - -a = Account:new() -is(a.balance, 0, "inheritance") --- r, msg = pcall(Account.withdraw, a, 100) --- print(msg) - -SpecialAccount = Account:new() - -function SpecialAccount:withdraw (v) --- print "SpecialAccount:withdraw" - if self.balance - v <= -self:getLimit() then - error"insuficient funds" - end - self.balance = self.balance - v -end - -function SpecialAccount:getLimit () --- print "SpecialAccount:getLimit" - return self.limit or 0 -end - -s = SpecialAccount:new{limit=1000.00} - -s:deposit(100.00) -is(s.balance, 100) - -s:withdraw(200.00) -is(s.balance, -100) - ---[[ multiple inheritance ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - return search(k, arg) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance") -account:deposit(100.00) -is(account.balance, 100) - - ---[[ multiple inheritance (patched) ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - -- return search(k, arg) - return (search(k, arg)) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance (patched)") -account:deposit(100.00) -is(account.balance, 100) - ---[[ privacy ]] -function newAccount (initialBalance) - local self = {balance = initialBalance} - - local withdraw = function (v) - self.balance = self.balance - v - end - - local deposit = function (v) - self.balance = self.balance + v - end - - local getBalance = function () return self.balance end - - return { - withdraw = withdraw, - deposit = deposit, - getBalance = getBalance - } -end - -acc1 = newAccount(100.00) -acc1.withdraw(40.00) -is(acc1.getBalance(), 60, "privacy") - ---[[ single-method approach ]] -function newObject (value) - return function (action, v) - if action == 'get' then return value - elseif action == 'set' then value = v - else error("invalid action") - end - end -end - -d = newObject(0) -is(d('get'), 0, "single-method approach") -d('set', 10) -is(d('get'), 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/301-basic.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/301-basic.t deleted file mode 100644 index 62eb0970..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/301-basic.t +++ /dev/null @@ -1,391 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Basic Library - -=head2 Synopsis - - % prove 301-basic.t - -=head2 Description - -Tests Lua Basic Library - -See "Lua 5.2 Reference Manual", section 6.1 "Basic Functions", -L. - -=cut - ---]] - --- MoonSharp note : THIS SUITE WAS HEAVILY CUT FOR NOT APPLIABLE TESTS - - -require 'Test.More' - -plan(168) - ---[[ -if jit then - like(_VERSION, '^Lua 5%.1$', "variable _VERSION") -else - like(_VERSION, '^Lua 5%.2$', "variable _VERSION") -end --- ]] - -v, msg = assert('text', "assert string") -is(v, 'text', "function assert") -is(msg, "assert string") -v, msg = assert({}, "assert table") -is(msg, "assert table") - -error_like(function () assert(false, "ASSERTION TEST") end, - "^[^:]+:%d+: ASSERTION TEST", - "function assert(false, msg)") - -error_like(function () assert(false) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false)") - -error_like(function () assert(false, nil) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false, nil)") - - -a = {'a','b','c'} -local f, v, s = ipairs(a) -type_ok(f, 'function', "function ipairs") -type_ok(v, 'table') -is(s, 0) -s, v = f(a, s) -is(s, 1) -is(v, 'a') -s, v = f(a, s) -is(s, 2) -is(v, 'b') -s, v = f(a, s) -is(s, 3) -is(v, 'c') -s, v = f(a, s) -is(s, nil) -is(v, nil) - -t = { [[ -function bar (x) - return x -end -]] } -i = 0 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(reader)") -is(bar, nil) -f() -is(bar('ok'), 'ok') -bar = nil - -t = { [[ -function baz (x) - return x -end -]] } -i = -1 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(pathological reader)") -f() -is(baz, nil) - -t = { [[?syntax error?]] } -i = 0 -f, msg = load(reader, "errorchunk") -is(f, nil, "function load(syntax error)") ---like(msg, "^%[string \"errorchunk\"%]:%d+:") -- ERRORMSG - -f = load(function () return nil end) -type_ok(f, 'function', "when reader returns nothing") - -f, msg = load(function () return {} end) -is(f, nil, "reader function must return a string") -like(msg, "reader function must return a string") - -f = load([[ -function bar (x) - return x -end -]]) -is(bar, nil, "function load(str)") -f() -is(bar('ok'), 'ok') -bar = nil - -env = {} -f = load([[ -function bar (x) - return x -end -]], "from string", 't', env) -is(env.bar, nil, "function load(str)") -f() -is(env.bar('ok'), 'ok') - - --- ... - - -f = load([[i = i + 1]]) -i = 0 -f() -is(i, 1, "function loadstring") -f() -is(i, 2) - -i = 32 -local i = 0 -f = load([[i = i + 1; return i]]) -g = function () i = i + 1; return i end -is(f(), 33, "function loadstring") -is(g(), 1) - -f, msg = load([[?syntax error?]]) -is(f, nil, "function loadstring (syntax error)") --- like(msg, '^%[string "%?syntax error%?"%]:%d+:') -- ERRORMSG - -t = {'a','b','c'} -a = next(t, nil) -is(a, 1, "function next (array)") -a = next(t, 1) -is(a, 2) -a = next(t, 2) -is(a, 3) -a = next(t, 3) -is(a, nil) - -error_like(function () a = next() end, - "^[^:]+:%d+: bad argument #1 to 'next' %(table expected, got no value%)", - "function next (no arg)") - -error_like(function () a = next(t, 6) end, - "invalid key to 'next'", - "function next (invalid key)") - -t = {'a','b','c'} -a = next(t, 2) -is(a, 3, "function next (unorderer)") -a = next(t, 1) -is(a, 2) -a = next(t, 3) -is(a, nil) - -t = {} -a = next(t, nil) -is(a, nil, "function next (empty table)") - -a = {'a','b','c'} -local f, v, s = pairs(a) -type_ok(f, 'function', "function pairs") -type_ok(v, 'table') -is(s, nil) -s = f(v, s) -is(s, 1) -s = f(v, s) -is(s, 2) -s = f(v, s) -is(s, 3) -s = f(v, s) -is(s, nil) - -r = pcall(assert, true) -is(r, true, "function pcall") -r, msg = pcall(assert, false, 'catched') -is(r, false) -is(msg, 'catched') -r = pcall(assert) -is(r, false) - -t = {} -a = t -is(rawequal(nil, nil), true, "function rawequal -> true") -is(rawequal(false, false), true) -is(rawequal(3, 3), true) -is(rawequal('text', 'text'), true) -is(rawequal(t, a), true) -is(rawequal(print, print), true) - -is(rawequal(nil, 2), false, "function rawequal -> false") -is(rawequal(false, true), false) -is(rawequal(false, 2), false) -is(rawequal(3, 2), false) -is(rawequal(3, '2'), false) -is(rawequal('text', '2'), false) -is(rawequal('text', 2), false) -is(rawequal(t, {}), false) -is(rawequal(t, 2), false) -is(rawequal(print, format), false) -is(rawequal(print, 2), false) - -is(rawlen("text"), 4, "function rawlen (string)") -is(rawlen({ 'a', 'b', 'c'}), 3, "function rawlen (table)") -error_like(function () a = rawlen(true) end, - "^[^:]+:%d+: bad argument #1 to 'rawlen' %(table ", - "function rawlen (bad arg)") - -t = {a = 'letter a', b = 'letter b'} -is(rawget(t, 'a'), 'letter a', "function rawget") - -t = {} -is(rawset(t, 'a', 'letter a'), t, "function rawset") -is(t.a, 'letter a') - -error_like(function () t = {}; rawset(t, nil, 42) end, - "^[^:]+:%d+: table index is nil", -- changed this for MoonSharp, but we stay as it is! - "function rawset (table index is nil)") - -is(select('#'), 0, "function select") -is(select('#','a','b','c'), 3) -eq_array({select(1,'a','b','c')}, {'a','b','c'}) -eq_array({select(3,'a','b','c')}, {'c'}) -eq_array({select(5,'a','b','c')}, {}) -eq_array({select(-1,'a','b','c')}, {'c'}) -eq_array({select(-2,'a','b','c')}, {'b', 'c'}) -eq_array({select(-3,'a','b','c')}, {'a', 'b', 'c'}) - -error_like(function () select(0,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -error_like(function () select(-4,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -is(type("Hello world"), 'string', "function type") -is(type(10.4*3), 'number') -is(type(print), 'function') -is(type(type), 'function') -is(type(true), 'boolean') -is(type(nil), 'nil') --- is(type(io.stdin), 'userdata') -- no stdin in MoonSharp so far -is(type(type(X)), 'string') - -a = nil -is(type(a), 'nil', "function type") -a = 10 -is(type(a), 'number') -a = "a string!!" -is(type(a), 'string') -a = print -is(type(a), 'function') -is(type(function () end), 'function') - -error_like(function () type() end, - "^[^:]+:%d+: bad argument #1 to 'type' %(value expected%)", - "function type (no arg)") - -is(tonumber('text12'), nil, "function tonumber") -is(tonumber('12text'), nil) -is(tonumber(3.14), 3.14) -is(tonumber('3.14'), 3.14) -is(tonumber(' 3.14 '), 3.14) -is(tonumber(111, 2), 7) -is(tonumber('111', 2), 7) -is(tonumber(' 111 ', 2), 7) -is(tonumber('78', 9), 71) -is(tonumber('111 ', 3), 13) -is(tonumber('111', 4), 21) -is(tonumber('1234', 5), 194) -is(tonumber('54321', 6), 7465) - -a = {} -is(tonumber(a), nil) - -error_like(function () tonumber() end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(value expected%)", - "function tonumber (no arg)") - -error_like(function () tonumber('111', 200) end, - "^[^:]+:%d+: bad argument #2 to 'tonumber' %(base out of range%)", - "function tonumber (bad base)") - -error_like(function () tonumber('17', 6) end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(invalid character%)", - "function tonumber (bad base)") - -is(tostring('text'), 'text', "function tostring") -is(tostring(3.14), '3.14') -is(tostring(nil), 'nil') -is(tostring(true), 'true') -is(tostring(false), 'false') -like(tostring({}), '^table: 0?[Xx]?%x+$') -like(tostring(print), '^function: 0?[Xx]?[builtin]*#?%x+$') - -error_like(function () tostring() end, - "^[^:]+:%d+: bad argument #1 to 'tostring' %(value expected%)", - "function tostring (no arg)") - ---[[ MoonSharp : this is intentional - we support pack and unpack outside the table namespace (or whatever they are) -if (platform and platform.compat) or jit then - type_ok(unpack, 'function', "function unpack") -else - is(unpack, nil, "function unpack (removed)") -end -]] - - -if jit then - error_like(function () xpcall(assert, nil) end, - "bad argument #2 to 'xpcall' %(function expected, got nil%)", - "function xpcall") - error_like(function () xpcall(assert) end, - "bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall") - diag("LuaJIT intentional. xpcall") -else - is(xpcall(assert, nil), false, "function xpcall") - error_like(function () xpcall(assert) end, - "^[^:]+:%d+: bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall (no arg)") -end - -function backtrace () - return 'not a back trace' -end -r, msg = xpcall(assert, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r, msg = xpcall(function() assert(); end, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r = xpcall(assert, backtrace, true) -is(r, true, "function xpcall") - - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/304-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/304-string.t deleted file mode 100644 index f610aaed..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/304-string.t +++ /dev/null @@ -1,318 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua String Library - -=head2 Synopsis - - % prove 304-string.t - -=head2 Description - -Tests Lua String Library - -See "Lua 5.2 Reference Manual", section 6.4 "String Manipulation", -L. - -See "Programming in Lua", section 20 "The String Library". - -=cut - -]] - -require 'Test.More' - -plan(115) - -is(string.byte('ABC'), 65, "function byte") -is(string.byte('ABC', 2), 66) -is(string.byte('ABC', -1), 67) -is(string.byte('ABC', 4), nil) -is(string.byte('ABC', 0), nil) -eq_array({string.byte('ABC', 1, 3)}, {65, 66, 67}) -eq_array({string.byte('ABC', 1, 4)}, {65, 66, 67}) - -type_ok(getmetatable('ABC'), 'table', "literal string has metatable") - -s = "ABC" -is(s:byte(2), 66, "method s:byte") - -is(string.char(65, 66, 67), 'ABC', "function char") -is(string.char(), '') - -error_like(function () string.char(0, 'bad') end, - "^[^:]+:%d+: bad argument #2 to 'char' %(number expected, got string%)", - "function char (bad arg)") - - ---[[ -MoonSharp intentional : - -1) unicode chars supported! -2) plan has upvalues, and by Lua spec it shouldn't be supported! - -error_like(function () string.char(0, 9999) end, - "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)", - "function char (invalid)") - -d = string.dump(plan) -type_ok(d, 'string', "function dump") - -error_like(function () string.dump(print) end, - "^[^:]+:%d+: unable to dump given function", - "function dump (C function)") - -]] - -s = "hello world" -eq_array({string.find(s, "hello")}, {1, 5}, "function find (mode plain)") -eq_array({string.find(s, "hello", 1, true)}, {1, 5}) -eq_array({string.find(s, "hello", 1)}, {1, 5}) -is(string.sub(s, 1, 5), "hello") -eq_array({string.find(s, "world")}, {7, 11}) -eq_array({string.find(s, "l")}, {3, 3}) -is(string.find(s, "lll"), nil) -is(string.find(s, "hello", 2, true), nil) -eq_array({string.find(s, "world", 2, true)}, {7, 11}) -is(string.find(s, "hello", 20), nil) - -s = "hello world" -eq_array({string.find(s, "^h.ll.")}, {1, 5}, "function find (with regex & captures)") -eq_array({string.find(s, "w.rld", 2)}, {7, 11}) -is(string.find(s, "W.rld"), nil) -eq_array({string.find(s, "^(h.ll.)")}, {1, 5, 'hello'}) -eq_array({string.find(s, "^(h.)l(l.)")}, {1, 5, 'he', 'lo'}) -s = "Deadline is 30/05/1999, firm" -date = "%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") -date = "%f[%S]%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") - -error_like(function () string.find(s, '%f') end, - "^[^:]+:%d+: missing '%[' after '%%f' in pattern", - "function find (invalid frontier)") - -is(string.format("pi = %.4f", math.pi), 'pi = 3.1416', "function format") -d = 5; m = 11; y = 1990 -is(string.format("%02d/%02d/%04d", d, m, y), "05/11/1990") -is(string.format("%X %x", 126, 126), "7E 7e") -tag, title = "h1", "a title" -is(string.format("<%s>%s", tag, title, tag), "

a title

") - --- moonsharp : this commented out as it might fail mostly because of CRLF in windows than because of --- a moonsharp bug I think. Will see, surely not a blocking issue now. ---[==[ -is(string.format('%q', 'a string with "quotes" and \n new line'), [["a string with \"quotes\" and \ - new line"]], "function format %q") ---]==] - -is(string.format('%q', 'a string with \b and \b2'), [["a string with \8 and \0082"]], "function format %q") - -is(string.format("%s %s", 1, 2, 3), '1 2', "function format (too many arg)") - -is(string.format("%% %c %%", 65), '% A %', "function format (%%)") - -r = string.rep("ab", 100) -is(string.format("%s %d", r, r:len()), r .. " 200") - -error_like(function () string.format("%s %s", 1) end, - "^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)", - "function format (too few arg)") - -error_like(function () string.format('%d', 'toto') end, - "^[^:]+:%d+: bad argument #2 to 'format' %(number expected, got string%)", - "function format (bad arg)") - -error_like(function () string.format('%k', 'toto') end, - "^[^:]+:%d+: invalid option '%%k' to 'format'", - "function format (invalid option)") - -if jit and jit.version_num >= 20100 then - todo("LuaJIT TODO. format.", 1) -end -error_like(function () string.format('%------s', 'toto') end, - "^[^:]+:%d+: invalid format %(repeated flags%)", - "function format (invalid format)") - -error_like(function () string.format('pi = %.123f', math.pi) end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -error_like(function () string.format('% 123s', 'toto') end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -s = "hello" -output = {} -for c in string.gmatch(s, '..') do - table.insert(output, c) -end -eq_array(output, {'he', 'll'}, "function gmatch") -output = {} -for c1, c2 in string.gmatch(s, '(.)(.)') do - table.insert(output, c1) - table.insert(output, c2) -end -eq_array(output, {'h', 'e', 'l', 'l'}) -s = "hello world from Lua" -output = {} -for w in string.gmatch(s, '%a+') do - table.insert(output, w) -end -eq_array(output, {'hello', 'world', 'from', 'Lua'}) -s = "from=world, to=Lua" -output = {} -for k, v in string.gmatch(s, '(%w+)=(%w+)') do - table.insert(output, k) - table.insert(output, v) -end -eq_array(output, {'from', 'world', 'to', 'Lua'}) - -is(string.gsub("hello world", "(%w+)", "%1 %1"), "hello hello world world", "function gsub") -is(string.gsub("hello world", "%w+", "%0 %0", 1), "hello hello world") - - -is(string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1"), "world hello Lua from") - - -if jit then - todo("LuaJIT TODO. gsub.", 1) -end - -error_like(function () string.gsub("hello world", "%w+", "%e") end, - "^[^:]+:%d+: invalid use of '%%' in replacement string", - "function gsub (invalid replacement string)") - -is(string.gsub("home = $HOME, user = $USER", "%$(%w+)", string.reverse), "home = EMOH, user = RESU") -is(string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) return load(s)() end), "4+5 = 9") -local t = {name='lua', version='5.1'} -is(string.gsub("$name-$version.tar.gz", "%$(%w+)", t), "lua-5.1.tar.gz") -is(string.gsub("Lua is cute", 'cute', 'great'), "Lua is great") -is(string.gsub("all lii", 'l', 'x'), "axx xii") -is(string.gsub("Lua is great", '^Sol', 'Sun'), "Lua is great") -is(string.gsub("all lii", 'l', 'x', 1), "axl lii") -is(string.gsub("all lii", 'l', 'x', 2), "axx lii") -is(select(2, string.gsub("string with 3 spaces", ' ', ' ')), 3) - -eq_array({string.gsub("hello, up-down!", '%A', '.')}, {"hello..up.down.", 4}) -text = "hello world" -nvow = select(2, string.gsub(text, '[AEIOUaeiou]', '')) -is(nvow, 3) -eq_array({string.gsub("one, and two; and three", '%a+', 'word')}, {"word, word word; word word", 5}) -test = "int x; /* x */ int y; /* y */" -eq_array({string.gsub(test, "/%*.*%*/", '')}, {"int x; ", 1}) -eq_array({string.gsub(test, "/%*.-%*/", '')}, {"int x; int y; ", 2}) -s = "a (enclosed (in) parentheses) line" -eq_array({string.gsub(s, '%b()', '')}, {"a line", 1}) - -error_like(function () string.gsub(s, '%b(', '') end, - "^[^:]+:%d+: .- pattern", - "function gsub (malformed pattern)") - -eq_array({string.gsub("hello Lua!", "%a", "%0-%0")}, {"h-he-el-ll-lo-o L-Lu-ua-a!", 8}) -eq_array({string.gsub("hello Lua", "(.)(.)", "%2%1")}, {"ehll ouLa", 4}) - -function expand (s) - return (string.gsub(s, '$(%w+)', _G)) -end -name = 'Lua'; status= 'great' -is(expand("$name is $status, isn't it?"), "Lua is great, isn't it?") -is(expand("$othername is $status, isn't it?"), "$othername is great, isn't it?") - -function expand (s) - return (string.gsub(s, '$(%w+)', function (n) - return tostring(_G[n]), 1 - end)) -end -like(expand("print = $print; a = $a"), "^print = function: [0]?[Xx]?[builtin]*#?%x+; a = nil") - -error_like(function () string.gsub("hello world", '(%w+)', '%2 %2') end, - "^[^:]+:%d+: invalid capture index", - "function gsub (invalid index)") - -error_like(function () string.gsub("hello world", '(%w+)', true) end, - "^[^:]+:%d+: bad argument #3 to 'gsub' %(string/function/table expected%)", - "function gsub (bad type)") - -error_like(function () - function expand (s) - return (string.gsub(s, '$(%w+)', _G)) - end - - name = 'Lua'; status= true - expand("$name is $status, isn't it?") - end, - "^[^:]+:%d+: invalid replacement value %(a boolean%)", - "function gsub (invalid value)") - -is(string.len(''), 0, "function len") -is(string.len('test'), 4) -is(string.len("a\000b\000c"), 5) -is(string.len('"'), 1) - -is(string.lower('Test'), 'test', "function lower") -is(string.lower('TeSt'), 'test') - -s = "hello world" -is(string.match(s, '^hello'), 'hello', "function match") -is(string.match(s, 'world', 2), 'world') -is(string.match(s, 'World'), nil) -eq_array({string.match(s, '^(h.ll.)')}, {'hello'}) -eq_array({string.match(s, '^(h.)l(l.)')}, {'he', 'lo'}) -date = "Today is 17/7/1990" -is(string.match(date, '%d+/%d+/%d+'), '17/7/1990') -eq_array({string.match(date, '(%d+)/(%d+)/(%d+)')}, {'17', '7', '1990'}) -is(string.match("The number 1298 is even", '%d+'), '1298') -pair = "name = Anna" -eq_array({string.match(pair, '(%a+)%s*=%s*(%a+)')}, {'name', 'Anna'}) - -s = [[then he said: "it's all right"!]] -eq_array({string.match(s, "([\"'])(.-)%1")}, {'"', "it's all right"}, "function match (back ref)") -p = "%[(=*)%[(.-)%]%1%]" -s = "a = [=[[[ something ]] ]==]x]=]; print(a)" -eq_array({string.match(s, p)}, {'=', '[[ something ]] ]==]x'}) - -is(string.match(s, "%g"), "a", "match graphic char") - -error_like(function () string.match("hello world", "%1") end, - "^[^:]+:%d+: invalid capture index", - "function match invalid capture") - -error_like(function () string.match("hello world", "%w)") end, - "^[^:]+:%d+: invalid pattern capture", - "function match invalid capture") - -is(string.rep('ab', 3), 'ababab', "function rep") -is(string.rep('ab', 0), '') -is(string.rep('ab', -1), '') -is(string.rep('', 5), '') -is(string.rep('ab', 3, ','), 'ab,ab,ab', "with sep") - -is(string.reverse('abcde'), 'edcba', "function reverse") -is(string.reverse('abcd'), 'dcba') -is(string.reverse(''), '') - -is(string.sub('abcde', 1, 2), 'ab', "function sub") -is(string.sub('abcde', 3, 4), 'cd') -is(string.sub('abcde', -2), 'de') -is(string.sub('abcde', 3, 2), '') - -is(string.upper('Test'), 'TEST', "function upper") -is(string.upper('TeSt'), 'TEST') -is(string.upper(string.rep('Test', 10000)), string.rep('TEST', 10000)) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/305-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/305-table.t deleted file mode 100644 index 0c40f3a5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/305-table.t +++ /dev/null @@ -1,253 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Library - -=head2 Synopsis - - % prove 305-table.t - -=head2 Description - -Tests Lua Table Library - -See "Lua 5.2 Reference Manual", section 6.5 "Table Manipulation", -L. - -See "Programming in Lua", section 19 "The Table Library". - -=cut - ---]] - -require 'Test.More' - -plan(44) - -t = {'a','b','c','d','e'} -is(table.concat(t), 'abcde', "function concat") -is(table.concat(t, ','), 'a,b,c,d,e') -is(table.concat(t, ',',2), 'b,c,d,e') -is(table.concat(t, ',', 2, 4), 'b,c,d') -is(table.concat(t, ',', 4, 2), '') - -t = {'a','b',3,'d','e'} -is(table.concat(t,','), 'a,b,3,d,e', "function concat (number)") - -t = {'a','b','c','d','e'} -error_like(function () table.concat(t, ',', 2, 7) end, - "^[^:]+:%d+: invalid value %(nil%) at index 6 in table for 'concat'", - "function concat (out of range)") - -t = {'a','b',true,'d','e'} -error_like(function () table.concat(t, ',') end, - "^[^:]+:%d+: invalid value %(boolean%) at index 3 in table for 'concat'", - "function concat (non-string)") - -a = {10, 20, 30} -table.insert(a, 1, 15) -is(table.concat(a,','), '15,10,20,30', "function insert") -t = {} -table.insert(t, 'a') -is(table.concat(t, ','), 'a') -table.insert(t, 'b') -is(table.concat(t, ','), 'a,b') -table.insert(t, 1, 'c') -is(table.concat(t, ','), 'c,a,b') -table.insert(t, 2, 'd') -is(table.concat(t, ','), 'c,d,a,b') -table.insert(t, 5, 'e') -is(table.concat(t, ','), 'c,d,a,b,e') - -if jit then - todo("LuaJIT TODO. table.insert.", 2) -end -error_like(function () table.insert(t, 7, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, -9, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, 2, 'g', 'h') end, - "^[^:]+:%d+: wrong number of arguments to 'insert'", - "function insert (too many arg)") - -if (platform and platform.compat) or jit then - t = {} - is(table.maxn(t), 0, "function maxn") - t[1] = 'a' - t[2] = 'b' - is(table.maxn(t), 2) - t[6] = 'g' - is(table.maxn(t), 6) - a = {} - a[10000] = 1 - is(table.maxn(a), 10000) -else - is(table.maxn, nil, "maxn (removed)") - skip("maxn (removed)", 3) -end - -t = table.pack("abc", "def", "ghi") -eq_array(t, { - "abc", - "def", - "ghi" -}, "function pack") -is(t.n, 3) - -t = table.pack() -eq_array(t, {}, "function pack (no element)") -is(t.n, 0) - -t = {} -a = table.remove(t) -is(a, nil, "function remove") -t = {'a','b','c','d','e'} -a = table.remove(t) -is(a, 'e') -is(table.concat(t, ','), 'a,b,c,d') -a = table.remove(t,3) -is(a, 'c') -is(table.concat(t, ','), 'a,b,d') -a = table.remove(t,1) -is(a, 'a') -is(table.concat(t, ','), 'b,d') - -if jit then - todo("LuaJIT TODO. table.remove.", 1) -end -error_like(function () table.remove(t,7) end, - "^[^:]+:%d+: bad argument #1 to 'remove' %(position out of bounds%)", - "function remove (out of bounds)") - -lines = { - luaH_set = 10, - luaH_get = 24, - luaH_present = 48, -} -a = {} -for n in pairs(lines) do a[#a + 1] = n end -table.sort(a) -output = {} -for _, n in ipairs(a) do - table.insert(output, n) -end -eq_array(output, {'luaH_get', 'luaH_present', 'luaH_set'}, "function sort") - -function pairsByKeys (t, f) - local a = {} - for n in pairs(t) do a[#a + 1] = n end - table.sort(a, f) - local i = 0 -- iterator variable - return function () -- iterator function - i = i + 1 - return a[i], t[a[i]] - end -end - -output = {} -for name, line in pairsByKeys(lines) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - -output = {} -for name, line in pairsByKeys(lines, function (a, b) return a < b end) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - - - -function permgen (a, n) - n = n or #a - if n <= 1 then - coroutine.yield(a) - else - for i=1,n do - a[n], a[i] = a[i], a[n] - permgen(a, n - 1) - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () - local code, res = coroutine.resume(co) - return res - end -end - -local t = {} -output = {} -for _, v in ipairs{'a', 'b', 'c', 'd', 'e', 'f', 'g'} do - table.insert(t, v) - local ref = table.concat(t, ' ') - table.insert(output, ref) - local n = 0 - for p in permutations(t) do - local c = {} - for i, v in ipairs(p) do - c[i] = v - end - table.sort(c) - assert(ref == table.concat(c, ' '), table.concat(p, ' ')) - n = n + 1 - end - table.insert(output, n) -end - -eq_array(output, { - 'a', 1, - 'a b', 2, - 'a b c', 6, - 'a b c d', 24, - 'a b c d e', 120, - 'a b c d e f', 720, - 'a b c d e f g', 5040, -}, "function sort (all permutations)") - ---[[ - -MoonSharp: Sort callbacks work --]] - - -error_like(function () - local t = { 1 } - table.sort( { t, t, t, t, }, function (a, b) return a[1] == b[1] end ) - end, - "^[^:]+:%d+: invalid order function for sorting", - "function sort (bad func)") - - -eq_array({table.unpack({})}, {}, "function unpack") -eq_array({table.unpack({'a'})}, {'a'}) -eq_array({table.unpack({'a','b','c'})}, {'a','b','c'}) -eq_array({(table.unpack({'a','b','c'}))}, {'a'}) -eq_array({table.unpack({'a','b','c','d','e'},2,4)}, {'b','c','d'}) -eq_array({table.unpack({'a','b','c'},2,4)}, {'b','c'}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/306-math.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/306-math.t deleted file mode 100644 index c68dac55..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/306-math.t +++ /dev/null @@ -1,153 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Mathematic Library - -=head2 Synopsis - - % prove 306-math.t - -=head2 Description - -Tests Lua Mathematic Library - -See "Lua 5.2 Reference Manual", section 6.6 "Mathematical Functions", -L. - -See "Programming in Lua", section 18 "The Mathematical Library". - -=cut - ---]] - -require 'Test.More' - -plan(47) - -like(tostring(math.pi), '^3%.14', "variable pi") - -type_ok(math.huge, 'number', "variable huge") - -is(math.abs(-12.34), 12.34, "function abs") -is(math.abs(12.34), 12.34) - -like(math.acos(0.5), '^1%.047', "function acos") - -like(math.asin(0.5), '^0%.523', "function asin") - -like(math.atan(0.5), '^0%.463', "function atan") - -like(math.atan2(1, 2), '^0%.463', "function atan2") - -is(math.ceil(12.34), 13, "function ceil") -is(math.ceil(-12.34), -12) - -like(math.cos(0), '^1$', "function cos") - -like(math.cosh(0), '^1$', "function cosh") - -is(math.deg(math.pi), 180, "function deg") - -like(math.exp(1.0), '^2%.718', "function exp") - -is(math.floor(12.34), 12, "function floor") -is(math.floor(-12.34), -13) - -is(math.fmod(7, 3), 1, "function fmod") -is(math.fmod(-7, 3), -1) - -eq_array({math.frexp(1.5)}, {0.75, 1}, "function frexp") - -is(math.ldexp(1.2, 3), 9.6, "function ldexp") - -like(math.log(47), '^3%.85', "function log") -like(math.log(47, 2), '^5%.554', "function log (base 2)") -like(math.log(47, 10), '^1%.672', "function log (base 10)") - -if (platform and platform.compat) or jit then - like(math.log10(47), '^1%.672', "function log10") -else - is(math.log10, nil, "function log10 (removed)") -end - -error_like(function () math.max() end, - "^[^:]+:%d+: bad argument #1 to 'max' %(number expected, got no value%)", - "function max 0") - -is(math.max(1), 1, "function max") -is(math.max(1, 2), 2) -is(math.max(1, 2, 3, -4), 3) - -error_like(function () math.min() end, - "^[^:]+:%d+: bad argument #1 to 'min' %(number expected, got no value%)", - "function min 0") - -is(math.min(1), 1, "function min") -is(math.min(1, 2), 1) -is(math.min(1, 2, 3, -4), -4) - -eq_array({math.modf(2.25)}, {2, 0.25}, "function modf") - -is(math.pow(-2, 3), -8, "function pow") - -like(math.rad(180), '^3%.14', "function rad") - -like(math.random(), '^%d%.%d+', "function random no arg") - -like(math.random(9), '^%d$', "function random 1 arg") - -like(math.random(10, 19), '^1%d$', "function random 2 arg") - ---[[ -MoonSharp : math.random normalizes inputs, and we are happy with that - -if jit then - todo("LuaJIT intentional. Don't check empty interval.", 2) -end -error_like(function () math.random(0) end, - "^[^:]+:%d+: bad argument #1 to 'random' %(interval is empty%)", - "function random empty interval") - -error_like(function () math.random(19, 10) end, - "^[^:]+:%d+: bad argument #2 to 'random' %(interval is empty%)", - "function random empty interval") - -if jit then - todo("LuaJIT intentional. Don't care about extra arguments.") -end -error_like(function () math.random(1, 2, 3) end, - "^[^:]+:%d+: wrong number of arguments", - "function random too many arg") - --]] - -math.randomseed(12) -a = math.random() -math.randomseed(12) -b = math.random() -is(a, b, "function randomseed") - -like(math.sin(math.pi/2), '^1$', "function sin") - -like(math.sinh(1), '^1%.175', "function sinh") - -like(math.sqrt(2), '^1%.414', "function sqrt") - -like(math.tan(math.pi/3), '^1%.732', "function tan") - -like(math.tanh(1), '^0%.761', "function sinh") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/307-bit.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/307-bit.t deleted file mode 100644 index 69487518..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/307-bit.t +++ /dev/null @@ -1,94 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Bitwise Library - -=head2 Synopsis - - % prove 307-bit.t - -=head2 Description - -Tests Lua Bitwise Library - -See "Lua 5.2 Reference Manual", section 6.7 "Bitwise operations", -L. - -=cut - ---]] - -require 'Test.More' - -if jit then - skip_all("LuaJIT. bit32") -end - -plan(20) - -is(bit32.band(0x01, 0x03, 0x07), 0x01, "function band") - -is(bit32.bnot(0x03), (-1 - 0x03) % 2^32, "function bnot") - -is(bit32.bor(0x01, 0x03, 0x07), 0x07, "function bor") - -is(bit32.btest(0x01), true, "function btest") -is(bit32.btest(0x00), false, "function btest") - -is(bit32.bxor(0x01, 0x03, 0x07), 0x05, "function bxor") - -is(bit32.lrotate(0x03, 2), 0x0C, "function lrotate") - -is(bit32.rrotate(0x06, 1), 0x03, "function rrotate") - -is(bit32.arshift(0x06, 1), 0x03, "function arshift") - -is(bit32.arshift(-3, 1), bit32.arshift(-6, 2), "function arshift") - -is(bit32.lshift(0x03, 2), 0x0C, "function lshift") - -is(bit32.rshift(0x06, 1), 0x03, "function rshift") - -is(bit32.extract(0xFFFF, 3, 3), 0x07, "function extract") - -error_like(function () bit32.extract(0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function extract (non-existent bits)") - -error_like(function () bit32.extract(0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #2 to 'extract' %(field cannot be negative%)", - "function extract (negatif field)") - -error_like(function () bit32.extract(0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #3 to 'extract' %(width must be positive%)", - "function extract (negative width)") - -is(bit32.replace(0x0000, 0xFFFF, 3, 3), 0x38, "function replace") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function replace (non-existent bits)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #3 to 'replace' %(field cannot be negative%)", - "function replace (negatif field)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #4 to 'replace' %(width must be positive%)", - "function replace (negative width)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/308-io.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/308-io.t deleted file mode 100644 index 2ca3b852..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/308-io.t +++ /dev/null @@ -1,258 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Input/Output Library - -=head2 Synopsis - - % prove 308-io.t - -=head2 Description - -Tests Lua Input/Output Library - -See "Lua 5.2 Reference Manual", section 6.8 "Input and Output Facilities", -L. - -See "Programming in Lua", section 21 "The I/O Library". - -=cut - ---]] - -require 'Test.More' - -local lua = [[\git\moonsharp\src\Tools\lua52.exe]] - -plan(67) - -like(io.stdin, '^file %(0?[Xx]?%x+%)$', "variable stdin") - -like(io.stdout, '^file %(0?[Xx]?%x+%)$', "variable stdout") - -like(io.stderr, '^file %(0?[Xx]?%x+%)$', "variable stderr") - -r, msg = io.close(io.stderr) -is(r, nil, "close (std)") -is(msg, "cannot close standard file") - -is(io.flush(), true, "function flush") - -os.remove('file.no') -f, msg = io.open("file.no") -is(f, nil, "function open") -is(msg, "file.no: No such file or directory") - -os.remove('file.txt') -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() -f = io.open('file.txt') -like(f, '^file %(0?[Xx]?%x+%)$', "function open") - - -is(io.close(f), true, "function close") - -error_like(function () io.close(f) end, - "^[^:]+:%d+: attempt to use a closed file", - "function close (closed)") - -if jit then - todo("LuaJIT TODO. open mode") -end -error_like(function () io.open('file.txt', 'baz') end, - "^[^:]+:%d+: bad argument #2 to 'open' %(invalid mode%)", - "function open (bad mode)") - - -is(io.type("not a file"), nil, "function type") -f = io.open('file.txt') -is(io.type(f), 'file') -like(tostring(f), '^file %(0?[Xx]?%x+%)$') -io.close(f) -is(io.type(f), 'closed file') -is(tostring(f), 'file (closed)') - -is(io.stdin, io.input(), "function input") -is(io.stdin, io.input(nil)) -f = io.stdin - -like(io.input('file.txt'), '^file %(0?[Xx]?%x+%)$') -is(f, io.input(f)) - -is(io.output(), io.stdout, "function output") -is(io.output(nil), io.stdout) -f = io.stdout -like(io.output('output.new'), '^file %(0?[Xx]?%x+%)$') -is(f, io.output(f)) -os.remove('output.new') - -r, f = pcall(io.popen, lua .. [[ -e "print 'standard output'"]]) -if r then - is(io.type(f), 'file', "popen (read)") - is(f:read(), "standard output") - is(io.close(f), true) -else - skip("io.popen not supported", 3) -end - -r, f = pcall(io.popen, lua .. [[ -e "for line in io.lines() do print((line:gsub('e', 'a'))) end"]], 'w') -if r then - is(io.type(f), 'file', "popen (write)") - f:write("# hello\n") -- not tested : hallo - is(io.close(f), true) -else - skip("io.popen not supported", 2) -end - -for line in io.lines('file.txt') do - is(line, "file with text", "function lines(filename)") -end - -error_like(function () io.lines('file.no') end, - "No such file or directory", - "function lines(no filename)") - -f = io.tmpfile() -is(io.type(f), 'file', "function tmpfile") -f:write("some text") -f:close() - -io.write() -- not tested -io.write('# text', 12, "\n") -- not tested : # text12 - -r, msg = io.stderr:close() -is(r, nil, "method close (std)") -is(msg, "cannot close standard file") - -f = io.open('file.txt') -is(f:close(), true, "method close") - -is(io.stderr:flush(), true, "method flush") - -error_like(function () f:flush() end, - "^[^:]+:%d+: attempt to use a closed file", - "method flush (closed)") - -error_like(function () f:read() end, - "^[^:]+:%d+: attempt to use a closed file", - "method read (closed)") - -f = io.open('file.txt') -s = f:read() -is(s:len(), 14, "method read") -is(s, "file with text") -s = f:read() -is(s, nil) -f:close() - -f = io.open('file.txt') -error_like(function () f:read('*z') end, - "^[^:]+:%d+: bad argument #1 to 'read' %(invalid %w+%)", - "method read (invalid)") -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*l', '*l') -is(s1:len(), 14, "method read *l") -is(s1, "file with text") -is(s2, nil) -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*L', '*L') -is(s1:len(), 15, "method read *L") -is(s1, "file with text\n") -is(s2, nil) -f:close() - -f = io.open('file.txt') -n1, n2 = f:read('*n', '*n') -is(n1, nil, "method read *n") -is(n2, nil) -f:close() - -f = io.open('file.txt') -s = f:read('*a') -is(s:len(), 15, "method read *a") -is(s, "file with text\n") -f:close() - -f = io.open('file.txt') -is(f:read(0), '', "method read number") -eq_array({f:read(5, 5, 15)}, {'file ', 'with ', "text\n"}) --- print(f:read(0)) -f:close() - -f = io.open('file.txt') -for line in f:lines() do - is(line, "file with text", "method lines") -end -is(io.type(f), 'file') -f:close() -is(io.type(f), 'closed file') - -f = io.open('file.txt') -for two_char in f:lines(2) do - is(two_char, "fi", "method lines (with read option)") - break -end -f:close() - -error_like(function () f:seek('end', 0) end, - "^[^:]+:%d+: attempt to use a closed file", - "method seek (closed)") - -f = io.open('file.txt') -error_like(function () f:seek('bad', 0) end, - "^[^:]+:%d+: bad argument #1 to 'seek' %(invalid option 'bad'%)", - "method seek (invalid)") - -f = io.open('file.txt') -if platform and platform.osname == 'MSWin32' then - is(f:seek('end', 0), 16, "method seek") -else - is(f:seek('end', 0), 15, "method seek") -end -f:close() - -f = io.open('file.txt') -is(f:setvbuf('no'), true, "method setvbuf 'no'") - -is(f:setvbuf('full', 4096), true, "method setvbuf 'full'") - -is(f:setvbuf('line', 132), true, "method setvbuf 'line'") -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('file.out', 'w') -f:close() -error_like(function () f:write('end') end, - "^[^:]+:%d+: attempt to use a closed file", - "method write (closed)") - -f = io.open('file.out', 'w') -is(f:write('end'), f, "method write") -f:close() - -os.remove('file.out') --clean up - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - ---]==] - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/309-os.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/309-os.t deleted file mode 100644 index a92ab3f8..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/309-os.t +++ /dev/null @@ -1,202 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Operating System Library - -=head2 Synopsis - - % prove 309-os.t - -=head2 Description - -Tests Lua Operating System Library - -See "Lua 5.2 Reference Manual", section 6.9 "Operating System Facilities", -L. - -See "Programming in Lua", section 22 "The Operating System Library". - -=cut - ---]] - -require 'Test.More' - -plan(54) - -local lua = "lua" - -clk = os.clock() -type_ok(clk, 'number', "function clock") -ok(clk <= os.clock()) - -d = os.date('!*t', 0) -is(d.year, 1970, "function date") -is(d.month, 1) -is(d.day, 1) -is(d.hour, 0) -is(d.min, 0) -is(d.sec, 0) -is(d.wday, 5) -is(d.yday, 1) -is(d.isdst, false) - -is(os.date('!%d/%m/%y %H:%M:%S', 0), '01/01/70 00:00:00', "function date") - -like(os.date('%H:%M:%S'), '^%d%d:%d%d:%d%d', "function date") - -if jit and jit.version_num < 20100 then - todo("LuaJIT TODO. invalid strftime.", 1) -end -is(os.date('%Oy', 0), '70') -if jit then - todo("LuaJIT TODO. invalid strftime.", 1) -end - - - -error_like(function () os.date('%Ja', 0) end, - "^[^:]+:%d+: bad argument #1 to 'date' %(invalid conversion specifier '%%Ja'%)", - "function date (invalid)") - -is(os.difftime(1234, 1200), 34, "function difftime") -is(os.difftime(1234), 1234) - -r = os.execute() -is(r, true, "function execute") - -r, s, n = os.execute('__IMPROBABLE__') -is(r, nil, "function execute") -is(s, 'exit') -type_ok(n, 'number') - ---[===[ -- Tests commented as currently they are more likely to fail because of OS configuration than implementation details - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(2)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 2, "exit value 1") - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(false)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 1, "exit value 2") - --- cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(true, true)"]] --- is(os.execute(cmd), true, "function execute & exit") - -cmd = lua .. [[ -e "print 'reached'; os.exit(); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - code = f:close() - is(code, true, "exit code") -else - skip("io.popen not supported", 3) -end - -cmd = lua .. [[ -e "print 'reached'; os.exit(3); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - r, s, n = f:close() - is(r, nil) - is(s, 'exit', "exit code") - is(n, 3, "exit value 3") -else - skip("io.popen not supported", 5) -end - ---]===] - -is(os.getenv('__IMPROBABLE__'), nil, "function getenv") - -user = os.getenv('LOGNAME') or os.getenv('USERNAME') -type_ok(user, 'string', "function getenv") - -local f = io.open('file.rm', 'w') -f:write("file to remove") -f:close() -r = os.remove("file.rm") -is(r, true, "function remove") - -r, msg = os.remove('file.rm') -is(r, nil, "function remove") -like(msg, '^file.rm: No such file or directory') - -local f = io.open('file.old', 'w') -f:write("file to rename") -f:close() -os.remove('file.new') -r = os.rename('file.old', 'file.new') -is(r, true, "function rename") -os.remove('file.new') -- clean up - -r, msg = os.rename('file.old', 'file.new') -is(r, nil, "function rename") -like(msg, 'No such file or directory') - ---[[ setlocale NOT supported! -is(os.setlocale('C', 'all'), 'C', "function setlocale") -is(os.setlocale(), 'C') - -is(os.setlocale('unk_loc', 'all'), nil, "function setlocale (unknown locale)") - -]] - -like(os.time(), '^%d+%.?%d*$', "function time") - -like(os.time(nil), '^%d+%.?%d*$', "function time") - -like(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 2000, - isdst = 0, -}), '^946%d+$', "function time") - -if platform and platform.intsize == 8 then - todo("pb on 64bit platforms") - -- os.time returns nil when C mktime returns < 0 - -- this test needs a out of range value on any platform -end -is(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 1000, - isdst = 0, -}), nil, "function time -> nil") - -error_like(function () os.time{} end, - "^[^:]+:%d+: field 'day' missing in date table", - "function time (missing field)") - -fname = os.tmpname() -type_ok(fname, 'string', "function tmpname") -ok(fname ~= os.tmpname()) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/310-debug.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/310-debug.t deleted file mode 100644 index 76055802..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/310-debug.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Debug Library - -=head2 Synopsis - - % prove 310-debug.t - -=head2 Description - -Tests Lua Debug Library - -See "Lua 5.2 Reference Manual", section 6.10 "The Debug Library", -L. - -See "Programming in Lua", section 23 "The Debug Library". - -=cut - -]] - -require 'Test.More' - -plan(51) - -debug = require 'debug' - -info = debug.getinfo(is) -type_ok(info, 'table', "function getinfo (function)") -is(info.func, is, " .func") - -info = debug.getinfo(is, 'L') -type_ok(info, 'table', "function getinfo (function, opt)") -type_ok(info.activelines, 'table') - -info = debug.getinfo(1) -type_ok(info, 'table', "function getinfo (level)") -like(info.func, "^function: [0]?[Xx]?%x+", " .func") - -is(debug.getinfo(12), nil, "function getinfo (too depth)") - -error_like(function () debug.getinfo('bad') end, - "bad argument #1 to 'getinfo' %(function or level expected%)", - "function getinfo (bad arg)") - -error_like(function () debug.getinfo(is, 'X') end, - "bad argument #2 to 'getinfo' %(invalid option%)", - "function getinfo (bad opt)") - -local name, value = debug.getlocal(0, 1) -type_ok(name, 'string', "function getlocal (level)") -is(value, 0) - -error_like(function () debug.getlocal(42, 1) end, - "bad argument #1 to 'getlocal' %(level out of range%)", - "function getlocal (out of range)") - -local name, value = debug.getlocal(like, 1) -type_ok(name, 'string', "function getlocal (func)") -is(value, nil) - -t = {} -is(debug.getmetatable(t), nil, "function getmetatable") -t1 = {} -debug.setmetatable(t, t1) -is(debug.getmetatable(t), t1) - -a = true -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -a = 3.14 -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -local reg = debug.getregistry() -type_ok(reg, 'table', "function getregistry") -type_ok(reg._LOADED, 'table') - -local name = debug.getupvalue(plan, 1) -type_ok(name, 'string', "function getupvalue") - -debug.sethook() -hook, mask, count = debug.gethook() -is(hook, nil, "function gethook") -is(mask, '') -is(count, 0) -local function f () end -debug.sethook(f, 'c', 42) -hook , mask, count = debug.gethook() -is(hook, f, "function gethook") -is(mask, 'c') -is(count, 42) - -co = coroutine.create(function () print "thread" end) -hook = debug.gethook(co) -if jit then - todo("LuaJIT TODO. debug.gethook(thread)", 1) -end -is(hook, nil, "function gethook(thread)") - -local name = debug.setlocal(0, 1, 0) -type_ok(name, 'string', "function setlocal (level)") - -local name = debug.setlocal(0, 42, 0) -is(name, nil, "function setlocal (level)") - -error_like(function () debug.setlocal(42, 1, true) end, - "bad argument #1 to 'setlocal' %(level out of range%)", - "function getlocal (out of range)") - -t = {} -t1 = {} -is(debug.setmetatable(t, t1), t, "function setmetatable") -is(getmetatable(t), t1) - -error_like(function () debug.setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected%)") - -local name = debug.setupvalue(plan, 1, require 'Test.Builder':new()) -type_ok(name, 'string', "function setupvalue") - -local name = debug.setupvalue(plan, 42, true) -is(name, nil) - -local u = io.tmpfile() -local old = debug.getuservalue(u) -if jit then - type_ok(old, 'table', "function getuservalue") -else - is(old, nil, "function getuservalue") -end -is(debug.getuservalue(true), nil) -local data = {} -r = debug.setuservalue(u, data) -is(r, u, "function setuservalue") -is(debug.getuservalue(u), data) -r = debug.setuservalue(u, old) -is(debug.getuservalue(u), old) - -error_like(function () debug.setuservalue({}, data) end, - "^[^:]+:%d+: bad argument #1 to 'setuservalue' %(userdata expected, got table%)") - -error_like(function () debug.setuservalue(u, true) end, - "^[^:]+:%d+: bad argument #2 to 'setuservalue' %(table expected, got boolean%)") - -like(debug.traceback(), "^stack traceback:\n", "function traceback") - -like(debug.traceback("message\n"), "^message\n\nstack traceback:\n", "function traceback with message") - -like(debug.traceback(false), "false", "function traceback") - -local id = debug.upvalueid(plan, 1) -type_ok(id, 'userdata', "function upvalueid") - -debug.upvaluejoin (pass, 1, fail, 1) - -error_like(function () debug.upvaluejoin(true, 1, nil, 1) end, - "bad argument #1 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - -error_like(function () debug.upvaluejoin(pass, 1, true, 1) end, - "bad argument #3 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/314-regex.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/314-regex.t deleted file mode 100644 index 89d89142..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/314-regex.t +++ /dev/null @@ -1,346 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Regex Compiler - -=head2 Synopsis - - % prove 314-regex.t - -=head2 Description - -Tests Lua Regex - -Individual tests are stored in the C files in the same directory; -There is one test per line: each test consists of the following -columns (separated by one *or more* tabs): - -=over 4 - -=item pattern - -The Lua regex to test. - -=item target - -The string that will be matched against the pattern. Use '' to indicate -an empty string. - -=item result - -The expected result of the match. - -=item description - -Description of the test. - -=back - -=cut - ---]] - -local test_patterns = { - [===[(a.)..(..) zzzabcdefzzz ab\tef basic match]===], - [===[(a(b(c))(d)) abcd abcd\tbc\tc\td nested match]===], - [===[((%w+)) abcd abcd\tabcd nested match]===], - [===[(a*(.)%w(%s*)) aa!b c aa!b \t!\t nested match]===], - [===[(a?).. abcd a opt]===], - [===[(A?).. abcd '' opt]===], - [===[()aa() flaaap 3\t5 empty capture]===], - [===[(.)%1 bookkeeper o backreference]===], - [===[(%w+)%s+%1 hello hello hello backreference]===], - [===[(.*)x 123x 123 repeated dot capture]===], - [===[$(%w+) $abc= abc not escaped]===], - [===[[c] abcdef c character class]===], - [===[^[a] abcdef a anchored character class]===], - [===[[^e] abcdef a negated character class]===], - [===[^[a]? abcdef a anchored optional character class]===], - [===[[^e]? abcdef a negated optional character class]===], - [===[^[^e] abcdef a anchored negated character class]===], - [===[^[^a] abcdef nil anchored negated character class]===], - [===[[b-d] abcdef b character range]===], - [===[[b-d] abxxef b character range]===], - [===[[b-d] axcxef c character range]===], - [===[[b-d] axxdef d character range]===], - [===[[b-d] axxxef nil character range]===], - [===[[^b-d] abcdef a negated character range]===], - [===[[^b-d] bbccdd nil negated character range]===], - [===[[-] ab-def - unescaped hyphen]===], - [===[[%-] ab-def - escaped hyphen]===], - [===[[%-] abcdef nil escaped hyphen]===], - [===[[^%-] ---x-- x negated escaped hyphen]===], - [===[[^%-] ------ nil negated escaped hyphen]===], - [===[[%-+] ab-def - escaped hyphen in range]===], - [===[[%-+] ab+def + escaped hyphen in range]===], - [===[[%-+] abcdef nil escaped hyphen in range]===], - [===[[+%-] ab-def - escaped hyphen in range]===], - [===[[+%-] ab+def + escaped hyphen in range]===], - [===[[+%-] abcdef nil escaped hyphen in range]===], - [===[[^%-+] ---x-- x negated escaped hyphen in range]===], - [===[[^%-+] ------ nil negated escaped hyphen in range]===], - [===[[^+%-] ---x-- x negated escaped hyphen in range]===], - [===[[^+%-] ------ nil negated escaped hyphen in range]===], - [===[["\\] \\ \ escaped backslash]===], - [===[[%]] ] ] escaped close bracket]===], - [===[[%] \\]] /malformed pattern %(missing ']'%)/ unescaped backslash (or no closing brace)]===], - [===[ab\\cd ab\092cd ab\cd literal match with backslash]===], - [===[%? ab --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Library - -=head2 Synopsis - - % prove 320-stdin.t - -=head2 Description - -Tests Lua Basic & IO Libraries with stdin - -=cut - ---]] - -require 'Test.More' - -local lua = (platform and platform.lua) or arg[-1] - -if not pcall(io.popen, lua .. [[ -e "a=1"]]) then - skip_all "io.popen not supported" -end - -plan(12) - -f = io.open('lib1.lua', 'w') -f:write[[ -function norm (x, y) - return (x^2 + y^2)^0.5 -end - -function twice (x) - return 2*x -end -]] -f:close() - -cmd = lua .. [[ -e "dofile(); n = norm(3.4, 1.0); print(twice(n))" < lib1.lua]] -f = io.popen(cmd) -like(f:read'*l', '^7%.088', "function dofile (stdin)") -f:close() - -os.remove('lib1.lua') -- clean up - -f = io.open('foo.lua', 'w') -f:write[[ -function foo (x) - return x -end -]] -f:close() - -cmd = lua .. [[ -e "f = loadfile(); print(foo); f(); print(foo('ok'))" < foo.lua]] -f = io.popen(cmd) -is(f:read'*l', 'nil', "function loadfile (stdin)") -is(f:read'*l', 'ok') -f:close() - -os.remove('foo.lua') -- clean up - -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() - -cmd = lua .. [[ -e "print(io.read'*l'); print(io.read'*l'); print(io.type(io.stdin))" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.read *l") -is(f:read'*l', 'nil') -is(f:read'*l', 'file') -f:close() - -f = io.open('number.txt', 'w') -f:write("6.0 -3.23 15e12\n") -f:write("4.3 234 1000001\n") -f:close() - -cmd = lua .. [[ -e "while true do local n1, n2, n3 = io.read('*number', '*number', '*number'); if not n1 then break end; print(math.max(n1, n2, n3)) end" < number.txt]] -f = io.popen(cmd) -is(f:read'*l', '15000000000000', "function io:read *number") -is(f:read'*l', '1000001') -f:close() - -os.remove('number.txt') -- clean up - -cmd = lua .. [[ -e "for line in io.lines() do print(line) end" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.lines") -is(f:read'*l', nil) -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('dbg.txt', 'w') -f:write("print 'ok'\n") -f:write("error 'dbg'\n") -f:write("cont\n") -f:close() - -cmd = lua .. [[ -e "debug.debug()" < dbg.txt]] -f = io.popen(cmd) -is(f:read'*l', 'ok', "function debug.debug") -is(f:read'*l', nil) -f:close() - -os.remove('dbg.txt') -- clean up - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Makefile b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Makefile deleted file mode 100644 index 7593592c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Makefile +++ /dev/null @@ -1,67 +0,0 @@ - -LUA = ../../lua-5.2.3/src/lua -LUAJIT = luajit -LUA_COVER = ../../gh-pages/lua-TestMore/lua-5.2.3/src/lua - -LUA_VERSION = $(shell $(LUA) -e "print(_VERSION)") -OSNAME = $(shell perl -MConfig -e "print Config->{osname}") -ARCHNAME = $(shell perl -MConfig -e "print Config->{archname}") -INTSIZE = $(shell perl -MConfig -e "print Config->{longsize}") - -export LUA_PATH=;;../src/?.lua -export LUA_INIT=platform = { osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -version: - @echo $(LUA_VERSION) - -harness: - prove --exec=$(LUA) *.t - -sanity: - prove --exec=$(LUA) 0*.t - -luajit: - prove --exec=$(LUAJIT) *.t - -coverage: - prove --exec=$(LUA_COVER) *.t - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA), $(LUA_VERSION)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: - -prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e '$(upload_pl)' diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/Builder.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/Builder.lua deleted file mode 100644 index 9fc87c9b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/Builder.lua +++ /dev/null @@ -1,392 +0,0 @@ - --- --- lua-TestMore : --- - -local debug = nil; -- require 'debug' -local io = nil; -- require 'io' -local os = nil; -- require 'os' -local error = error -local gsub = require 'string'.gsub -local match = require 'string'.match -local pairs = pairs -local pcall = pcall -local print = print -local rawget = rawget -local setmetatable = setmetatable -local tconcat = require 'table'.concat -local tonumber = tonumber -local tostring = tostring -local type = type - -_ENV = nil -local m = {} - -local testout = io and io.stdout -local testerr = io and (io.stderr or io.stdout) - -function m.puts (f, str) - f:write(str) -end - -local function _print_to_fh (self, f, ...) - -- if f then - -- local msg = tconcat({...}) - -- gsub(msg, "\n", "\n" .. self.indent) - -- m.puts(f, self.indent .. msg .. "\n") - -- else - print(self.indent, ...) - -- end -end - -local function _print (self, ...) - _print_to_fh(self, self:output(), ...) -end - -local function print_comment (self, f, ...) - local arg = {...} - for k, v in pairs(arg) do - arg[k] = tostring(v) - end - local msg = tconcat(arg) - msg = gsub(msg, "\n", "\n# ") - msg = gsub(msg, "\n# \n", "\n#\n") - msg = gsub(msg, "\n# $", '') - _print_to_fh(self, f, "# ", msg) -end - -function m.create () - local o = { - data = setmetatable({}, { __index = m }), - } - setmetatable(o, { - __index = function (t, k) - return rawget(t, 'data')[k] - end, - __newindex = function (t, k, v) - rawget(o, 'data')[k] = v - end, - }) - o:reset() - return o -end - -local test -function m.new () - test = test or m.create() - return test -end - -local function in_todo (self) - return self.todo_upto >= self.curr_test -end - -function m:child (name) - if self.child_name then - error("You already have a child named (" .. self.child_name .. " running") - end - local child = m.create() - child.indent = self.indent .. ' ' - child.out_file = self.out_file - child.fail_file = in_todo(self) and self.todo_file or self.fail_file - child.todo_file = self.todo_file - child.parent = self - self.child_name = name - return child -end - -local function plan_handled (self) - return self.have_plan or self.no_plan or self._skip_all -end - -function m:subtest (name, func) - if type(func) ~= 'function' then - error("subtest()'s second argument must be a function") - end - self:diag('Subtest: ' .. name) - local child = self:child(name) - local parent = self.data - self.data = child.data - local r, msg = pcall(func) - child.data = self.data - self.data = parent - if not r and not child._skip_all then - error(msg, 0) - end - if not plan_handled(child) then - child:done_testing() - end - child:finalize() -end - -function m:finalize () - if not self.parent then - return - end - if self.child_name then - error("Can't call finalize() with child (" .. self.child_name .. " active") - end - local parent = self.parent - local name = parent.child_name - parent.child_name = nil - if self._skip_all then - parent:skip(self._skip_all) - elseif self.curr_test == 0 then - parent:ok(false, "No tests run for subtest \"" .. name .. "\"", 2) - else - parent:ok(self.is_passing, name, 2) - end - self.parent = nil -end - -function m:reset () - self.curr_test = 0 - self._done_testing = false - self.expected_tests = 0 - self.is_passing = true - self.todo_upto = -1 - self.todo_reason = nil - self.have_plan = false - self.no_plan = false - self._skip_all = false - self.have_output_plan = false - self.indent = '' - self.parent = false - self.child_name = false - self:reset_outputs() -end - -local function _output_plan (self, max, directive, reason) - if self.have_output_plan then - error("The plan was already output") - end - local out = "1.." .. max - if directive then - out = out .. " # " .. directive - end - if reason then - out = out .. " " .. reason - end - _print(self, out) - self.have_output_plan = true -end - -function m:plan (arg) - if self.have_plan then - error("You tried to plan twice") - end - if type(arg) == 'string' and arg == 'no_plan' then - self.have_plan = true - self.no_plan = true - return true - elseif type(arg) ~= 'number' then - error("Need a number of tests") - elseif arg < 0 then - error("Number of tests must be a positive integer. You gave it '" .. arg .."'.") - else - self.expected_tests = arg - self.have_plan = true - _output_plan(self, arg) - return arg - end -end - -function m:done_testing (num_tests) - if num_tests then - self.no_plan = false - end - num_tests = num_tests or self.curr_test - if self._done_testing then - tb:ok(false, "done_testing() was already called") - return - end - self._done_testing = true - if self.expected_tests > 0 and num_tests ~= self.expected_tests then - self:ok(false, "planned to run " .. self.expected_tests - .. " but done_testing() expects " .. num_tests) - else - self.expected_tests = num_tests - end - if not self.have_output_plan then - _output_plan(self, num_tests) - end - self.have_plan = true - -- The wrong number of tests were run - if self.expected_tests ~= self.curr_test then - self.is_passing = false - end - -- No tests were run - if self.curr_test == 0 then - self.is_passing = false - end -end - -function m:has_plan () - if self.expected_tests > 0 then - return self.expected_tests - end - if self.no_plan then - return 'no_plan' - end - return nil -end - -function m:skip_all (reason) - if self.have_plan then - error("You tried to plan twice") - end - self._skip_all = reason - _output_plan(self, 0, 'SKIP', reason) - if self.parent then - error("skip_all in child", 0) - end - -- os.exit(0) -end - -local function _check_is_passing_plan (self) - local plan = self:has_plan() - if not plan or not tonumber(plan) then - return - end - if plan < self.curr_test then - self.is_passing = false - end -end - -function m:ok (test, name, level) - if self.child_name then - name = name or 'unnamed test' - self.is_passing = false - error("Cannot run test (" .. name .. ") with active children") - end - name = name or '' - level = level or 0 - self.curr_test = self.curr_test + 1 - name = tostring(name) - if match(name, '^[%d%s]+$') then - self:diag(" You named your test '" .. name .."'. You shouldn't use numbers for your test names." - .. "\n Very confusing.") - end - local out = '' - if not test then - out = "not " - end - out = out .. "ok " .. self.curr_test - if name ~= '' then - out = out .. " - " .. name - end - if self.todo_reason and in_todo(self) then - out = out .. " # TODO " .. self.todo_reason - end - _print(self, out) - if not test then - local msg = in_todo(self) and "Failed (TODO)" or "Failed" - local info = debug and debug.getinfo(3 + level) - if info then - local file = info.short_src - local line = info.currentline - self:diag(" " .. msg .. " test (" .. file .. " at line " .. line .. ")") - else - self:diag(" " .. msg .. " test") - end - end - if not test and not in_todo(self) then - self.is_passing = false - end - _check_is_passing_plan(self) -end - -function m:BAIL_OUT (reason) - local out = "Bail out!" - if reason then - out = out .. " " .. reason - end - _print(self, out) - os.exit(255) -end - -function m:current_test (num) - if num then - self.curr_test = num - end - return self.curr_test -end - -function m:todo (reason, count) - count = count or 1 - self.todo_upto = self.curr_test + count - self.todo_reason = reason -end - -function m:skip (reason) - local name = "# skip" - if reason then - name = name .. " " .. reason - end - self:ok(true, name, 1) -end - -function m:todo_skip (reason) - local name = "# TODO & SKIP" - if reason then - name = name .. " " .. reason - end - self:ok(false, name, 1) -end - -function m:skip_rest (reason) - for i = self.curr_test, self.expected_tests do - tb:skip(reason) - end -end - -local function diag_file (self) - if in_todo(self) then - return self:todo_output() - else - return self:failure_output() - end -end - -function m:diag (...) - print_comment(self, diag_file(self), ...) -end - -function m:note (...) - print_comment(self, self:output(), ...) -end - -function m:output (f) - if f then - self.out_file = f - end - return self.out_file -end - -function m:failure_output (f) - if f then - self.fail_file = f - end - return self.fail_file -end - -function m:todo_output (f) - if f then - self.todo_file = f - end - return self.todo_file -end - -function m:reset_outputs () - self:output(testout) - self:failure_output(testerr) - self:todo_output(testout) -end - -return m --- --- Copyright (c) 2009-2012 Francois Perrad --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/More.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/More.lua deleted file mode 100644 index 9f417ca4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/Modules/Test/More.lua +++ /dev/null @@ -1,383 +0,0 @@ - --- --- lua-TestMore : --- - -local loadstring = loadstring or load -local pairs = pairs -local pcall = pcall -local require = require -local tostring = tostring -local type = type -local match = require 'string'.match -local unpack = require 'table'.unpack or unpack -local _G = _G - -local tb = require 'Test.Builder'.new() - -_ENV = nil -local m = {} - -function m.plan (arg) - tb:plan(arg) -end - -function m.done_testing (num_tests) - tb:done_testing(num_tests) -end - -function m.skip_all (reason) - tb:skip_all(reason) -end - -function m.BAIL_OUT (reason) - tb:BAIL_OUT(reason) -end - -function m.ok (test, name) - tb:ok(test, name) -end - -function m.nok (test, name) - tb:ok(not test, name) -end - -function m.is (got, expected, name) - local pass = got == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: " .. tostring(expected)) - end -end - -function m.isnt (got, expected, name) - local pass = got ~= expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: anything else") - end -end - -function m.like (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end -end - -function m.unlike (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = not match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n matches '" .. pattern .. "'") - end -end - -local cmp = { - ['<'] = function (a, b) return a < b end, - ['<='] = function (a, b) return a <= b end, - ['>'] = function (a, b) return a > b end, - ['>='] = function (a, b) return a >= b end, - ['=='] = function (a, b) return a == b end, - ['~='] = function (a, b) return a ~= b end, -} - -function m.cmp_ok (this, op, that, name) - local f = cmp[op] - if not f then - tb:ok(false, name) - tb:diag("unknown operator : " .. tostring(op)) - return - end - local pass = f(this, that) - tb:ok(pass, name) - if not pass then - tb:diag(" " .. tostring(this) - .. "\n " .. op - .. "\n " .. tostring(that)) - end -end - -function m.type_ok (val, t, name) - if type(t) ~= 'string' then - tb:ok(false, name) - tb:diag("type isn't a string : " .. tostring(t)) - return - end - if type(val) == t then - tb:ok(true, name) - else - tb:ok(false, name) - tb:diag(" " .. tostring(val) .. " isn't a '" .. t .."' it's a '" .. type(val) .. "'") - end -end - -function m.subtest (name, func) - tb:subtest(name, func) -end - -function m.pass (name) - tb:ok(true, name) -end - -function m.fail (name) - tb:ok(false, name) -end - -function m.require_ok (mod) - local r, msg = pcall(require, mod) - tb:ok(r, "require '" .. tostring(mod) .. "'") - if not r then - tb:diag(" " .. msg) - end - return r -end - -function m.eq_array (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - for i = 1, #expected do - local v = expected[i] - local val = got[i] - if val ~= v then - tb:ok(false, name) - tb:diag(" at index: " .. tostring(i) - .. "\n got: " .. tostring(val) - .. "\n expected: " .. tostring(v)) - return - end - end - local extra = #got - #expected - if extra ~= 0 then - tb:ok(false, name) - tb:diag(" " .. tostring(extra) .. " unexpected item(s)") - else - tb:ok(true, name) - end -end - -function m.is_deeply (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - local msg1 - local msg2 - local seen = {} - - local function deep_eq (t1, t2, key_path) - if t1 == t2 or seen[t1] then - return true - end - seen[t1] = true - for k, v2 in pairs(t2) do - local v1 = t1[k] - if type(v1) == 'table' and type(v2) == 'table' then - local r = deep_eq(v1, v2, key_path .. "." .. tostring(k)) - if not r then - return false - end - else - if v1 ~= v2 then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(v1) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - end - for k in pairs(t1) do - local v2 = t2[k] - if v2 == nil then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(t1[k]) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - return true - end -- deep_eq - - local pass = deep_eq(got, expected, '') - tb:ok(pass, name) - if not pass then - tb:diag(" Tables begin differing at:") - tb:diag(" " .. msg1) - tb:diag(" " .. msg2) - end -end - -function m.error_is (code, arg2, arg3, arg4) - local params, expected, name - if type(arg2) == 'table' then - params = arg2 - expected = arg3 - name = arg4 - else - params = {} - expected = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(expected)) - else - local pass = msg == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. msg - .. "\n expected: " .. tostring(expected)) - end - end -end - -function m.error_like (code, arg2, arg3, arg4) - local params, pattern, name - if type(arg2) == 'table' then - params = arg2 - pattern = arg3 - name = arg4 - else - params = {} - pattern = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(pattern)) - else - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - local pass = match(msg, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. msg .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end - end -end - -function m.lives_ok (code, arg2, arg3) - local params, name - if type(arg2) == 'table' then - params = arg2 - name = arg3 - else - params = {} - name = arg2 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - tb:ok(r, name) - if not r then - tb:diag(" " .. msg) - end -end - -function m.diag (msg) - tb:diag(msg) -end - -function m.note (msg) - tb:note(msg) -end - -function m.skip (reason, count) - count = count or 1 - for i = 1, count do - tb:skip(reason) - end -end - -function m.todo_skip (reason, count) - count = count or 1 - for i = 1, count do - tb:todo_skip(reason) - end -end - -function m.skip_rest (reason) - tb:skip_rest(reason) -end - -function m.todo (reason, count) - tb:todo(reason, count) -end - -for k, v in pairs(m) do -- injection - _G[k] = v -end - -m._VERSION = "0.3.1" -m._DESCRIPTION = "lua-TestMore : an Unit Testing Framework" -m._COPYRIGHT = "Copyright (c) 2009-2012 Francois Perrad" -return m --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/makefile.mak b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/makefile.mak deleted file mode 100644 index e593ef85..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/TestMore/makefile.mak +++ /dev/null @@ -1,68 +0,0 @@ -# nmake /F makefile.mak - -LUAJIT = luajit.exe -LUA = lua.exe -LUAC = luac.exe - -RUN_LUA = $(LUA) -RUN_LUAC = $(LUAC) -OSNAME = MSWin32 -ARCHNAME = MSWin32-x86-multi-thread -INTSIZE = 4 - -harness: env - @prove --exec=$(LUA) *.t - -sanity: env - @prove --exec=$(LUA) 0*.t - -luajit: env - @prove --exec=$(LUAJIT) *.t - -llvm-lua: env - @prove --exec=$(LLVM_LUA) *.t - -env: - @set LUA_PATH=;;../src/?.lua - @set LUA_INIT=platform = { lua=[[$(RUN_LUA)]], luac=[[$(RUN_LUAC)]], osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/public_projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/public_projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: env - -@prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e "$(upload_pl)" - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/packages.config b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/packages.config deleted file mode 100644 index 512ce05d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.net40-client/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/MoonSharp.Interpreter.Tests.portable40.csproj b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/MoonSharp.Interpreter.Tests.portable40.csproj deleted file mode 100644 index 90d0a48d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/MoonSharp.Interpreter.Tests.portable40.csproj +++ /dev/null @@ -1,376 +0,0 @@ - - - - Debug - AnyCPU - {CE1E352B-8F70-4C0B-B171-13732CB77F7E} - Library - Properties - MoonSharp.Interpreter.Tests.portable40 - MoonSharp.Interpreter.Tests.portable40 - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - true - ..\..\..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG;HASDYNAMIC,PCL - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;HASDYNAMIC,PCL - prompt - 4 - - - true - bin\Dev\ - TRACE;DEBUG;HASDYNAMIC,PCL - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG;HASDYNAMIC,PCL - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - - 3.5 - - - - - - - - - - - - - - - - - EmbeddableNUnitWrapper.cs - - - BinaryDumpTests.cs - - - ClosureTests.cs - - - CollectionsBaseInterfGenRegisteredTests.cs - - - CollectionsBaseGenRegisteredTests.cs - - - CollectionsRegisteredTests.cs - - - ConfigPropertyAssignerTests.cs - - - CoroutineTests.cs - - - DynamicTests.cs - - - ErrorHandlingTests.cs - - - GotoTests.cs - - - JsonSerializationTests.cs - - - LuaTestSuiteExtract.cs - - - Code - MetatableTests.cs - - - ProxyObjectsTests.cs - - - StringLibTests.cs - - - StructAssignmentTechnique.cs - - - TailCallTests.cs - - - UserDataEventsTests.cs - - - UserDataEnumsTest.cs - - - UserDataNestedTypesTests.cs - - - VarargsTupleTests.cs - - - VtUserDataPropertiesTests.cs - - - VtUserDataOverloadsTests.cs - - - VtUserDataMethodsTests.cs - - - VtUserDataMetaTests.cs - - - VtUserDataIndexerTests.cs - - - VtUserDataFieldsTests.cs - - - UserDataMetaTests.cs - - - UserDataIndexerTests.cs - - - UserDataMethodsTests.cs - - - UserDataOverloadsTests.cs - - - UserDataFieldsTests.cs - - - Code - UserDataPropertiesTests.cs - - - Utils.cs - - - AssemblyInfo.cs - - - SimpleTests.cs - - - TableTests.cs - - - TapRunner.cs - - - TestMoreTests.cs - - - TestRunner.cs - - - BinDumpStreamTests.cs - - - FastStackTests.cs - - - InteropTests.cs - - - _Hardwired.cs - - - - - {49f32476-fca0-45fd-8f89-0c7c0d15e409} - MoonSharp.Interpreter.portable40 - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/Properties/AssemblyInfo.cs deleted file mode 100644 index 5fac58b9..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter.Tests.portable40")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.Tests.portable40")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ae1e3e73-2237-4cc0-89f8-2003e7b61783")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/000-sanity.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/000-sanity.t deleted file mode 100644 index e2de2368..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/000-sanity.t +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua test suite - -=head2 Synopsis - - % prove 000-sanity.t - -=head2 Description - -=cut - -]] - -function f (n) - return n + 1 -end - -function g (m, p) - return m + p -end - -print('1..9') -print("ok 1 -") -print('ok', 2, "- list") -print("ok " .. 3 .. " - concatenation") -i = 4 -print("ok " .. i .. " - var") -i = i + 1 -print("ok " .. i .. " - var incr") -print("ok " .. i+1 .. " - expr") -j = f(i + 1) -print("ok " .. j .. " - call f") -k = g(i, 3) -print("ok " .. k .. " - call g") -local print = print -print("ok 9 - local") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/001-if.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/001-if.t deleted file mode 100644 index b32c4bd7..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/001-if.t +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua if statement - -=head2 Synopsis - - % prove 001-if.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..6") - -if true then - print("ok 1") -else - print("not ok 1") -end - -if not true then - print("not ok 2") -else - print("ok 2") -end - -a = 12 -b = 34 -if a < b then - print("ok 3") -else - print("not ok 3") -end - -a = 0 -b = 4 -if a < b then - print("ok 4") -elseif a == b then - print("not ok 4") -else - print("not ok 4") -end - -a = 5 -b = 5 -if a < b then - print("not ok 5") -elseif a == b then - print("ok 5") -else - print("not ok 5") -end - -a = 10 -b = 6 -if a < b then - print("not ok 6") -elseif a == b then - print("not ok 6") -else - print("ok 6") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/002-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/002-table.t deleted file mode 100644 index acf3bb28..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/002-table.t +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table - -=head2 Synopsis - - % prove 002-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - -]] - -print("1..8") - -a = {"ok 1", "ok 2", "ok 3"} -print(a[1]) -i = 2 -print(a[i]) -print(a[i+1]) -if #a == 3 then - print("ok 4 - len") -else - print("not ok 4") -end -if a[7] == nil then - print("ok 5") -else - print("not ok 5") -end - -t = {a=10, b=100} -if t['a'] == 10 then - print("ok 6") -else - print("not ok 6") -end -if t.b == 100 then - print("ok 7") -else - print("not ok 7") -end -if t.z == nil then - print("ok 8") -else - print("not ok 8") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/011-while.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/011-while.t deleted file mode 100644 index 0c5791d9..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/011-while.t +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua while statement - -=head2 Synopsis - - % prove 011-while.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..11") - -a = {} -local i = 1 -while a[i] do - i = i + 1 -end -if i == 1 then - print("ok 1 - while empty") -else - print("not ok 1 - " .. i) -end - -a = {"ok 2 - while ", "ok 3", "ok 4"} -local i = 1 -while a[i] do - print(a[i]) - i = i + 1 -end - -a = {"ok 5 - with break", "ok 6", "stop", "more"} -local i = 1 -while a[i] do - if a[i] == 'stop' then break end - print(a[i]) - i = i + 1 -end -if i == 3 then - print("ok 7 - break") -else - print("not ok 7 - " .. i) -end - -x = 3 -local i = 1 -while i<=x do - print("ok " .. 7+i) - i = i + 1 -end -if i == 4 then - print("ok 11") -else - print("not ok 11 - " .. i) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/012-repeat.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/012-repeat.t deleted file mode 100644 index 54893b1c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/012-repeat.t +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua repeat statement - -=head2 Synopsis - - % prove 012-repeat.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - -]] - -print("1..8") - -a = {"ok 1 - repeat", "ok 2", "ok 3"} -local i = 0 -repeat - i = i + 1 - if a[i] then - print(a[i]) - end -until not a[i] -if i == 4 then - print("ok 4") -else - print("not ok 4 - " .. i) -end - -a = {"ok 5 - with break", "ok 6", 'stop', 'more'} -local i = 0 -repeat - i = i + 1 - if a[i] == 'stop' then break end - print(a[i]) -until not a[i] -if a[i] == 'stop' then - print("ok 7 - break") -else - print("not ok 7 - " .. a[i]) -end - -function f () return true end - -local i = 1 -repeat - local v = f() - if i == 1 then - print("ok 8 - scope") - else - print("not ok") - break - end - i = i + 1 -until v - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/014-fornum.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/014-fornum.t deleted file mode 100644 index 1cf3e61b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/014-fornum.t +++ /dev/null @@ -1,136 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 014-fornum.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..36") - -for i = 1, 10, 2 do - print("ok " .. (i+1)/2 .. " - for 1, 10, 2") -end - -for i = 1, 10, 2 do - function f () - print("ok " .. (i+11)/2 .. " - for 1, 10, 2 lex") - end - f() -end - -function f (i) - print("ok " .. (i+21)/2 .. " - for 1, 10, 2 !lex") -end -for i = 1, 10, 2 do - f(i) -end - -for i = 3, 5 do - print("ok " .. 13+i .. " - for 3, 5") - i = i + 1 -end - -for i = 5, 1, -1 do - print("ok " .. 24-i .. " - for 5, 1, -1") -end - -for i = 5, 5 do - print("ok " .. 19+i .. " - for 5, 5") -end - -for i = 5, 5, -1 do - print("ok " .. 20+i .. " - for 5, 5, -1") -end - -v = false -for i = 5, 3 do - v = true -end -if v then - print("not ok 26 - for 5, 3") -else - print("ok 26 - for 5, 3") -end - -v = false -for i = 5, 7, -1 do - v = true -end -if v then - print("not ok 27 - for 5, 7, -1") -else - print("ok 27 - for 5, 7, -1") -end - -v = false -for i = 5, 7, 0 do - v = true - break -- avoid infinite loop with luajit -end -if jit then - print("not ok 28 - for 5, 7, 0 # TODO # LuaJIT intentional.") -elseif v then - print("not ok 28 - for 5, 7, 0") -else - print("ok 28 - for 5, 7, 0") -end - -v = nil -for i = 1, 10, 2 do - if i > 4 then break end - print("ok " .. (i+57)/2 .. " - for break") - v = i -end -if v == 3 then - print("ok 31 - break") -else - print("not ok 31 - " .. v) -end - -local function first() return 1 end -local function limit() return 8 end -local function step() return 2 end -for i = first(), limit(), step() do - print("ok " .. (i+63)/2 .. " - with functions") -end - -local a = {} -for i = 1, 10 do - a[i] = function () return i end -end -local v = a[5]() -if v == 5 then - print("ok 36 - for & upval") -else - print("not ok 36 - for & upval") - print("#", v) -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/015-forlist.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/015-forlist.t deleted file mode 100644 index 11aaf992..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/015-forlist.t +++ /dev/null @@ -1,99 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua for statement - -=head2 Synopsis - - % prove 015-forlist.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement", -L. - -See "Programming in Lua", section 4.3 "Control Structures". - -=cut - ---]] - -print("1..18") - -a = {"ok 1 - for ipairs", "ok 2 - for ipairs", "ok 3 - for ipairs"} -for _, v in ipairs(a) do - print(v) -end -for i, v in ipairs(a) do - print("ok " .. 3+i .. " - for ipairs") -end - -r = false -t = {a=10, b=100} -for i, v in ipairs(t) do - print(i, v) - r = true -end -if r then - print("not ok 7 - for ipairs (hash)") -else - print("ok 7 - for ipairs (hash)") -end - -for k in pairs(a) do - print("ok " .. 7+k .. " - for pairs") -end - -local i = 1 -for k in pairs(t) do - if k == 'a' or k == 'b' then - print("ok " .. 10+i .. " - for pairs (hash)") - else - print("not ok " .. 10+i .. " - " .. k) - end - i = i + 1 -end - -a = {"ok 13 - for break", "ok 14 - for break", "stop", "more"} -local i -for _, v in ipairs(a) do - if v == "stop" then break end - print(v) - i = _ -end -if i == 2 then - print("ok 15 - break") -else - print("not ok 15 - " .. i) -end - -local a = {"ok 16 - for & upval", "ok 17 - for & upval", "ok 18 - for & upval"} -local b = {} -for i, v in ipairs(a) do - b[i] = function () return v end -end -for i, v in ipairs(a) do - local r = b[i]() - if r == a[i] then - print(r) - else - print("not " .. a[i]) - print("#", r) - end -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/101-boolean.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/101-boolean.t deleted file mode 100644 index 403f4766..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/101-boolean.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua boolean & coercion - -=head2 Synopsis - - % prove 101-boolean.t - -=head2 Description - -=cut - -]] - -require 'Test.More' - -plan(24) - -error_like(function () return -true end, - "^[^:]+:%d+: attempt to perform arithmetic on a %w+ value", - "-true") - -error_like(function () return #true end, - "^[^:]+:%d+: attempt to get length of a boolean value", - "#true") - -is(not false, true, "not false") - -error_like(function () return true + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true + 10") - -error_like(function () return true - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true - 2") - -error_like(function () return true * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true * 3.14") - -error_like(function () return true / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true / -7") - -error_like(function () return true % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true % 4") - -error_like(function () return true ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "true ^ 3") - -error_like(function () return true .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "true .. 'end'") - -is(true == true, true, "true == true") - -is(true ~= false, true, "true ~= false") - -is(true == 1, false, "true == 1") - -is(true ~= 1, true, "true ~= 1") - -error_like(function () return true < false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true < false") - -error_like(function () return true <= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true <= false") - -error_like(function () return true > false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true > false") - -error_like(function () return true >= false end, - "^[^:]+:%d+: attempt to compare two boolean values", - "true >= false") - -error_like(function () return true < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true < 0") - -error_like(function () return true <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true <= 0") - -error_like(function () return true > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true > 0") - -error_like(function () return true >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "true >= 0") - -error_like(function () a = true; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = true; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/102-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/102-function.t deleted file mode 100644 index 46ab7108..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/102-function.t +++ /dev/null @@ -1,199 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua function & coercion - -=head2 Synopsis - - % prove 102-function.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -f = function () return 1 end - -error_like(function () return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-f") - -error_like(function () f = print; return -f end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return #f end, - "^[^:]+:%d+: attempt to get length of", - "#f") - -error_like(function () f = print; return #f end, - "^[^:]+:%d+: attempt to get length of") - -is(not f, false, "not f") - -is(not print, false) - -error_like(function () return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f + 10") - -error_like(function () f = print; return f + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f - 2") - -error_like(function () f = print; return f - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f * 3.14") - -error_like(function () f = print; return f * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f / -7") - -error_like(function () f = print; return f / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f % 4") - -error_like(function () f = print; return f % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "f ^ 3") - -error_like(function () f = print; return f ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on") - -error_like(function () return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "f .. 'end'") - -error_like(function () f = print; return f .. 'end' end, - "^[^:]+:%d+: attempt to concatenate") - -g = f -is(f == g, true, "f == f") - -g = print -is(g == print, true) - -g = function () return 2 end -is(f ~= g, true, "f ~= g") -h = type -is(f ~= h, true) - -is(print ~= g, true) -is(print ~= h, true) - -is(f == 1, false, "f == 1") - -is(print == 1, false) - -is(f ~= 1, true, "f ~= 1") - -is(print ~= 1, true) - -error_like(function () return f < g end, - "^[^:]+:%d+: attempt to compare two function values", - "f < g") - -error_like(function () f = print; g = type; return f < g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f <= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f <= g") - -error_like(function () f = print; g = type; return f <= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f > g end, - "^[^:]+:%d+: attempt to compare two function values", - "f > g") - -error_like(function () f = print; g = type; return f > g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f >= g end, - "^[^:]+:%d+: attempt to compare two function values", - "f >= g") - -error_like(function () f = print; g = type; return f >= g end, - "^[^:]+:%d+: attempt to compare two function values") - -error_like(function () return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f < 0") - -error_like(function () f = print; return f < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f <= 0") - -error_like(function () f = print; return f <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f > 0") - -error_like(function () f = print; return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () return f > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "f >= 0") - -error_like(function () f = print; return f >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+") - -error_like(function () a = f; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; b = a[1]; end, - "^[^:]+:%d+: attempt to index") - -error_like(function () a = f; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = print; a[1] = 1; end, - "^[^:]+:%d+: attempt to index") - -t = {} -t[print] = true -ok(t[print]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/103-nil.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/103-nil.t deleted file mode 100644 index 904970c6..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/103-nil.t +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua nil & coercion - -=head2 Synopsis - - % prove 103-nil.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(24) - -error_like(function () return -nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "-nil") - -error_like(function () return #nil end, - "^[^:]+:%d+: attempt to get length of a nil value", - "#nil") - -is(not nil, true, "not nil") - -error_like(function () return nil + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil + 10") - -error_like(function () return nil - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil - 2") - -error_like(function () return nil * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil * 3.14") - -error_like(function () return nil / -7 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil / -7") - -error_like(function () return nil % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil % 4") - -error_like(function () return nil ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "nil ^ 3") - -error_like(function () return nil .. 'end' end, - "^[^:]+:%d+: attempt to concatenate a nil value", - "nil .. 'end'") - -is(nil == nil, true, "nil == nil") - -is(nil ~= nil, false, "nil ~= nil") - -is(nil == 1, false, "nil == 1") - -is(nil ~= 1, true, "nil ~= 1") - -error_like(function () return nil < nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil < nil") - -error_like(function () return nil <= nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil <= nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil > nil") - -error_like(function () return nil > nil end, - "^[^:]+:%d+: attempt to compare two nil values", - "nil >= nil") - -error_like(function () return nil < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil < 0") - -error_like(function () return nil <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil <= 0") - -error_like(function () return nil > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil > 0") - -error_like(function () return nil >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "nil >= 0") - -error_like(function () a = nil; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = nil; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/104-number.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/104-number.t deleted file mode 100644 index 32ea3c3e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/104-number.t +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua number & coercion - -=head2 Synopsis - - % prove 104-number.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(54) - -is(-1, -(1), "-1") - -error_like(function () return #1 end, - "^[^:]+:%d+: attempt to get length of a number value", - "#1") - -is(not 1, false, "not 1") - -is(10 + 2, 12, "10 + 2") - -is(2 - 10, -8, "2 - 10") - -is(3.14 * 1, 3.14, "3.14 * 1") - -is(-7 / 0.5, -14, "-7 / 0.5") - -type_ok(1 / 0, 'number', "1 / 0") - -is(-25 % 3, 2, "-25 % 3") - -type_ok(1 % 0, 'number', "1 % 0") - -error_like(function () return 10 + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "10 + true") - -error_like(function () return 2 - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "2 - nil") - -error_like(function () return 3.14 * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3.14 * false") - -error_like(function () return -7 / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "-7 / {}") - -error_like(function () return 3 ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "3 ^ true") - -error_like(function () return -25 % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "-25 % false") - -error_like(function () return 10 + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "10 + 'text'") - -error_like(function () return 2 - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "2 - 'text'") - -error_like(function () return 3.14 * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3.14 * 'text'") - -error_like(function () return -7 / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "-7 / 'text'") - -error_like(function () return 25 % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "25 % 'text'") - -error_like(function () return 3 ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "3 ^ 'text'") - -is(10 + '2', 12, "10 + '2'") - -is(2 - '10', -8, "2 - '10'") - -is(3.14 * '1', 3.14, "3.14 * '1'") - -is(-7 / '0.5', -14, "-7 / '0.5'") - -is(-25 % '3', 2, "-25 % '3'") - -is(3 ^ '3', 27, "3 ^ '3'") - -is(1 .. 'end', '1end', "1 .. 'end'") - -is(1 .. 2, '12', "1 .. 2") - -error_like(function () return 1 .. true end, - "^[^:]+:%d+: attempt to concatenate a %w+ value", - "1 .. true") - -is(1.0 == 1, true, "1.0 == 1") - -is(1 ~= 2, true, "1 ~= 2") - -is(1 == true, false, "1 == true") - -is(1 ~= nil, true, "1 ~= nil") - -is(1 == '1', false, "1 == '1'") - -is(1 ~= '1', true, "1 ~= '1'") - -is(1 < 0, false, "1 < 0") - -is(1 <= 0, false, "1 <= 0") - -is(1 > 0, true, "1 > 0") - -is(1 >= 0, true, "1 >= 0") - -error_like(function () return 1 < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < false") - -error_like(function () return 1 <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= nil") - -error_like(function () return 1 > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > true") - -error_like(function () return 1 >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= {}") - -error_like(function () return 1 < '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 < '0'") - -error_like(function () return 1 <= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 <= '0'") - -error_like(function () return 1 > '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 > '0'") - -error_like(function () return 1 >= '0' end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "1 >= '0'") - -is(tostring(1000000000), '1000000000', "number 1000000000") - -is(tostring(1e9), '1000000000', "number 1e9") - -is(tostring(1.0e+9), '1000000000', "number 1.0e+9") - -error_like(function () a= 3.14; b = a[1]; end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () a = 3.14; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/105-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/105-string.t deleted file mode 100644 index 3162bb74..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/105-string.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua string & coercion - -=head2 Synopsis - - % prove 105-string.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(51) - -is(- '1', -1, "-'1'") - -error_like(function () return - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on .- string value", - "-'text'") - -is(# 'text', 4, "#'text'") - -is(not 'text', false, "not 'text'") - -is('10' + 2, 12, "'10' + 2") - -is('2' - 10, -8, "'2' - 10") - -is('3.14' * 1, 3.14, "'3.14' * 1") - -is('-7' / 0.5, -14, "'-7' / 0.5") - -is('-25' % 3, 2, "'-25' % 3") - -is('3' ^ 3, 27, "'3' ^ 3") - -error_like(function () return '10' + true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'10' + true") - -error_like(function () return '2' - nil end, - "^[^:]+:%d+: attempt to perform arithmetic on a nil value", - "'2' - nil") - -error_like(function () return '3.14' * false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3.14' * false") - -error_like(function () return '-7' / {} end, - "^[^:]+:%d+: attempt to perform arithmetic on a table value", - "'-7' / {}") - -error_like(function () return '-25' % false end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'-25' % false") - -error_like(function () return '3' ^ true end, - "^[^:]+:%d+: attempt to perform arithmetic on a boolean value", - "'3' ^ true") - -error_like(function () return '10' + 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'10' + 'text'") - -error_like(function () return '2' - 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'2' - 'text'") - -error_like(function () return '3.14' * 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3.14' * 'text'") - -error_like(function () return '-7' / 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-7' / 'text'") - -error_like(function () return '-25' % 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'-25' % 'text'") - -error_like(function () return '3' ^ 'text' end, - "^[^:]+:%d+: attempt to perform arithmetic on a string value", - "'3' ^ 'text'") - -is('10' + '2', 12, "'10' + '2'") - -is('2' - '10', -8, "'2' - '10'") - -is('3.14' * '1', 3.14, "'3.14' * '1'") - -is('-7' / '0.5', -14, "'-7' / '0.5'") - -is('-25' % '3', 2, "'-25' % '3'") - -is('3' ^ '3', 27, "'3' ^ '3'") - -is('1' .. 'end', '1end', "'1' .. 'end'") - -is('1' .. 2, '12', "'1' .. 2") - -error_like(function () return '1' .. true end, - "^[^:]+:%d+: attempt to concatenate a boolean value", - "'1' .. true") - -is('1.0' == '1', false, "'1.0' == '1'") - -is('1' ~= '2', true, "'1' ~= '2'") - -is('1' == true, false, "'1' == true") - -is('1' ~= nil, true, "'1' ~= nil") - -is('1' == 1, false, "'1' == 1") - -is('1' ~= 1, true, "'1' ~= 1") - -is('1' < '0', false, "'1' < '0'") - -is('1' <= '0', false, "'1' <= '0'") - -is('1' > '0', true, "'1' > '0'") - -is('1' >= '0', true, "'1' >= '0'") - -error_like(function () return '1' < false end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < false") - -error_like(function () return '1' <= nil end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= nil") - -error_like(function () return '1' > true end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > true") - -error_like(function () return '1' >= {} end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >= {}") - -error_like(function () return '1' < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' < 0") - -error_like(function () return '1' <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' <= 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' > 0") - -error_like(function () return '1' > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "'1' >== 0") - -a = 'text' -is(a[1], nil, "index") - -error_like(function () a = 'text'; a[1] = 1; end, - "^[^:]+:%d+: attempt to index", - "index") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/106-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/106-table.t deleted file mode 100644 index 20725fb5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/106-table.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua table & coercion - -=head2 Synopsis - - % prove 106-table.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(28) - -error_like(function () return -{} end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-{}") - -is(# {}, 0, "#{}") -is(# {4,5,6}, 3) - -is(not {}, false, "not {}") - -error_like(function () return {} + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} + 10") - -error_like(function () return {} - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} - 2") - -error_like(function () return {} * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} * 3.14") - -error_like(function () return {} / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} / 7") - -error_like(function () return {} % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} % 4") - -error_like(function () return {} ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "{} ^ 3") - -error_like(function () return {} .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "{} .. 'end'") - -is({} == {}, false, "{} == {}") - -t1 = {} -t2 = {} -is(t1 == t1, true, "t1 == t1") -is(t1 == t2, false, "t1 == t2") -is(t1 ~= t2, true, "t1 ~= t2") - -is({} == 1, false, "{} == 1") - -is({} ~= 1, true, "{} ~= 1") - -error_like(function () return t1 < t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 < t2") - -error_like(function () return t1 <= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 <= t2") - -error_like(function () return t1 > t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 > t2") - -error_like(function () return t1 >= t2 end, - "^[^:]+:%d+: attempt to compare two table values", - "t1 >= t2") - -error_like(function () return {} < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} < 0") - -error_like(function () return {} <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} <= 0") - -error_like(function () return {} > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} > 0") - -error_like(function () return {} >= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "{} >= 0") - -t = {} -is( t[1], nil, "index" ) -t[1] = 42 -is( t[1], 42, "index" ) - -error_like(function () t = {}; t[nil] = 42 end, - "^[^:]+:%d+: table index is nil", - "table index is nil") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/107-thread.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/107-thread.t deleted file mode 100644 index fffedec0..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/107-thread.t +++ /dev/null @@ -1,128 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua thread & coercion - -=head2 Synopsis - - % prove 107-thread.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -co = coroutine.create(function () return 1 end) - -error_like(function () return -co end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-co") - -error_like(function () return #co end, - "^[^:]+:%d+: attempt to get length of", - "#co") - -is(not co, false, "not co") - -error_like(function () return co + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co + 10") - -error_like(function () return co - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co - 2") - -error_like(function () return co * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co * 3.14") - -error_like(function () return co / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co / 7") - -error_like(function () return co % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co % 4") - -error_like(function () return co ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "co ^ 3") - -error_like(function () return co .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "co .. 'end'") - -is(co == co, true, "co == co") - -co1 = coroutine.create(function () return 1 end) -co2 = coroutine.create(function () return 2 end) -is(co1 ~= co2, true, "co1 ~= co2") - -is(co == 1, false, "co == 1") - -is(co ~= 1, true, "co ~= 1") - -error_like(function () return co1 < co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 < co2") - -error_like(function () return co1 <= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 <= co2") - -error_like(function () return co1 > co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 > co2") - -error_like(function () return co1 >= co2 end, - "^[^:]+:%d+: attempt to compare two thread values", - "co1 >= co2") - -error_like(function () return co < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co < 0") - -error_like(function () return co <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co <= 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co > 0") - -error_like(function () return co > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "co >= 0") - -error_like(function () a = co[1] end, - "^[^:]+:%d+: attempt to index", - "index") - -error_like(function () co[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[co] = true -ok(t[co]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/108-userdata.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/108-userdata.t deleted file mode 100644 index c27ced46..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/108-userdata.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua userdata & coercion - -=head2 Synopsis - - % prove 108-userdata.t - -=head2 Description - -=cut - ---]] - -require 'Test.More' - -plan(25) - -u = io.stdin - -error_like(function () return -u end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "-u") - -error_like(function () return #u end, - "^[^:]+:%d+: attempt to get length of", - "#u") - -is(not u, false, "not u") - -error_like(function () return u + 10 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u + 10") - -error_like(function () return u - 2 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u - 2") - -error_like(function () return u * 3.14 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u * 3.14") - -error_like(function () return u / 7 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u / 7") - -error_like(function () return u % 4 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u % 4") - -error_like(function () return u ^ 3 end, - "^[^:]+:%d+: attempt to perform arithmetic on", - "u ^ 3") - -error_like(function () return u .. 'end' end, - "^[^:]+:%d+: attempt to concatenate", - "u .. 'end'") - -is(u == u, true, "u == u") - -v = io.stdout -is(u ~= v, true, "u ~= v") - -is(u == 1, false, "u == 1") - -is(u ~= 1, true, "u ~= 1") - -error_like(function () return u < v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u < v") - -error_like(function () return u <= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u <= v") - -error_like(function () return u > v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u > v") - -error_like(function () return u >= v end, - "^[^:]+:%d+: attempt to compare two userdata values", - "u >= v") - -error_like(function () return u < 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u < 0") - -error_like(function () return u <= 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u <= 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u > 0") - -error_like(function () return u > 0 end, - "^[^:]+:%d+: attempt to compare %w+ with %w+", - "u >= 0") - -is(u[1], nil, "index") - -error_like(function () u[1] = 1 end, - "^[^:]+:%d+: attempt to index", - "index") - -t = {} -t[u] = true -ok(t[u]) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/200-examples.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/200-examples.t deleted file mode 100644 index 200dc4b5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/200-examples.t +++ /dev/null @@ -1,104 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 some Lua code examples - -=head2 Synopsis - - % prove 200-examples.t - -=head2 Description - -First tests in order to check infrastructure. - -=cut - ---]] - -require 'Test.More' - -plan(5) - -function factorial (n) - if n == 0 then - return 1 - else - return n * factorial(n-1) - end -end -is(factorial(7), 5040, "factorial (recursive)") - -local function local_factorial (n) - if n == 0 then - return 1 - else - return n * local_factorial(n-1) - end -end -is(local_factorial(7), 5040, "factorial (recursive)") - -function loop_factorial (n) - local a = 1 - for i = 1, n, 1 do - a = a*i - end - return a -end -is(loop_factorial(7), 5040, "factorial (loop)") - -function iter_factorial (n) - local function iter (product, counter) - if counter > n then - return product - else - return iter(counter*product, counter+1) - end - end - return iter(1, 1) -end -is(iter_factorial(7), 5040, "factorial (iter)") - ---[[ - - Knuth's "man or boy" test. - See http://en.wikipedia.org/wiki/Man_or_boy_test - -]] - -local function A (k, x1, x2, x3, x4, x5) - local function B () - k = k - 1 - return A(k, B, x1, x2, x3, x4) - end - if k <= 0 then - return x4() + x5() - else - return B() - end -end - -is(A(10, - function () return 1 end, - function () return -1 end, - function () return -1 end, - function () return 1 end, - function () return 0 end), - -67, - "man or boy" -) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/201-assign.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/201-assign.t deleted file mode 100644 index c245815a..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/201-assign.t +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua assignment - -=head2 Synopsis - - % prove 201-assign.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.3.3 "Assignment", -L. - -See "Programming in Lua", section 4.1 "Assignment". - -=cut - ---]] - -require 'Test.More' - -plan(38) - -is(b, nil, "global variable") -b = 10 -is(b, 10) -if jit then - skip("LuaJIT intentional. _ENV.", 3) -else - is(_ENV.b, 10, "_ENV") - is(_G, _ENV, "_G") - error_like([[ _ENV = nil; b = 20 ]], - "^[^:]+:%d+: attempt to index a nil value") -end -b = nil -is(b, nil) - -a = {} -i = 3 -i, a[i] = i+1, 20 --- this behavior is undefined --- see http://lua-users.org/lists/lua-l/2006-06/msg00378.html --- is(i, 4, "check eval") --- is(a[3], 20) - -x = 1. -y = 2. -x, y = y, x -- swap -is(x, 2, "check swap") -is(y, 1) - -a, b, c = 0, 1 -is(a, 0, "check padding") -is(b, 1) -is(c, nil) -a, b = a+1, b+1, a+b -is(a, 1) -is(b, 2) -a, b, c = 0 -is(a, 0) -is(b, nil) -is(c, nil) - -function f() return 1, 2 end -a, b, c, d = f() -is(a, 1, "adjust with function") -is(b, 2) -is(c, nil) -is(d, nil) - -function f() print('# f') end -a = 2 -a, b, c = f(), 3 -is(a, nil, "padding with function") -is(b, 3) -is(c, nil) - -local my_i = 1 -is(my_i, 1, "local variable") -local my_i = 2 -is(my_i, 2) - -local i = 1 -local j = i -is(i, 1, "local variable") -is(j, 1) -j = 2 -is(i, 1) -is(j, 2) - -local function f(x) return 2*x end -is(f(2), 4, "param & result of function") -a = 2 -a = f(a) -is(a, 4) -local b = 2 -b = f(b) -is(b, 4) - -local n1 = 1 -local n2 = 2 -local n3 = 3 -local n4 = 4 -n1,n2,n3,n4 = n4,n3,n2,n1 -is(n1, 4, "assignment list swap values") -is(n2, 3) -is(n3, 2) -is(n4, 1) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/202-expr.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/202-expr.t deleted file mode 100644 index 3d03f115..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/202-expr.t +++ /dev/null @@ -1,111 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua expression - -=head2 Synopsis - - % prove 202-expr.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4 "Expressions", -L. - -See "Programming in Lua", section 3 "Expressions". - -=cut - ---]] - -require 'Test.More' - -plan(39) - -x = math.pi -is(x - x%0.01, 3.14, "modulo") - -a = {}; a.x = 1; a.y = 0; -b = {}; b.x = 1; b.y = 0; -c = a -is(a == c, true, "relational op (by reference)") -is(a ~= b, true) - -is('0' == 0, false, "relational op") -is(2 < 15, true) -is('2' < '15', false) - -error_like(function () return 2 < '15' end, - "compare", - "relational op") - -error_like(function () return '2' < 15 end, - "compare", - "relational op") - -is(4 and 5, 5, "logical op") -is(nil and 13, nil) -is(false and 13, false) -is(4 or 5, 4) -is(false or 5, 5) -is(false or 'text', 'text') - -is(10 or 20, 10, "logical op") -is(10 or error(), 10) -is(nil or 'a', 'a') -is(nil and 10, nil) -is(false and error(), false) -is(false and nil, false) -is(false or nil, nil) -is(10 and 20, 20) - -is(not nil, true, "logical not") -is(not false, true) -is(not 0, false) -is(not not nil, false) -is(not 'text', false) -a = {} -is(not a, false) - -is("Hello " .. "World", "Hello World", "concatenation") -is(0 .. 1, '01') -a = "Hello" -is(a .. " World", "Hello World") -is(a, "Hello") - -is('10' + 1, 11, "coercion") -is('-5.3' * '2', -10.6) -is(10 .. 20, '1020') -is(tostring(10), '10') -is(10 .. '', '10') - -error_like(function () return 'hello' + 1 end, - "perform arithmetic", - "no coercion") - -error_like(function () - local function first() return 1 end - local function limit() return end - local function step() return 2 end - for i = first(), limit(), step() do - print(i) - end - end, - "^[^:]+:%d+: 'for' limit must be a number", - "for tonumber") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/203-lexico.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/203-lexico.t deleted file mode 100644 index d735f2b4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/203-lexico.t +++ /dev/null @@ -1,122 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Lexicography - -=head2 Synopsis - - % prove 203-lexico.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.1 "Lexical Conventions", -L. - -=cut - ---]] - -require 'Test.More' - -plan(40) - -is("\65", "A") -is("\065", "A") -is("\x41", "A") -is("\x3d", "=") -is("\x3D", "=") - -is(string.byte("\a"), 7) -is(string.byte("\b"), 8) -is(string.byte("\f"), 12) -is(string.byte("\n"), 10) -is(string.byte("\r"), 13) -is(string.byte("\t"), 9) -is(string.byte("\v"), 11) -is(string.byte("\\"), 92) - -is(string.len("A\0B"), 3) - -f, msg = load [[a = "A\300"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = "A\xyz"]] -like(msg, "^[^:]+:%d+: .- near") - -f, msg = load [[a = "A\Z"]] -like(msg, "^[^:]+:%d+: .- escape .- near") - -f, msg = load [[a = " unfinished string ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \ -]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load [[a = " unfinished string \]] -like(msg, "^[^:]+:%d+: unfinished string near") - -f, msg = load "a = [[ unfinished long string " -like(msg, "^[^:]+:%d+: unfinished long string near") - -f, msg = load "a = [== invalid long string delimiter " -like(msg, "^[^:]+:%d+: invalid long string delimiter near") - -a = 'alo\n123"' -is('alo\n123"', a) -is("alo\n123\"", a) -is('\97lo\10\04923"', a) -is([[alo -123"]], a) -is([==[ -alo -123"]==], a) -is("alo\n\z -123\"", a) - -f, msg = load [[a = " escape \z unauthorized -new line" ]] -like(msg, "^[^:]+:%d+: unfinished string near") - -is(3.0, 3) -is(314.16e-2, 3.1416) -is(0.31416E1, 3.1416) -is(0xff, 255) -is(0x56, 86) -is(0x0.1E, 0x1E / 0x100) -- 0.1171875 -is(0xA23p-4, 0xA23 / (2^4)) -- 162.1875 -is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2) - -f, msg = load [[a = 12e34e56]] -like(msg, "^[^:]+:%d+: malformed number near") - ---[===[ ---[[ ---[=[ - nested long comments ---]=] ---]] ---]===] - -f, msg = load " --[[ unfinished long comment " -like(msg, "^[^:]+:%d+: unfinished long comment near") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/204-grammar.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/204-grammar.t deleted file mode 100644 index 86636ff2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/204-grammar.t +++ /dev/null @@ -1,106 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Grammar - -=head2 Synopsis - - % prove 204-grammar.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 9 "The Complete Syntax of Lua", -L. - -=cut - ---]] - -require 'Test.More' - -plan(6) - ---[[ empty statement ]] -f, msg = load [[; a = 1]] -type_ok(f, 'function', "empty statement") - ---[[ orphan break ]] -f, msg = load [[ -function f() - print "before" - do - print "inner" - break - end - print "after" -end -]] -if jit then - like(msg, "^[^:]+:%d+: no loop to break", "orphan break") -else - like(msg, "^[^:]+:%d+: at line 5 not inside a loop", "orphan break") -end - ---[[ break anywhere ]] -lives_ok( [[ -function f() - print "before" - while true do - print "inner" - break - print "break" - end - print "after" -end -]], "break anywhere") - ---[[ goto ]] -f, msg = load [[ -::label:: -goto unknown -]] -if jit then - like(msg, ":%d+: undefined label 'unknown'", "unknown goto") -else - like(msg, ":%d+: no visible label 'unknown' for at line %d+", "unknown goto") -end - -f, msg = load [[ -::label:: -goto label -::label:: -]] -if jit then - like(msg, ":%d+: duplicate label 'label'", "duplicate label") -else - like(msg, ":%d+: label 'label' already defined on line %d+", "duplicate label") -end - -f, msg = load [[ -::e:: -goto f -local x -::f:: -goto e -]] -if jit then - like(msg, ":%d+: jumps into the scope of local 'x'", "bad goto") -else - like(msg, ":%d+: at line %d+ jumps into the scope of local 'x'", "bad goto") -end - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/211-scope.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/211-scope.t deleted file mode 100644 index 0781c985..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/211-scope.t +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua scope - -=head2 Synopsis - - % prove 211-scope.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 4.2 "Local Variables and Blocks". - -=cut - ---]] - -require 'Test.More' - -plan(10) - ---[[ scope ]] -x = 10 -do - local x = x - is(x, 10, "scope") - x = x + 1 - do - local x = x + 1 - is(x, 12) - end - is(x, 11) -end -is(x, 10) - ---[[ scope ]] -x = 10 -local i = 1 - -while i<=x do - local x = i*2 --- print(x) - i = i + 1 -end - -if i > 20 then - local x - x = 20 - nok("scope") -else - is(x, 10, "scope") -end - -is(x, 10) - ---[[ scope ]] -local a, b = 1, 10 -if a < b then - is(a, 1, "scope") - local a - is(a, nil) -end -is(a, 1) -is(b, 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/212-function.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/212-function.t deleted file mode 100644 index 9882884e..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/212-function.t +++ /dev/null @@ -1,268 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua functions - -=head2 Synopsis - - % prove 212-function.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.10 "Function Definitions", -L. - -See "Programming in Lua", section 5 "Functions". - -=cut - ---]] - -require 'Test.More' - -plan(63) - ---[[ add ]] -function add (a) - local sum = 0 - for i,v in ipairs(a) do - sum = sum + v - end - return sum -end - -t = { 10, 20, 30, 40 } -is(add(t), 100, "add") - ---[[ f ]] -function f(a, b) return a or b end - -is(f(3), 3, "f") -is(f(3, 4), 3) -is(f(3, 4, 5), 3) - ---[[ incCount ]] -count = 0 - -function incCount (n) - n = n or 1 - count = count + n -end - -is(count, 0, "inCount") -incCount() -is(count, 1) -incCount(2) -is(count, 3) -incCount(1) -is(count, 4) - ---[[ maximum ]] -function maximum (a) - local mi = 1 -- maximum index - local m = a[mi] -- maximum value - for i,val in ipairs(a) do - if val > m then - mi = i - m = val - end - end - return m, mi -end - -local m, mi = maximum({8,10,23,12,5}) -is(m, 23, "maximum") -is(mi, 3) - ---[[ call by value ]] -function f (n) - n = n - 1 - return n -end - -a = 12 -is(a, 12, "call by value") -b = f(a) -is(b, 11) -is(a, 12) -c = f(12) -is(c, 11) -is(a, 12) - ---[[ call by ref ]] -function f (t) - t[#t+1] = 'end' - return t -end - -a = { 'a', 'b', 'c' } -is(table.concat(a, ','), 'a,b,c', "call by ref") -b = f(a) -is(table.concat(b, ','), 'a,b,c,end') -is(table.concat(a, ','), 'a,b,c,end') - ---[[ var args ]] -local function g(a, b, ...) - local arg = {...} - is(a, 3, "vararg") - is(b, nil) - is(#arg, 0) - is(arg[1], nil) -end -g(3) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 0) - is(arg[1], nil) -end -g(3, 4) - -local function g(a, b, ...) - local arg = {...} - is(a, 3) - is(b, 4) - is(#arg, 2) - is(arg[1], 5) - is(arg[2], 8) -end -g(3, 4, 5, 8) - ---[[ var args ]] -local function g(a, b, ...) - local c, d, e = ... - is(a, 3, "var args") - is(b, nil) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, nil) - is(d, nil) - is(e, nil) -end -g(3, 4) - -local function g(a, b, ...) - local c, d, e = ... - is(a, 3) - is(b, 4) - is(c, 5) - is(d, 8) - is(e, nil) -end - ---[[ var args ]] -local function g(a, b, ...) - is(#{a, b, ...}, 1, "varargs") -end -g(3) - -local function g(a, b, ...) - is(#{a, b, ...}, 2) -end -g(3, 4) - -local function g(a, b, ...) - is(#{a, b, ...}, 4) -end -g(3, 4, 5, 8) - ---[[ var args ]] -function f() return 1, 2 end -function g() return 'a', f() end -function h() return f(), 'b' end -function k() return 'c', (f()) end - -x, y = f() -is(x, 1, "var args") -is(y, 2) -x, y, z = g() -is(x, 'a') -is(y, 1) -is(z, 2) -x, y = h() -is(x, 1) -is(y, 'b') -x, y, z = k() -is(x, 'c') -is(y, 1) -is(z, nil) - - ---[[ invalid var args ]] -f, msg = load [[ -function f () - print(...) -end -]] -like(msg, "^[^:]+:%d+: cannot use '...' outside a vararg function", "invalid var args") - ---[[ tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return foo(n -1) - end - return 'end', 0 -end - -eq_array({foo(3)}, {'end', 0}, "tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - return (foo(n -1)) - end - return 'end', 0 -end - -is(foo(3), 'end', "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ no tail call ]] -output = {} -local function foo (n) - output[#output+1] = n - if n > 0 then - foo(n -1) - end -end - -is(foo(3), nil, "no tail call") -eq_array(output, {3, 2, 1, 0}) - ---[[ sub name ]] -local function f () return 1 end -is(f(), 1, "sub name") - -local function f () return 2 end -is(f(), 2) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/213-closure.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/213-closure.t deleted file mode 100644 index 31ab2033..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/213-closure.t +++ /dev/null @@ -1,98 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua closures - -=head2 Synopsis - - % prove 213-closure.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules", -L. - -See "Programming in Lua", section 6.1 "Closures". - -=cut - ---]] - -require 'Test.More' - -plan(15) - ---[[ inc ]] -local counter = 0 - -function inc (x) - counter = counter + x - return counter -end - -is(inc(1), 1, "inc") -is(inc(2), 3) - ---[[ newCounter ]] -function newCounter () - local i = 0 - return function () -- anonymous function - i = i + 1 - return i - end -end - -c1 = newCounter() -is(c1(), 1, "newCounter") -is(c1(), 2) - -c2 = newCounter() -is(c2(), 1) -is(c1(), 3) -is(c2(), 2) - ---[[ -The loop creates ten closures (that is, ten instances of the anonymous -function). Each of these closures uses a different y variable, while all -of them share the same x. -]] -a = {} -local x = 20 -for i=1,10 do - local y = 0 - a[i] = function () y=y+1; return x+y end -end - -is(a[1](), 21, "ten closures") -is(a[1](), 22) -is(a[2](), 21) - - ---[[ add ]] -function add(x) - return function (y) return (x + y) end -end - -f = add(2) -type_ok(f, 'function', "add") -is(f(10), 12) -g = add(5) -is(g(1), 6) -is(g(10), 15) -is(f(1), 3) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/214-coroutine.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/214-coroutine.t deleted file mode 100644 index ed2144c2..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/214-coroutine.t +++ /dev/null @@ -1,193 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua coroutines - -=head2 Synopsis - - % prove 214-coroutine.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.6 "Coroutines", -L. - -See "Programming in Lua", section 9 "Coroutines". - -=cut - ---]] - -require 'Test.More' - -plan(30) - ---[[ ]] -output = {} - -function foo1 (a) - output[#output+1] = "foo " .. a - return coroutine.yield(2*a) -end - -co = coroutine.create(function (a,b) - output[#output+1] = "co-body " .. a .." " .. b - local r = foo1(a+1) - output[#output+1] = "co-body " .. r - local r, s = coroutine.yield(a+b, a-b) - output[#output+1] = "co-body " .. r .. " " .. s - return b, 'end' - end) - -eq_array({coroutine.resume(co, 1, 10)}, {true, 4}, "foo1") -eq_array({coroutine.resume(co, 'r')}, {true, 11, -9}) -eq_array({coroutine.resume(co, "x", "y")}, {true, 10, 'end'}) -eq_array({coroutine.resume(co, "x", "y")}, {false, "cannot resume dead coroutine"}) -eq_array(output, { - 'co-body 1 10', - 'foo 2', - 'co-body r', - 'co-body x y', -}) - ---[[ ]] -co = coroutine.create(function () - output = 'hi' - end) -like(co, '^thread: 0?[Xx]?%x+$', "basics") - -is(coroutine.status(co), 'suspended') -output = '' -coroutine.resume(co) -is(output, 'hi') -is(coroutine.status(co), 'dead') - -error_like(function () coroutine.create(true) end, - "^[^:]+:%d+: bad argument #1 to 'create' %(function expected, got boolean%)") - -error_like(function () coroutine.resume(true) end, - "^[^:]+:%d+: bad argument #1 to 'resume' %(coroutine expected, got boolean%)") - -error_like(function () coroutine.status(true) end, - "^[^:]+:%d+: bad argument #1 to 'status' %(coroutine expected, got boolean%)") - ---[[ ]] -output = {} -co = coroutine.create(function () - for i=1,10 do - output[#output+1] = i - coroutine.yield() - end - end) - -coroutine.resume(co) -thr, ismain = coroutine.running(co) -type_ok(thr, 'thread', "running") -is(ismain, true, "running") -is(coroutine.status(co), 'suspended', "basics") -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -coroutine.resume(co) -eq_array({coroutine.resume(co)}, {false, 'cannot resume dead coroutine'}) -eq_array(output, {1,2,3,4,5,6,7,8,9,10}) - ---[[ ]] -co = coroutine.create(function (a,b) - coroutine.yield(a + b, a - b) - end) - -eq_array({coroutine.resume(co, 20, 10)}, {true, 30, 10}, "basics") - ---[[ ]] -co = coroutine.create(function () - return 6, 7 - end) - -eq_array({coroutine.resume(co)}, {true, 6, 7}, "basics") - ---[[ ]] -co = coroutine.wrap(function(...) - return pcall(function(...) - return coroutine.yield(...) - end, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - ---[[ ]] -co = coroutine.wrap(function(...) - function backtrace () - return 'not a back trace' - end - return xpcall(function(...) - return coroutine.yield(...) - end, backtrace, ...) -end) -eq_array({co("Hello")}, {"Hello"}) -eq_array({co("World")}, {true, "World"}) - - ---[[ ]] -local output = {} -co = coroutine.wrap(function() - while true do - local t = setmetatable({}, { - __eq = function(...) - return coroutine.yield(...) - end} - ) - local t2 = setmetatable({}, getmetatable(t)) - output[#output+1] = t == t2 - end -end) -co() -co(true) -co(false) -eq_array(output, {true, false}) - ---[[ ]] -co = coroutine.wrap(print) -type_ok(co, 'function') - -error_like(function () coroutine.wrap(true) end, - "^[^:]+:%d+: bad argument #1 to 'wrap' %(function expected, got boolean%)") - -co = coroutine.wrap(function () error"in coro" end) -error_like(function () co() end, - "^[^:]+:%d+: in coro$") - ---[[ ]] -co = coroutine.create(function () - error "in coro" - end) -r, msg = coroutine.resume(co) -is(r, false) -like(msg, "in coro$") - ---[[ ]] -error_like(function () coroutine.yield() end, - "attempt to yield") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/221-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/221-table.t deleted file mode 100644 index f026f77d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/221-table.t +++ /dev/null @@ -1,112 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua tables - -=head2 Synopsis - - % prove 221-table.t - -=head2 Description - -See "Programming in Lua", section 2.5 "Tables". - -=cut - ---]] - -require 'Test.More' - -plan(25) - ---[[ ]] -a = {} -k = 'x' -a[k] = 10 -a[20] = 'great' -is(a['x'], 10) -k = 20 -is(a[k], 'great') -a['x'] = a ['x'] + 1 -is(a['x'], 11) - ---[[ ]] -a = {} -a['x'] = 10 -b = a -is(b['x'], 10) -b['x'] = 20 -is(a['x'], 20) -a = nil -b = nil - ---[[ ]] -a = {} -for i=1,1000 do a[i] = i*2 end -is(a[9], 18) -a['x'] = 10 -is(a['x'], 10) -is(a['y'], nil) - ---[[ ]] -a = {} -x = 'y' -a[x] = 10 -is(a[x], 10) -is(a.x, nil) -is(a.y, 10) - ---[[ ]] -i = 10; j = '10'; k = '+10' -a = {} -a[i] = "one value" -a[j] = "another value" -a[k] = "yet another value" -is(a[j], "another value") -is(a[k], "yet another value") -is(a[tonumber(j)], "one value") -is(a[tonumber(k)], "one value") - -t = { {'a','b','c'}, 10 } -is(t[2], 10) -is(t[1][3], 'c') -t[1][1] = 'A' -is(table.concat(t[1],','), 'A,b,c') - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is(tt[2], 10) -is(tt[1][3], 'c') -tt[1][1] = 'A' -is(table.concat(tt[1],','), 'A,b,c') - ---[[ ]] -a = {} -error_like(function () a() end, - "^[^:]+:%d+: attempt to call") - ---[[ ]] -local tt -tt = { {'a','b','c'}, 10 } -is((tt)[2], 10) -is((tt[1])[3], 'c'); -(tt)[1][2] = 'B' -(tt[1])[3] = 'C' -is(table.concat(tt[1],','), 'a,B,C') - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/222-constructor.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/222-constructor.t deleted file mode 100644 index 44009471..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/222-constructor.t +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Constructors - -=head2 Synopsis - - % prove 222-constructor.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 3.4.8 "Table Constructors", -L. - -See "Programming in Lua", section 3.6 "Table Constructors". - -=cut - ---]] - -require 'Test.More' - -plan(14) - ---[[ list-style init ]] -days = {'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday'} -is(days[4], 'Wednesday', "list-style init") -is(#days, 7) - ---[[ record-style init ]] -a = {x=0, y=0} -is(a.x, 0, "record-style init") -is(a.y, 0) - ---[[ ]] -w = {x=0, y=0, label='console'} -x = {0, 1, 2} -w[1] = "another field" -x.f = w -is(w['x'], 0, "ctor") -is(w[1], "another field") -is(x.f[1], "another field") -w.x = nil - ---[[ mix record-style and list-style init ]] -polyline = {color='blue', thickness=2, npoints=4, - {x=0, y=0}, - {x=-10, y=0}, - {x=-10, y=1}, - {x=0, y=1} - } -is(polyline[2].x, -10, "mix record-style and list-style init") - ---[[ ]] -opnames = {['+'] = 'add', ['-'] = 'sub', - ['*'] = 'mul', ['/'] = 'div'} -i = 20; s = '-' -a = {[i+0] = s, [i+1] = s..s, [i+2] = s..s..s} -is(opnames[s], 'sub', "ctor") -is(a[22], '---') - ---[[ ]] -local function f() return 10, 20 end - -eq_array({f()}, {10, 20}, "ctor") -eq_array({'a', f()}, {'a', 10, 20}) -eq_array({f(), 'b'}, {10, 'b'}) -eq_array({'c', (f())}, {'c', 10}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/223-iterator.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/223-iterator.t deleted file mode 100644 index 3905fc22..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/223-iterator.t +++ /dev/null @@ -1,196 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2010, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua iterators - -=head2 Synopsis - - % prove 223-iterator.t - -=head2 Description - -See "Programming in Lua", section 7 "Iterators and the Generic for" and -section 9.3 "Coroutines as Iterators". - -=cut - ---]] - -require 'Test.More' - -plan(8) - ---[[ list_iter ]] -function list_iter (t) - local i = 0 - local n = #t - return function () - i = i + 1 - if i <= n then - return t[i] - else - return nil - end - end -end - -t = {10, 20, 30} -output = {} -for element in list_iter(t) do - output[#output+1] = element -end -eq_array(output, t, "list_iter") - ---[[ values ]] -function values (t) - local i = 0 - return function () - i = i + 1 - return t[i] - end -end - -t = {10, 20, 30} -output = {} -for element in values(t) do - output[#output+1] = element -end -eq_array(output, t, "values") - ---[[ emul ipairs ]] -local function iter (a, i) - i = i + 1 - local v = a[i] - if v then - return i, v - end -end - -local function my_ipairs (a) - return iter, a, 0 -end - -a = {'one', 'two', 'three'} -output = {} -for i, v in my_ipairs(a) do - output[#output+1] = i - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ emul pairs ]] -local function my_pairs (t) - return next, t, nil -end - -a = {'one', 'two', 'three'} -output = {} -for k, v in my_pairs(a) do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "emul ipairs") - ---[[ with next ]] -t = {'one', 'two', 'three'} -output = {} -for k, v in next, t do - output[#output+1] = k - output[#output+1] = v -end -eq_array(output, {1, 'one', 2, 'two', 3, 'three'}, "with next") - ---[[ permutations ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () -- iterator - local code, res = coroutine.resume(co) - return res - end -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations") - - ---[[ permutations with wrap ]] -function permgen (a, n) - n = n or #a -- default for 'n' is size of 'a' - if n <= 1 then -- nothing to change? - coroutine.yield(a) - else - for i=1,n do - -- put i-th element as the last one - a[n], a[i] = a[i], a[n] - -- generate all permutations of the other elements - permgen(a, n - 1) - -- restore i-th element - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - return coroutine.wrap(function () permgen(a) end) -end - -output = {} -for p in permutations{'a', 'b', 'c'} do - output[#output+1] = table.concat(p, ' ') -end -eq_array(output, {'b c a','c b a','c a b','a c b','b a c','a b c'}, "permutations with wrap") - ---[[ fibo ]] -function fibogen () - local x, y = 0, 1 - while true do - coroutine.yield(x) - x, y = y, x + y - end -end - -function fibo () - return coroutine.wrap(function () fibogen() end) -end - -output = {} -for n in fibo() do - output[#output+1] = n - if n > 30 then break end -end -eq_array(output, {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}, "fibo") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/231-metatable.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/231-metatable.t deleted file mode 100644 index fc05e7bc..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/231-metatable.t +++ /dev/null @@ -1,533 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua metatables - -=head2 Synopsis - - % prove 231-metatable.t - -=head2 Description - -See "Lua 5.2 Reference Manual", section 2.4 "Metatables and Metamethods", -L. - -See "Programming in Lua", section 13 "Metatables and Metamethods". - -=cut - ---]] - -require 'Test.More' - -plan(96) - -t = {} -is(getmetatable(t), nil, "metatable") -t1 = {} -is(setmetatable(t, t1), t) -is(getmetatable(t), t1) -is(setmetatable(t, nil), t) -error_like(function () setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected.+%)") - -mt = {} -mt.__metatable = "not your business" -setmetatable(t, mt) -is(getmetatable(t), "not your business", "protected metatable") -error_like(function () setmetatable(t, {}) end, - "^[^:]+:%d+: cannot change a protected metatable") - -is(getmetatable('').__index, string, "metatable for string") - -is(getmetatable(nil), nil, "metatable for nil") -is(getmetatable(false), nil, "metatable for boolean") -is(getmetatable(2), nil, "metatable for number") -is(getmetatable(print), nil, "metatable for function") - -t = {} -mt = { __tostring=function () return '__TABLE__' end } -setmetatable(t, mt) -is(tostring(t), '__TABLE__', "__tostring") - -mt = {} -a = nil -function mt.__tostring () a = "return nothing" end -setmetatable(t, mt) -is(tostring(t), nil, "__tostring no-output") -is(a, "return nothing") -error_like(function () print(t) end, - "^[^:]+:%d+: 'tostring' must return a string to 'print'") - -mt.__tostring = function () return '__FIRST__', 2 end -setmetatable(t, mt) -is(tostring(t), '__FIRST__', "__tostring too-many-output") - -t = {} -t.mt = {} -setmetatable(t, t.mt) -t.mt.__tostring = "not a function" -error_like(function () tostring(t) end, - "attempt to call", - "__tostring invalid") - -t = {} -mt = { __len=function () return 42 end } -setmetatable(t, mt) -is(#t, 42, "__len") - -t = {} -mt = { __len=function () return nil end } -setmetatable(t, mt) -if jit then - todo("LuaJIT TODO. __len.", 1) -end -error_like(function () print(table.concat(t)) end, - "object length is not a number", - "__len invalid") - -t = {} -mt = { - __tostring=function () return 't' end, - __concat=function (op1, op2) - return tostring(op1) .. '|' .. tostring(op2) - end, -} -setmetatable(t, mt) -is(t .. t .. t .. 4 ..'end', "t|t|t|4end", "__concatx") - - ---[[ Cplx ]] -Cplx = {} -Cplx.mt = {} - -function Cplx.new (re, im) - local c = {} - setmetatable(c, Cplx.mt) - c.re = tonumber(re) - if im == nil then - c.im = 0.0 - else - c.im = tonumber(im) - end - return c -end - -function Cplx.mt.__tostring (c) - return '(' .. c.re .. ',' .. c.im .. ')' -end - -function Cplx.mt.__add (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re + b.re, a.im + b.im) - return r -end - -c1 = Cplx.new(1, 3) -c2 = Cplx.new(2, -1) - -is(tostring(c1 + c2), '(3,2)', "cplx __add") -is(tostring(c1 + 3), '(4,3)') -is(tostring(-2 + c1), '(-1,3)') -is(tostring(c1 + '3'), '(4,3)') -is(tostring('-2' + c1), '(-1,3)') - -function Cplx.mt.__sub (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re - b.re, a.im - b.im) - return r -end - -is(tostring(c1 - c2), '(-1,4)', "cplx __sub") -is(tostring(c1 - 3), '(-2,3)') -is(tostring(-2 - c1), '(-3,-3)') -is(tostring(c1 - '3'), '(-2,3)') -is(tostring('-2' - c1), '(-3,-3)') - -function Cplx.mt.__mul (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local r = Cplx.new(a.re*b.re - a.im*b.im, - a.re*b.im + a.im*b.re) - return r -end - -is(tostring(c1 * c2), '(5,5)', "cplx __mul") -is(tostring(c1 * 3), '(3,9)') -is(tostring(-2 * c1), '(-2,-6)') -is(tostring(c1 * '3'), '(3,9)') -is(tostring('-2' * c1), '(-2,-6)') - -function Cplx.mt.__div (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local n = b.re*b.re + b.im*b.im - local inv = Cplx.new(b.re/n, b.im/n) - local r = Cplx.new(a.re*inv.re - a.im*inv.im, - a.re*inv.im + a.im*inv.re) - return r -end - -c1 = Cplx.new(2, 6) -c2 = Cplx.new(2, 0) - -is(tostring(c1 / c2), '(1,3)', "cplx __div") -is(tostring(c1 / 2), '(1,3)') -is(tostring(-4 / c2), '(-2,0)') -is(tostring(c1 / '2'), '(1,3)') -is(tostring('-4' / c2), '(-2,0)') - -function Cplx.mt.__unm (a) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - local r = Cplx.new(-a.re, -a.im) - return r -end - -c1 = Cplx.new(1, 3) -is(tostring(- c1), '(-1,-3)', "cplx __unm") - -function Cplx.mt.__len (a) - return math.sqrt(a.re*a.re + a.im*a.im) -end - -c1 = Cplx.new(3, 4) -is( #c1, 5, "cplx __len") - -function Cplx.mt.__eq (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - return (a.re == b.re) and (b.im == b.im) -end - -c1 = Cplx.new(2, 0) -c2 = Cplx.new(1, 3) -c3 = Cplx.new(2, 0) - -is(c1 ~= c2, true, "cplx __eq") -is(c1 == c3, true) -is(c1 == 2, false) -is(Cplx.mt.__eq(c1, 2), true) - -function Cplx.mt.__lt (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra < rb -end - -is(c1 < c2, true, "cplx __lt") -is(c1 < c3, false) -is(c1 <= c3, true) -is(c1 < 1, false) -is(c1 < 4, true) - -function Cplx.mt.__le (a, b) - if type(a) ~= 'table' then - a = Cplx.new(a, 0) - end - if type(b) ~= 'table' then - b = Cplx.new(b, 0) - end - local ra = a.re*a.re + a.im*a.im - local rb = b.re*b.re + b.im*b.im - return ra <= rb -end - -is(c1 < c2, true, "cplx __lt __le") -is(c1 < c3, false) -is(c1 <= c3, true) - -function Cplx.mt.__call (obj) - a = "Cplx.__call " .. tostring(obj) - return true -end - -c1 = Cplx.new(2, 0) -a = nil -r = c1() -is(r, true, "cplx __call (without args)") -is(a, "Cplx.__call (2,0)") - -function Cplx.mt.__call (obj, ...) - a = "Cplx.__call " .. tostring(obj) .. ", " .. table.concat({...}, ", ") - return true -end - -is(c1(), true, "cplx __call (with args)") -is(a, "Cplx.__call (2,0), ") -is(c1('a'), true) -is(a, "Cplx.__call (2,0), a") -is(c1('a', 'b', 'c'), true) -is(a, "Cplx.__call (2,0), a, b, c") - ---[[ delegate ]] - -local t = { - _VALUES = { - a = 1, - b = 'text', - c = true, - } -} -local mt = { - __pairs = function (op) - return next, op._VALUES - end -} -setmetatable(t, mt) - -r = {} -for k in pairs(t) do - r[#r+1] = k -end -table.sort(r) -is( table.concat(r, ','), 'a,b,c', "__pairs" ) - -local t = { - _VALUES = { 'a', 'b', 'c' } -} -local mt = { - __ipairs = function (op) - return ipairs(op._VALUES) - end -} -setmetatable(t, mt) - -r = '' -for i, v in ipairs(t) do - r = r .. v -end -is( r, 'abc', "__ipairs" ) - ---[[ Window ]] - --- create a namespace -Window = {} --- create a prototype with default values -Window.prototype = {x=0, y=0, width=100, heigth=100, } --- create a metatable -Window.mt = {} --- declare the constructor function -function Window.new (o) - setmetatable(o, Window.mt) - return o -end - -Window.mt.__index = function (table, key) - return Window.prototype[key] -end - -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - -Window.mt.__index = Window.prototype -- just a table -w = Window.new{x=10, y=20} -is(w.x, 10, "table-access") -is(w.width, 100) -is(rawget(w, 'x'), 10) -is(rawget(w, 'width'), nil) - ---[[ tables with default values ]] -function setDefault_1 (t, d) - local mt = {__index = function () return d end} - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_1(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local mt = {__index = function (t) return t.___ end} -function setDefault_2 (t, d) - t.___ = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_2(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ tables with default values ]] -local key = {} -local mt = {__index = function (t) return t[key] end} -function setDefault_3 (t, d) - t[key] = d - setmetatable (t, mt) -end - -tab = {x=10, y=20} -is(tab.x, 10, "tables with default values") -is(tab.z, nil) -setDefault_3(tab, 0) -is(tab.x, 10) -is(tab.z, 0) - ---[[ private access ]] -t = {} -- original table --- keep a private access to original table -local _t = t --- create proxy -t = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return _t[k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - _t[k] = v -- update original table - end -} -setmetatable(t, mt) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ private access ]] --- create private index -local index = {} --- create metatable -local mt = { - __index = function (t,k) - r = "*access to element " .. tostring(k) - return t[index][k] -- access the original table - end, - - __newindex = function (t,k,v) - w = "*update of element " .. tostring(k) .. - " to " .. tostring(v) - t[index][k] = v -- update original table - end -} -function track (t) - local proxy = {} - proxy[index] = t - setmetatable(proxy, mt) - return proxy -end - -t = {} -t = track(t) - -w = nil -r = nil -t[2] = 'hello' -is(t[2], 'hello', "tracking table accesses") -is(w, "*update of element 2 to hello") -is(r, "*access to element 2") - ---[[ read-only table ]] -function readOnly (t) - local proxy = {} - local mt = { - __index = t, - __newindex = function (t,k,v) - error("attempt to update a read-only table", 2) - end - } - setmetatable(proxy, mt) - return proxy -end - -days = readOnly{'Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thurday', 'Friday', 'Saturday'} - -is(days[1], 'Sunday', "read-only tables") - -error_like(function () days[2] = 'Noday' end, - "^[^:]+:%d+: attempt to update a read%-only table") - ---[[ declare global ]] -function declare (name, initval) - rawset(_G, name, initval or false) -end - -setmetatable(_G, { - __newindex = function (_, n) - error("attempt to write to undeclared variable " .. n, 2) - end, - __index = function (_, n) - error("attempt to read undeclared variable" .. n, 2) - end, -}) - -error_like(function () new_a = 1 end, - "^[^:]+:%d+: attempt to write to undeclared variable new_a", - "declaring global variables") - -declare 'new_a' -new_a = 1 -is(new_a, 1) - ---[[ ]] -local newindex = {} --- create metatable -local mt = { - __newindex = newindex -} -local t = setmetatable({}, mt) -t[1] = 42 -is(newindex[1], 42, "__newindex") - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/232-object.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/232-object.t deleted file mode 100644 index f00eb321..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/232-object.t +++ /dev/null @@ -1,307 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua object - -=head2 Synopsis - - % prove 232-object.t - -=head2 Description - -See "Programming in Lua", section 16 "Object-Oriented Programming". - -=cut - ---]] - -require 'Test.More' - -plan(18) - ---[[ object ]] -Account = {balance = 0} - -function Account.withdraw (self, v) - self.balance = self.balance - v -end - -a1 = Account; Account = nil -a1.withdraw(a1, 100.00) -is(a1.balance, -100, "object") - -a2 = {balance = 0, withdraw = a1.withdraw} -a2.withdraw(a2, 260.00) -is(a2.balance, -260) - ---[[ object ]] -Account = {balance = 0} - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account -a:withdraw(100.00) -is(a.balance, -100, "object") - -Account = { balance = 0, - withdraw = function (self, v) - self.balance = self.balance -v - end - } -function Account:deposit (v) - self.balance = self.balance + v -end - -Account.deposit(Account, 200.00) -is(Account.balance, 200, "object") -Account:withdraw(100.00) -is(Account.balance, 100) - ---[[ classe ]] -Account = {balance = 0} - -function Account:new (o) - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) - self.balance = self.balance + v -end - -function Account:withdraw (v) - self.balance = self.balance - v -end - -a = Account:new{balance = 0} -a:deposit(100.00) -is(a.balance, 100, "classe") - -b = Account:new() -is(b.balance, 0) -b:deposit(200.00) -is(b.balance, 200) - ---[[ inheritance ]] -Account = {balance = 0} - -function Account:new (o) --- print "Account:new" - o = o or {} - setmetatable(o, self) - self.__index = self - return o -end - -function Account:deposit (v) --- print "Account:deposit" - self.balance = self.balance + v -end - -function Account:withdraw (v) --- print "Account:withdraw" - if v > self.balance then error"insuficient funds" end - self.balance = self.balance - v -end - -a = Account:new() -is(a.balance, 0, "inheritance") --- r, msg = pcall(Account.withdraw, a, 100) --- print(msg) - -SpecialAccount = Account:new() - -function SpecialAccount:withdraw (v) --- print "SpecialAccount:withdraw" - if self.balance - v <= -self:getLimit() then - error"insuficient funds" - end - self.balance = self.balance - v -end - -function SpecialAccount:getLimit () --- print "SpecialAccount:getLimit" - return self.limit or 0 -end - -s = SpecialAccount:new{limit=1000.00} - -s:deposit(100.00) -is(s.balance, 100) - -s:withdraw(200.00) -is(s.balance, -100) - ---[[ multiple inheritance ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - return search(k, arg) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance") -account:deposit(100.00) -is(account.balance, 100) - - ---[[ multiple inheritance (patched) ]] --- look up for 'k' in list of tables 'plist' -local function search (k, plist) - for i=1, #plist do - local v = plist[i][k] -- try 'i'-th superclass - if v then return v end - end -end - -function createClass (...) - local c = {} -- new class - local arg = {...} - - -- class will search for each method in the list of its - -- parents ('arg' is the list of parents) - setmetatable(c, {__index = function (t, k) - -- return search(k, arg) - return (search(k, arg)) - end}) - - -- prepare 'c' to be the metatable of its instance - c.__index = c - - -- define a new constructor for this new class - function c:new (o) - o = o or {} - setmetatable(o, c) - return o - end - - -- return new class - return c -end - -Account = {balance = 0} -function Account:deposit (v) - self.balance = self.balance + v -end -function Account:withdraw (v) - self.balance = self.balance - v -end - -Named = {} -function Named:getname () - return self.name -end -function Named:setname (n) - self.name = n -end - -NamedAccount = createClass(Account, Named) - -account = NamedAccount:new{name = "Paul"} -is(account:getname(), 'Paul', "multiple inheritance (patched)") -account:deposit(100.00) -is(account.balance, 100) - ---[[ privacy ]] -function newAccount (initialBalance) - local self = {balance = initialBalance} - - local withdraw = function (v) - self.balance = self.balance - v - end - - local deposit = function (v) - self.balance = self.balance + v - end - - local getBalance = function () return self.balance end - - return { - withdraw = withdraw, - deposit = deposit, - getBalance = getBalance - } -end - -acc1 = newAccount(100.00) -acc1.withdraw(40.00) -is(acc1.getBalance(), 60, "privacy") - ---[[ single-method approach ]] -function newObject (value) - return function (action, v) - if action == 'get' then return value - elseif action == 'set' then value = v - else error("invalid action") - end - end -end - -d = newObject(0) -is(d('get'), 0, "single-method approach") -d('set', 10) -is(d('get'), 10) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/301-basic.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/301-basic.t deleted file mode 100644 index 62eb0970..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/301-basic.t +++ /dev/null @@ -1,391 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Basic Library - -=head2 Synopsis - - % prove 301-basic.t - -=head2 Description - -Tests Lua Basic Library - -See "Lua 5.2 Reference Manual", section 6.1 "Basic Functions", -L. - -=cut - ---]] - --- MoonSharp note : THIS SUITE WAS HEAVILY CUT FOR NOT APPLIABLE TESTS - - -require 'Test.More' - -plan(168) - ---[[ -if jit then - like(_VERSION, '^Lua 5%.1$', "variable _VERSION") -else - like(_VERSION, '^Lua 5%.2$', "variable _VERSION") -end --- ]] - -v, msg = assert('text', "assert string") -is(v, 'text', "function assert") -is(msg, "assert string") -v, msg = assert({}, "assert table") -is(msg, "assert table") - -error_like(function () assert(false, "ASSERTION TEST") end, - "^[^:]+:%d+: ASSERTION TEST", - "function assert(false, msg)") - -error_like(function () assert(false) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false)") - -error_like(function () assert(false, nil) end, - "^[^:]+:%d+: assertion failed!", - "function assert(false, nil)") - - -a = {'a','b','c'} -local f, v, s = ipairs(a) -type_ok(f, 'function', "function ipairs") -type_ok(v, 'table') -is(s, 0) -s, v = f(a, s) -is(s, 1) -is(v, 'a') -s, v = f(a, s) -is(s, 2) -is(v, 'b') -s, v = f(a, s) -is(s, 3) -is(v, 'c') -s, v = f(a, s) -is(s, nil) -is(v, nil) - -t = { [[ -function bar (x) - return x -end -]] } -i = 0 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(reader)") -is(bar, nil) -f() -is(bar('ok'), 'ok') -bar = nil - -t = { [[ -function baz (x) - return x -end -]] } -i = -1 -function reader () - i = i + 1 - return t[i] -end -f, msg = load(reader) -if msg then - diag(msg) -end -type_ok(f, 'function', "function load(pathological reader)") -f() -is(baz, nil) - -t = { [[?syntax error?]] } -i = 0 -f, msg = load(reader, "errorchunk") -is(f, nil, "function load(syntax error)") ---like(msg, "^%[string \"errorchunk\"%]:%d+:") -- ERRORMSG - -f = load(function () return nil end) -type_ok(f, 'function', "when reader returns nothing") - -f, msg = load(function () return {} end) -is(f, nil, "reader function must return a string") -like(msg, "reader function must return a string") - -f = load([[ -function bar (x) - return x -end -]]) -is(bar, nil, "function load(str)") -f() -is(bar('ok'), 'ok') -bar = nil - -env = {} -f = load([[ -function bar (x) - return x -end -]], "from string", 't', env) -is(env.bar, nil, "function load(str)") -f() -is(env.bar('ok'), 'ok') - - --- ... - - -f = load([[i = i + 1]]) -i = 0 -f() -is(i, 1, "function loadstring") -f() -is(i, 2) - -i = 32 -local i = 0 -f = load([[i = i + 1; return i]]) -g = function () i = i + 1; return i end -is(f(), 33, "function loadstring") -is(g(), 1) - -f, msg = load([[?syntax error?]]) -is(f, nil, "function loadstring (syntax error)") --- like(msg, '^%[string "%?syntax error%?"%]:%d+:') -- ERRORMSG - -t = {'a','b','c'} -a = next(t, nil) -is(a, 1, "function next (array)") -a = next(t, 1) -is(a, 2) -a = next(t, 2) -is(a, 3) -a = next(t, 3) -is(a, nil) - -error_like(function () a = next() end, - "^[^:]+:%d+: bad argument #1 to 'next' %(table expected, got no value%)", - "function next (no arg)") - -error_like(function () a = next(t, 6) end, - "invalid key to 'next'", - "function next (invalid key)") - -t = {'a','b','c'} -a = next(t, 2) -is(a, 3, "function next (unorderer)") -a = next(t, 1) -is(a, 2) -a = next(t, 3) -is(a, nil) - -t = {} -a = next(t, nil) -is(a, nil, "function next (empty table)") - -a = {'a','b','c'} -local f, v, s = pairs(a) -type_ok(f, 'function', "function pairs") -type_ok(v, 'table') -is(s, nil) -s = f(v, s) -is(s, 1) -s = f(v, s) -is(s, 2) -s = f(v, s) -is(s, 3) -s = f(v, s) -is(s, nil) - -r = pcall(assert, true) -is(r, true, "function pcall") -r, msg = pcall(assert, false, 'catched') -is(r, false) -is(msg, 'catched') -r = pcall(assert) -is(r, false) - -t = {} -a = t -is(rawequal(nil, nil), true, "function rawequal -> true") -is(rawequal(false, false), true) -is(rawequal(3, 3), true) -is(rawequal('text', 'text'), true) -is(rawequal(t, a), true) -is(rawequal(print, print), true) - -is(rawequal(nil, 2), false, "function rawequal -> false") -is(rawequal(false, true), false) -is(rawequal(false, 2), false) -is(rawequal(3, 2), false) -is(rawequal(3, '2'), false) -is(rawequal('text', '2'), false) -is(rawequal('text', 2), false) -is(rawequal(t, {}), false) -is(rawequal(t, 2), false) -is(rawequal(print, format), false) -is(rawequal(print, 2), false) - -is(rawlen("text"), 4, "function rawlen (string)") -is(rawlen({ 'a', 'b', 'c'}), 3, "function rawlen (table)") -error_like(function () a = rawlen(true) end, - "^[^:]+:%d+: bad argument #1 to 'rawlen' %(table ", - "function rawlen (bad arg)") - -t = {a = 'letter a', b = 'letter b'} -is(rawget(t, 'a'), 'letter a', "function rawget") - -t = {} -is(rawset(t, 'a', 'letter a'), t, "function rawset") -is(t.a, 'letter a') - -error_like(function () t = {}; rawset(t, nil, 42) end, - "^[^:]+:%d+: table index is nil", -- changed this for MoonSharp, but we stay as it is! - "function rawset (table index is nil)") - -is(select('#'), 0, "function select") -is(select('#','a','b','c'), 3) -eq_array({select(1,'a','b','c')}, {'a','b','c'}) -eq_array({select(3,'a','b','c')}, {'c'}) -eq_array({select(5,'a','b','c')}, {}) -eq_array({select(-1,'a','b','c')}, {'c'}) -eq_array({select(-2,'a','b','c')}, {'b', 'c'}) -eq_array({select(-3,'a','b','c')}, {'a', 'b', 'c'}) - -error_like(function () select(0,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -error_like(function () select(-4,'a','b','c') end, - "^[^:]+:%d+: bad argument #1 to 'select' %(index out of range%)", - "function select (out of range)") - -is(type("Hello world"), 'string', "function type") -is(type(10.4*3), 'number') -is(type(print), 'function') -is(type(type), 'function') -is(type(true), 'boolean') -is(type(nil), 'nil') --- is(type(io.stdin), 'userdata') -- no stdin in MoonSharp so far -is(type(type(X)), 'string') - -a = nil -is(type(a), 'nil', "function type") -a = 10 -is(type(a), 'number') -a = "a string!!" -is(type(a), 'string') -a = print -is(type(a), 'function') -is(type(function () end), 'function') - -error_like(function () type() end, - "^[^:]+:%d+: bad argument #1 to 'type' %(value expected%)", - "function type (no arg)") - -is(tonumber('text12'), nil, "function tonumber") -is(tonumber('12text'), nil) -is(tonumber(3.14), 3.14) -is(tonumber('3.14'), 3.14) -is(tonumber(' 3.14 '), 3.14) -is(tonumber(111, 2), 7) -is(tonumber('111', 2), 7) -is(tonumber(' 111 ', 2), 7) -is(tonumber('78', 9), 71) -is(tonumber('111 ', 3), 13) -is(tonumber('111', 4), 21) -is(tonumber('1234', 5), 194) -is(tonumber('54321', 6), 7465) - -a = {} -is(tonumber(a), nil) - -error_like(function () tonumber() end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(value expected%)", - "function tonumber (no arg)") - -error_like(function () tonumber('111', 200) end, - "^[^:]+:%d+: bad argument #2 to 'tonumber' %(base out of range%)", - "function tonumber (bad base)") - -error_like(function () tonumber('17', 6) end, - "^[^:]+:%d+: bad argument #1 to 'tonumber' %(invalid character%)", - "function tonumber (bad base)") - -is(tostring('text'), 'text', "function tostring") -is(tostring(3.14), '3.14') -is(tostring(nil), 'nil') -is(tostring(true), 'true') -is(tostring(false), 'false') -like(tostring({}), '^table: 0?[Xx]?%x+$') -like(tostring(print), '^function: 0?[Xx]?[builtin]*#?%x+$') - -error_like(function () tostring() end, - "^[^:]+:%d+: bad argument #1 to 'tostring' %(value expected%)", - "function tostring (no arg)") - ---[[ MoonSharp : this is intentional - we support pack and unpack outside the table namespace (or whatever they are) -if (platform and platform.compat) or jit then - type_ok(unpack, 'function', "function unpack") -else - is(unpack, nil, "function unpack (removed)") -end -]] - - -if jit then - error_like(function () xpcall(assert, nil) end, - "bad argument #2 to 'xpcall' %(function expected, got nil%)", - "function xpcall") - error_like(function () xpcall(assert) end, - "bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall") - diag("LuaJIT intentional. xpcall") -else - is(xpcall(assert, nil), false, "function xpcall") - error_like(function () xpcall(assert) end, - "^[^:]+:%d+: bad argument #2 to 'xpcall' %(function expected, got no value%)", - "function xpcall (no arg)") -end - -function backtrace () - return 'not a back trace' -end -r, msg = xpcall(assert, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r, msg = xpcall(function() assert(); end, backtrace) -is(r, false, "function xpcall (backtrace)") -is(msg, 'not a back trace') - -r = xpcall(assert, backtrace, true) -is(r, true, "function xpcall") - - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/304-string.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/304-string.t deleted file mode 100644 index f610aaed..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/304-string.t +++ /dev/null @@ -1,318 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua String Library - -=head2 Synopsis - - % prove 304-string.t - -=head2 Description - -Tests Lua String Library - -See "Lua 5.2 Reference Manual", section 6.4 "String Manipulation", -L. - -See "Programming in Lua", section 20 "The String Library". - -=cut - -]] - -require 'Test.More' - -plan(115) - -is(string.byte('ABC'), 65, "function byte") -is(string.byte('ABC', 2), 66) -is(string.byte('ABC', -1), 67) -is(string.byte('ABC', 4), nil) -is(string.byte('ABC', 0), nil) -eq_array({string.byte('ABC', 1, 3)}, {65, 66, 67}) -eq_array({string.byte('ABC', 1, 4)}, {65, 66, 67}) - -type_ok(getmetatable('ABC'), 'table', "literal string has metatable") - -s = "ABC" -is(s:byte(2), 66, "method s:byte") - -is(string.char(65, 66, 67), 'ABC', "function char") -is(string.char(), '') - -error_like(function () string.char(0, 'bad') end, - "^[^:]+:%d+: bad argument #2 to 'char' %(number expected, got string%)", - "function char (bad arg)") - - ---[[ -MoonSharp intentional : - -1) unicode chars supported! -2) plan has upvalues, and by Lua spec it shouldn't be supported! - -error_like(function () string.char(0, 9999) end, - "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)", - "function char (invalid)") - -d = string.dump(plan) -type_ok(d, 'string', "function dump") - -error_like(function () string.dump(print) end, - "^[^:]+:%d+: unable to dump given function", - "function dump (C function)") - -]] - -s = "hello world" -eq_array({string.find(s, "hello")}, {1, 5}, "function find (mode plain)") -eq_array({string.find(s, "hello", 1, true)}, {1, 5}) -eq_array({string.find(s, "hello", 1)}, {1, 5}) -is(string.sub(s, 1, 5), "hello") -eq_array({string.find(s, "world")}, {7, 11}) -eq_array({string.find(s, "l")}, {3, 3}) -is(string.find(s, "lll"), nil) -is(string.find(s, "hello", 2, true), nil) -eq_array({string.find(s, "world", 2, true)}, {7, 11}) -is(string.find(s, "hello", 20), nil) - -s = "hello world" -eq_array({string.find(s, "^h.ll.")}, {1, 5}, "function find (with regex & captures)") -eq_array({string.find(s, "w.rld", 2)}, {7, 11}) -is(string.find(s, "W.rld"), nil) -eq_array({string.find(s, "^(h.ll.)")}, {1, 5, 'hello'}) -eq_array({string.find(s, "^(h.)l(l.)")}, {1, 5, 'he', 'lo'}) -s = "Deadline is 30/05/1999, firm" -date = "%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") -date = "%f[%S]%d%d/%d%d/%d%d%d%d" -is(string.sub(s, string.find(s, date)), "30/05/1999") - -error_like(function () string.find(s, '%f') end, - "^[^:]+:%d+: missing '%[' after '%%f' in pattern", - "function find (invalid frontier)") - -is(string.format("pi = %.4f", math.pi), 'pi = 3.1416', "function format") -d = 5; m = 11; y = 1990 -is(string.format("%02d/%02d/%04d", d, m, y), "05/11/1990") -is(string.format("%X %x", 126, 126), "7E 7e") -tag, title = "h1", "a title" -is(string.format("<%s>%s", tag, title, tag), "

a title

") - --- moonsharp : this commented out as it might fail mostly because of CRLF in windows than because of --- a moonsharp bug I think. Will see, surely not a blocking issue now. ---[==[ -is(string.format('%q', 'a string with "quotes" and \n new line'), [["a string with \"quotes\" and \ - new line"]], "function format %q") ---]==] - -is(string.format('%q', 'a string with \b and \b2'), [["a string with \8 and \0082"]], "function format %q") - -is(string.format("%s %s", 1, 2, 3), '1 2', "function format (too many arg)") - -is(string.format("%% %c %%", 65), '% A %', "function format (%%)") - -r = string.rep("ab", 100) -is(string.format("%s %d", r, r:len()), r .. " 200") - -error_like(function () string.format("%s %s", 1) end, - "^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)", - "function format (too few arg)") - -error_like(function () string.format('%d', 'toto') end, - "^[^:]+:%d+: bad argument #2 to 'format' %(number expected, got string%)", - "function format (bad arg)") - -error_like(function () string.format('%k', 'toto') end, - "^[^:]+:%d+: invalid option '%%k' to 'format'", - "function format (invalid option)") - -if jit and jit.version_num >= 20100 then - todo("LuaJIT TODO. format.", 1) -end -error_like(function () string.format('%------s', 'toto') end, - "^[^:]+:%d+: invalid format %(repeated flags%)", - "function format (invalid format)") - -error_like(function () string.format('pi = %.123f', math.pi) end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -error_like(function () string.format('% 123s', 'toto') end, - "^[^:]+:%d+: invalid ", - "function format (invalid format)") - -s = "hello" -output = {} -for c in string.gmatch(s, '..') do - table.insert(output, c) -end -eq_array(output, {'he', 'll'}, "function gmatch") -output = {} -for c1, c2 in string.gmatch(s, '(.)(.)') do - table.insert(output, c1) - table.insert(output, c2) -end -eq_array(output, {'h', 'e', 'l', 'l'}) -s = "hello world from Lua" -output = {} -for w in string.gmatch(s, '%a+') do - table.insert(output, w) -end -eq_array(output, {'hello', 'world', 'from', 'Lua'}) -s = "from=world, to=Lua" -output = {} -for k, v in string.gmatch(s, '(%w+)=(%w+)') do - table.insert(output, k) - table.insert(output, v) -end -eq_array(output, {'from', 'world', 'to', 'Lua'}) - -is(string.gsub("hello world", "(%w+)", "%1 %1"), "hello hello world world", "function gsub") -is(string.gsub("hello world", "%w+", "%0 %0", 1), "hello hello world") - - -is(string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1"), "world hello Lua from") - - -if jit then - todo("LuaJIT TODO. gsub.", 1) -end - -error_like(function () string.gsub("hello world", "%w+", "%e") end, - "^[^:]+:%d+: invalid use of '%%' in replacement string", - "function gsub (invalid replacement string)") - -is(string.gsub("home = $HOME, user = $USER", "%$(%w+)", string.reverse), "home = EMOH, user = RESU") -is(string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s) return load(s)() end), "4+5 = 9") -local t = {name='lua', version='5.1'} -is(string.gsub("$name-$version.tar.gz", "%$(%w+)", t), "lua-5.1.tar.gz") -is(string.gsub("Lua is cute", 'cute', 'great'), "Lua is great") -is(string.gsub("all lii", 'l', 'x'), "axx xii") -is(string.gsub("Lua is great", '^Sol', 'Sun'), "Lua is great") -is(string.gsub("all lii", 'l', 'x', 1), "axl lii") -is(string.gsub("all lii", 'l', 'x', 2), "axx lii") -is(select(2, string.gsub("string with 3 spaces", ' ', ' ')), 3) - -eq_array({string.gsub("hello, up-down!", '%A', '.')}, {"hello..up.down.", 4}) -text = "hello world" -nvow = select(2, string.gsub(text, '[AEIOUaeiou]', '')) -is(nvow, 3) -eq_array({string.gsub("one, and two; and three", '%a+', 'word')}, {"word, word word; word word", 5}) -test = "int x; /* x */ int y; /* y */" -eq_array({string.gsub(test, "/%*.*%*/", '')}, {"int x; ", 1}) -eq_array({string.gsub(test, "/%*.-%*/", '')}, {"int x; int y; ", 2}) -s = "a (enclosed (in) parentheses) line" -eq_array({string.gsub(s, '%b()', '')}, {"a line", 1}) - -error_like(function () string.gsub(s, '%b(', '') end, - "^[^:]+:%d+: .- pattern", - "function gsub (malformed pattern)") - -eq_array({string.gsub("hello Lua!", "%a", "%0-%0")}, {"h-he-el-ll-lo-o L-Lu-ua-a!", 8}) -eq_array({string.gsub("hello Lua", "(.)(.)", "%2%1")}, {"ehll ouLa", 4}) - -function expand (s) - return (string.gsub(s, '$(%w+)', _G)) -end -name = 'Lua'; status= 'great' -is(expand("$name is $status, isn't it?"), "Lua is great, isn't it?") -is(expand("$othername is $status, isn't it?"), "$othername is great, isn't it?") - -function expand (s) - return (string.gsub(s, '$(%w+)', function (n) - return tostring(_G[n]), 1 - end)) -end -like(expand("print = $print; a = $a"), "^print = function: [0]?[Xx]?[builtin]*#?%x+; a = nil") - -error_like(function () string.gsub("hello world", '(%w+)', '%2 %2') end, - "^[^:]+:%d+: invalid capture index", - "function gsub (invalid index)") - -error_like(function () string.gsub("hello world", '(%w+)', true) end, - "^[^:]+:%d+: bad argument #3 to 'gsub' %(string/function/table expected%)", - "function gsub (bad type)") - -error_like(function () - function expand (s) - return (string.gsub(s, '$(%w+)', _G)) - end - - name = 'Lua'; status= true - expand("$name is $status, isn't it?") - end, - "^[^:]+:%d+: invalid replacement value %(a boolean%)", - "function gsub (invalid value)") - -is(string.len(''), 0, "function len") -is(string.len('test'), 4) -is(string.len("a\000b\000c"), 5) -is(string.len('"'), 1) - -is(string.lower('Test'), 'test', "function lower") -is(string.lower('TeSt'), 'test') - -s = "hello world" -is(string.match(s, '^hello'), 'hello', "function match") -is(string.match(s, 'world', 2), 'world') -is(string.match(s, 'World'), nil) -eq_array({string.match(s, '^(h.ll.)')}, {'hello'}) -eq_array({string.match(s, '^(h.)l(l.)')}, {'he', 'lo'}) -date = "Today is 17/7/1990" -is(string.match(date, '%d+/%d+/%d+'), '17/7/1990') -eq_array({string.match(date, '(%d+)/(%d+)/(%d+)')}, {'17', '7', '1990'}) -is(string.match("The number 1298 is even", '%d+'), '1298') -pair = "name = Anna" -eq_array({string.match(pair, '(%a+)%s*=%s*(%a+)')}, {'name', 'Anna'}) - -s = [[then he said: "it's all right"!]] -eq_array({string.match(s, "([\"'])(.-)%1")}, {'"', "it's all right"}, "function match (back ref)") -p = "%[(=*)%[(.-)%]%1%]" -s = "a = [=[[[ something ]] ]==]x]=]; print(a)" -eq_array({string.match(s, p)}, {'=', '[[ something ]] ]==]x'}) - -is(string.match(s, "%g"), "a", "match graphic char") - -error_like(function () string.match("hello world", "%1") end, - "^[^:]+:%d+: invalid capture index", - "function match invalid capture") - -error_like(function () string.match("hello world", "%w)") end, - "^[^:]+:%d+: invalid pattern capture", - "function match invalid capture") - -is(string.rep('ab', 3), 'ababab', "function rep") -is(string.rep('ab', 0), '') -is(string.rep('ab', -1), '') -is(string.rep('', 5), '') -is(string.rep('ab', 3, ','), 'ab,ab,ab', "with sep") - -is(string.reverse('abcde'), 'edcba', "function reverse") -is(string.reverse('abcd'), 'dcba') -is(string.reverse(''), '') - -is(string.sub('abcde', 1, 2), 'ab', "function sub") -is(string.sub('abcde', 3, 4), 'cd') -is(string.sub('abcde', -2), 'de') -is(string.sub('abcde', 3, 2), '') - -is(string.upper('Test'), 'TEST', "function upper") -is(string.upper('TeSt'), 'TEST') -is(string.upper(string.rep('Test', 10000)), string.rep('TEST', 10000)) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/305-table.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/305-table.t deleted file mode 100644 index 0c40f3a5..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/305-table.t +++ /dev/null @@ -1,253 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Table Library - -=head2 Synopsis - - % prove 305-table.t - -=head2 Description - -Tests Lua Table Library - -See "Lua 5.2 Reference Manual", section 6.5 "Table Manipulation", -L. - -See "Programming in Lua", section 19 "The Table Library". - -=cut - ---]] - -require 'Test.More' - -plan(44) - -t = {'a','b','c','d','e'} -is(table.concat(t), 'abcde', "function concat") -is(table.concat(t, ','), 'a,b,c,d,e') -is(table.concat(t, ',',2), 'b,c,d,e') -is(table.concat(t, ',', 2, 4), 'b,c,d') -is(table.concat(t, ',', 4, 2), '') - -t = {'a','b',3,'d','e'} -is(table.concat(t,','), 'a,b,3,d,e', "function concat (number)") - -t = {'a','b','c','d','e'} -error_like(function () table.concat(t, ',', 2, 7) end, - "^[^:]+:%d+: invalid value %(nil%) at index 6 in table for 'concat'", - "function concat (out of range)") - -t = {'a','b',true,'d','e'} -error_like(function () table.concat(t, ',') end, - "^[^:]+:%d+: invalid value %(boolean%) at index 3 in table for 'concat'", - "function concat (non-string)") - -a = {10, 20, 30} -table.insert(a, 1, 15) -is(table.concat(a,','), '15,10,20,30', "function insert") -t = {} -table.insert(t, 'a') -is(table.concat(t, ','), 'a') -table.insert(t, 'b') -is(table.concat(t, ','), 'a,b') -table.insert(t, 1, 'c') -is(table.concat(t, ','), 'c,a,b') -table.insert(t, 2, 'd') -is(table.concat(t, ','), 'c,d,a,b') -table.insert(t, 5, 'e') -is(table.concat(t, ','), 'c,d,a,b,e') - -if jit then - todo("LuaJIT TODO. table.insert.", 2) -end -error_like(function () table.insert(t, 7, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, -9, 'f') end, - "^[^:]+:%d+: bad argument #2 to 'insert' %(position out of bounds%)", - "function insert (out of bounds)") - -error_like(function () table.insert(t, 2, 'g', 'h') end, - "^[^:]+:%d+: wrong number of arguments to 'insert'", - "function insert (too many arg)") - -if (platform and platform.compat) or jit then - t = {} - is(table.maxn(t), 0, "function maxn") - t[1] = 'a' - t[2] = 'b' - is(table.maxn(t), 2) - t[6] = 'g' - is(table.maxn(t), 6) - a = {} - a[10000] = 1 - is(table.maxn(a), 10000) -else - is(table.maxn, nil, "maxn (removed)") - skip("maxn (removed)", 3) -end - -t = table.pack("abc", "def", "ghi") -eq_array(t, { - "abc", - "def", - "ghi" -}, "function pack") -is(t.n, 3) - -t = table.pack() -eq_array(t, {}, "function pack (no element)") -is(t.n, 0) - -t = {} -a = table.remove(t) -is(a, nil, "function remove") -t = {'a','b','c','d','e'} -a = table.remove(t) -is(a, 'e') -is(table.concat(t, ','), 'a,b,c,d') -a = table.remove(t,3) -is(a, 'c') -is(table.concat(t, ','), 'a,b,d') -a = table.remove(t,1) -is(a, 'a') -is(table.concat(t, ','), 'b,d') - -if jit then - todo("LuaJIT TODO. table.remove.", 1) -end -error_like(function () table.remove(t,7) end, - "^[^:]+:%d+: bad argument #1 to 'remove' %(position out of bounds%)", - "function remove (out of bounds)") - -lines = { - luaH_set = 10, - luaH_get = 24, - luaH_present = 48, -} -a = {} -for n in pairs(lines) do a[#a + 1] = n end -table.sort(a) -output = {} -for _, n in ipairs(a) do - table.insert(output, n) -end -eq_array(output, {'luaH_get', 'luaH_present', 'luaH_set'}, "function sort") - -function pairsByKeys (t, f) - local a = {} - for n in pairs(t) do a[#a + 1] = n end - table.sort(a, f) - local i = 0 -- iterator variable - return function () -- iterator function - i = i + 1 - return a[i], t[a[i]] - end -end - -output = {} -for name, line in pairsByKeys(lines) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - -output = {} -for name, line in pairsByKeys(lines, function (a, b) return a < b end) do - table.insert(output, name) - table.insert(output, line) -end -eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort") - - - -function permgen (a, n) - n = n or #a - if n <= 1 then - coroutine.yield(a) - else - for i=1,n do - a[n], a[i] = a[i], a[n] - permgen(a, n - 1) - a[n], a[i] = a[i], a[n] - end - end -end - -function permutations (a) - local co = coroutine.create(function () permgen(a) end) - return function () - local code, res = coroutine.resume(co) - return res - end -end - -local t = {} -output = {} -for _, v in ipairs{'a', 'b', 'c', 'd', 'e', 'f', 'g'} do - table.insert(t, v) - local ref = table.concat(t, ' ') - table.insert(output, ref) - local n = 0 - for p in permutations(t) do - local c = {} - for i, v in ipairs(p) do - c[i] = v - end - table.sort(c) - assert(ref == table.concat(c, ' '), table.concat(p, ' ')) - n = n + 1 - end - table.insert(output, n) -end - -eq_array(output, { - 'a', 1, - 'a b', 2, - 'a b c', 6, - 'a b c d', 24, - 'a b c d e', 120, - 'a b c d e f', 720, - 'a b c d e f g', 5040, -}, "function sort (all permutations)") - ---[[ - -MoonSharp: Sort callbacks work --]] - - -error_like(function () - local t = { 1 } - table.sort( { t, t, t, t, }, function (a, b) return a[1] == b[1] end ) - end, - "^[^:]+:%d+: invalid order function for sorting", - "function sort (bad func)") - - -eq_array({table.unpack({})}, {}, "function unpack") -eq_array({table.unpack({'a'})}, {'a'}) -eq_array({table.unpack({'a','b','c'})}, {'a','b','c'}) -eq_array({(table.unpack({'a','b','c'}))}, {'a'}) -eq_array({table.unpack({'a','b','c','d','e'},2,4)}, {'b','c','d'}) -eq_array({table.unpack({'a','b','c'},2,4)}, {'b','c'}) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/306-math.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/306-math.t deleted file mode 100644 index c68dac55..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/306-math.t +++ /dev/null @@ -1,153 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Mathematic Library - -=head2 Synopsis - - % prove 306-math.t - -=head2 Description - -Tests Lua Mathematic Library - -See "Lua 5.2 Reference Manual", section 6.6 "Mathematical Functions", -L. - -See "Programming in Lua", section 18 "The Mathematical Library". - -=cut - ---]] - -require 'Test.More' - -plan(47) - -like(tostring(math.pi), '^3%.14', "variable pi") - -type_ok(math.huge, 'number', "variable huge") - -is(math.abs(-12.34), 12.34, "function abs") -is(math.abs(12.34), 12.34) - -like(math.acos(0.5), '^1%.047', "function acos") - -like(math.asin(0.5), '^0%.523', "function asin") - -like(math.atan(0.5), '^0%.463', "function atan") - -like(math.atan2(1, 2), '^0%.463', "function atan2") - -is(math.ceil(12.34), 13, "function ceil") -is(math.ceil(-12.34), -12) - -like(math.cos(0), '^1$', "function cos") - -like(math.cosh(0), '^1$', "function cosh") - -is(math.deg(math.pi), 180, "function deg") - -like(math.exp(1.0), '^2%.718', "function exp") - -is(math.floor(12.34), 12, "function floor") -is(math.floor(-12.34), -13) - -is(math.fmod(7, 3), 1, "function fmod") -is(math.fmod(-7, 3), -1) - -eq_array({math.frexp(1.5)}, {0.75, 1}, "function frexp") - -is(math.ldexp(1.2, 3), 9.6, "function ldexp") - -like(math.log(47), '^3%.85', "function log") -like(math.log(47, 2), '^5%.554', "function log (base 2)") -like(math.log(47, 10), '^1%.672', "function log (base 10)") - -if (platform and platform.compat) or jit then - like(math.log10(47), '^1%.672', "function log10") -else - is(math.log10, nil, "function log10 (removed)") -end - -error_like(function () math.max() end, - "^[^:]+:%d+: bad argument #1 to 'max' %(number expected, got no value%)", - "function max 0") - -is(math.max(1), 1, "function max") -is(math.max(1, 2), 2) -is(math.max(1, 2, 3, -4), 3) - -error_like(function () math.min() end, - "^[^:]+:%d+: bad argument #1 to 'min' %(number expected, got no value%)", - "function min 0") - -is(math.min(1), 1, "function min") -is(math.min(1, 2), 1) -is(math.min(1, 2, 3, -4), -4) - -eq_array({math.modf(2.25)}, {2, 0.25}, "function modf") - -is(math.pow(-2, 3), -8, "function pow") - -like(math.rad(180), '^3%.14', "function rad") - -like(math.random(), '^%d%.%d+', "function random no arg") - -like(math.random(9), '^%d$', "function random 1 arg") - -like(math.random(10, 19), '^1%d$', "function random 2 arg") - ---[[ -MoonSharp : math.random normalizes inputs, and we are happy with that - -if jit then - todo("LuaJIT intentional. Don't check empty interval.", 2) -end -error_like(function () math.random(0) end, - "^[^:]+:%d+: bad argument #1 to 'random' %(interval is empty%)", - "function random empty interval") - -error_like(function () math.random(19, 10) end, - "^[^:]+:%d+: bad argument #2 to 'random' %(interval is empty%)", - "function random empty interval") - -if jit then - todo("LuaJIT intentional. Don't care about extra arguments.") -end -error_like(function () math.random(1, 2, 3) end, - "^[^:]+:%d+: wrong number of arguments", - "function random too many arg") - --]] - -math.randomseed(12) -a = math.random() -math.randomseed(12) -b = math.random() -is(a, b, "function randomseed") - -like(math.sin(math.pi/2), '^1$', "function sin") - -like(math.sinh(1), '^1%.175', "function sinh") - -like(math.sqrt(2), '^1%.414', "function sqrt") - -like(math.tan(math.pi/3), '^1%.732', "function tan") - -like(math.tanh(1), '^0%.761', "function sinh") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/307-bit.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/307-bit.t deleted file mode 100644 index 69487518..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/307-bit.t +++ /dev/null @@ -1,94 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2010-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Bitwise Library - -=head2 Synopsis - - % prove 307-bit.t - -=head2 Description - -Tests Lua Bitwise Library - -See "Lua 5.2 Reference Manual", section 6.7 "Bitwise operations", -L. - -=cut - ---]] - -require 'Test.More' - -if jit then - skip_all("LuaJIT. bit32") -end - -plan(20) - -is(bit32.band(0x01, 0x03, 0x07), 0x01, "function band") - -is(bit32.bnot(0x03), (-1 - 0x03) % 2^32, "function bnot") - -is(bit32.bor(0x01, 0x03, 0x07), 0x07, "function bor") - -is(bit32.btest(0x01), true, "function btest") -is(bit32.btest(0x00), false, "function btest") - -is(bit32.bxor(0x01, 0x03, 0x07), 0x05, "function bxor") - -is(bit32.lrotate(0x03, 2), 0x0C, "function lrotate") - -is(bit32.rrotate(0x06, 1), 0x03, "function rrotate") - -is(bit32.arshift(0x06, 1), 0x03, "function arshift") - -is(bit32.arshift(-3, 1), bit32.arshift(-6, 2), "function arshift") - -is(bit32.lshift(0x03, 2), 0x0C, "function lshift") - -is(bit32.rshift(0x06, 1), 0x03, "function rshift") - -is(bit32.extract(0xFFFF, 3, 3), 0x07, "function extract") - -error_like(function () bit32.extract(0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function extract (non-existent bits)") - -error_like(function () bit32.extract(0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #2 to 'extract' %(field cannot be negative%)", - "function extract (negatif field)") - -error_like(function () bit32.extract(0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #3 to 'extract' %(width must be positive%)", - "function extract (negative width)") - -is(bit32.replace(0x0000, 0xFFFF, 3, 3), 0x38, "function replace") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 99) end, - "^[^:]+:%d+: trying to access non%-existent bits", - "function replace (non-existent bits)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, -3) end, - "^[^:]+:%d+: bad argument #3 to 'replace' %(field cannot be negative%)", - "function replace (negatif field)") - -error_like(function () bit32.replace(0x0000, 0xFFFF, 3, -3) end, - "^[^:]+:%d+: bad argument #4 to 'replace' %(width must be positive%)", - "function replace (negative width)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/308-io.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/308-io.t deleted file mode 100644 index 2ca3b852..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/308-io.t +++ /dev/null @@ -1,258 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Input/Output Library - -=head2 Synopsis - - % prove 308-io.t - -=head2 Description - -Tests Lua Input/Output Library - -See "Lua 5.2 Reference Manual", section 6.8 "Input and Output Facilities", -L. - -See "Programming in Lua", section 21 "The I/O Library". - -=cut - ---]] - -require 'Test.More' - -local lua = [[\git\moonsharp\src\Tools\lua52.exe]] - -plan(67) - -like(io.stdin, '^file %(0?[Xx]?%x+%)$', "variable stdin") - -like(io.stdout, '^file %(0?[Xx]?%x+%)$', "variable stdout") - -like(io.stderr, '^file %(0?[Xx]?%x+%)$', "variable stderr") - -r, msg = io.close(io.stderr) -is(r, nil, "close (std)") -is(msg, "cannot close standard file") - -is(io.flush(), true, "function flush") - -os.remove('file.no') -f, msg = io.open("file.no") -is(f, nil, "function open") -is(msg, "file.no: No such file or directory") - -os.remove('file.txt') -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() -f = io.open('file.txt') -like(f, '^file %(0?[Xx]?%x+%)$', "function open") - - -is(io.close(f), true, "function close") - -error_like(function () io.close(f) end, - "^[^:]+:%d+: attempt to use a closed file", - "function close (closed)") - -if jit then - todo("LuaJIT TODO. open mode") -end -error_like(function () io.open('file.txt', 'baz') end, - "^[^:]+:%d+: bad argument #2 to 'open' %(invalid mode%)", - "function open (bad mode)") - - -is(io.type("not a file"), nil, "function type") -f = io.open('file.txt') -is(io.type(f), 'file') -like(tostring(f), '^file %(0?[Xx]?%x+%)$') -io.close(f) -is(io.type(f), 'closed file') -is(tostring(f), 'file (closed)') - -is(io.stdin, io.input(), "function input") -is(io.stdin, io.input(nil)) -f = io.stdin - -like(io.input('file.txt'), '^file %(0?[Xx]?%x+%)$') -is(f, io.input(f)) - -is(io.output(), io.stdout, "function output") -is(io.output(nil), io.stdout) -f = io.stdout -like(io.output('output.new'), '^file %(0?[Xx]?%x+%)$') -is(f, io.output(f)) -os.remove('output.new') - -r, f = pcall(io.popen, lua .. [[ -e "print 'standard output'"]]) -if r then - is(io.type(f), 'file', "popen (read)") - is(f:read(), "standard output") - is(io.close(f), true) -else - skip("io.popen not supported", 3) -end - -r, f = pcall(io.popen, lua .. [[ -e "for line in io.lines() do print((line:gsub('e', 'a'))) end"]], 'w') -if r then - is(io.type(f), 'file', "popen (write)") - f:write("# hello\n") -- not tested : hallo - is(io.close(f), true) -else - skip("io.popen not supported", 2) -end - -for line in io.lines('file.txt') do - is(line, "file with text", "function lines(filename)") -end - -error_like(function () io.lines('file.no') end, - "No such file or directory", - "function lines(no filename)") - -f = io.tmpfile() -is(io.type(f), 'file', "function tmpfile") -f:write("some text") -f:close() - -io.write() -- not tested -io.write('# text', 12, "\n") -- not tested : # text12 - -r, msg = io.stderr:close() -is(r, nil, "method close (std)") -is(msg, "cannot close standard file") - -f = io.open('file.txt') -is(f:close(), true, "method close") - -is(io.stderr:flush(), true, "method flush") - -error_like(function () f:flush() end, - "^[^:]+:%d+: attempt to use a closed file", - "method flush (closed)") - -error_like(function () f:read() end, - "^[^:]+:%d+: attempt to use a closed file", - "method read (closed)") - -f = io.open('file.txt') -s = f:read() -is(s:len(), 14, "method read") -is(s, "file with text") -s = f:read() -is(s, nil) -f:close() - -f = io.open('file.txt') -error_like(function () f:read('*z') end, - "^[^:]+:%d+: bad argument #1 to 'read' %(invalid %w+%)", - "method read (invalid)") -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*l', '*l') -is(s1:len(), 14, "method read *l") -is(s1, "file with text") -is(s2, nil) -f:close() - -f = io.open('file.txt') -s1, s2 = f:read('*L', '*L') -is(s1:len(), 15, "method read *L") -is(s1, "file with text\n") -is(s2, nil) -f:close() - -f = io.open('file.txt') -n1, n2 = f:read('*n', '*n') -is(n1, nil, "method read *n") -is(n2, nil) -f:close() - -f = io.open('file.txt') -s = f:read('*a') -is(s:len(), 15, "method read *a") -is(s, "file with text\n") -f:close() - -f = io.open('file.txt') -is(f:read(0), '', "method read number") -eq_array({f:read(5, 5, 15)}, {'file ', 'with ', "text\n"}) --- print(f:read(0)) -f:close() - -f = io.open('file.txt') -for line in f:lines() do - is(line, "file with text", "method lines") -end -is(io.type(f), 'file') -f:close() -is(io.type(f), 'closed file') - -f = io.open('file.txt') -for two_char in f:lines(2) do - is(two_char, "fi", "method lines (with read option)") - break -end -f:close() - -error_like(function () f:seek('end', 0) end, - "^[^:]+:%d+: attempt to use a closed file", - "method seek (closed)") - -f = io.open('file.txt') -error_like(function () f:seek('bad', 0) end, - "^[^:]+:%d+: bad argument #1 to 'seek' %(invalid option 'bad'%)", - "method seek (invalid)") - -f = io.open('file.txt') -if platform and platform.osname == 'MSWin32' then - is(f:seek('end', 0), 16, "method seek") -else - is(f:seek('end', 0), 15, "method seek") -end -f:close() - -f = io.open('file.txt') -is(f:setvbuf('no'), true, "method setvbuf 'no'") - -is(f:setvbuf('full', 4096), true, "method setvbuf 'full'") - -is(f:setvbuf('line', 132), true, "method setvbuf 'line'") -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('file.out', 'w') -f:close() -error_like(function () f:write('end') end, - "^[^:]+:%d+: attempt to use a closed file", - "method write (closed)") - -f = io.open('file.out', 'w') -is(f:write('end'), f, "method write") -f:close() - -os.remove('file.out') --clean up - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: - ---]==] - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/309-os.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/309-os.t deleted file mode 100644 index a92ab3f8..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/309-os.t +++ /dev/null @@ -1,202 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Operating System Library - -=head2 Synopsis - - % prove 309-os.t - -=head2 Description - -Tests Lua Operating System Library - -See "Lua 5.2 Reference Manual", section 6.9 "Operating System Facilities", -L. - -See "Programming in Lua", section 22 "The Operating System Library". - -=cut - ---]] - -require 'Test.More' - -plan(54) - -local lua = "lua" - -clk = os.clock() -type_ok(clk, 'number', "function clock") -ok(clk <= os.clock()) - -d = os.date('!*t', 0) -is(d.year, 1970, "function date") -is(d.month, 1) -is(d.day, 1) -is(d.hour, 0) -is(d.min, 0) -is(d.sec, 0) -is(d.wday, 5) -is(d.yday, 1) -is(d.isdst, false) - -is(os.date('!%d/%m/%y %H:%M:%S', 0), '01/01/70 00:00:00', "function date") - -like(os.date('%H:%M:%S'), '^%d%d:%d%d:%d%d', "function date") - -if jit and jit.version_num < 20100 then - todo("LuaJIT TODO. invalid strftime.", 1) -end -is(os.date('%Oy', 0), '70') -if jit then - todo("LuaJIT TODO. invalid strftime.", 1) -end - - - -error_like(function () os.date('%Ja', 0) end, - "^[^:]+:%d+: bad argument #1 to 'date' %(invalid conversion specifier '%%Ja'%)", - "function date (invalid)") - -is(os.difftime(1234, 1200), 34, "function difftime") -is(os.difftime(1234), 1234) - -r = os.execute() -is(r, true, "function execute") - -r, s, n = os.execute('__IMPROBABLE__') -is(r, nil, "function execute") -is(s, 'exit') -type_ok(n, 'number') - ---[===[ -- Tests commented as currently they are more likely to fail because of OS configuration than implementation details - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(2)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 2, "exit value 1") - -cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(false)"]] -r, s, n = os.execute(cmd) -is(r, nil) -is(s, 'exit', "function execute & exit") -is(n, 1, "exit value 2") - --- cmd = lua .. [[ -e "print '# hello from external Lua'; os.exit(true, true)"]] --- is(os.execute(cmd), true, "function execute & exit") - -cmd = lua .. [[ -e "print 'reached'; os.exit(); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - code = f:close() - is(code, true, "exit code") -else - skip("io.popen not supported", 3) -end - -cmd = lua .. [[ -e "print 'reached'; os.exit(3); print 'not reached';"]] -r, f = pcall(io.popen, cmd) -if r then - is(f:read'*l', 'reached', "function exit") - is(f:read'*l', nil) - r, s, n = f:close() - is(r, nil) - is(s, 'exit', "exit code") - is(n, 3, "exit value 3") -else - skip("io.popen not supported", 5) -end - ---]===] - -is(os.getenv('__IMPROBABLE__'), nil, "function getenv") - -user = os.getenv('LOGNAME') or os.getenv('USERNAME') -type_ok(user, 'string', "function getenv") - -local f = io.open('file.rm', 'w') -f:write("file to remove") -f:close() -r = os.remove("file.rm") -is(r, true, "function remove") - -r, msg = os.remove('file.rm') -is(r, nil, "function remove") -like(msg, '^file.rm: No such file or directory') - -local f = io.open('file.old', 'w') -f:write("file to rename") -f:close() -os.remove('file.new') -r = os.rename('file.old', 'file.new') -is(r, true, "function rename") -os.remove('file.new') -- clean up - -r, msg = os.rename('file.old', 'file.new') -is(r, nil, "function rename") -like(msg, 'No such file or directory') - ---[[ setlocale NOT supported! -is(os.setlocale('C', 'all'), 'C', "function setlocale") -is(os.setlocale(), 'C') - -is(os.setlocale('unk_loc', 'all'), nil, "function setlocale (unknown locale)") - -]] - -like(os.time(), '^%d+%.?%d*$', "function time") - -like(os.time(nil), '^%d+%.?%d*$', "function time") - -like(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 2000, - isdst = 0, -}), '^946%d+$', "function time") - -if platform and platform.intsize == 8 then - todo("pb on 64bit platforms") - -- os.time returns nil when C mktime returns < 0 - -- this test needs a out of range value on any platform -end -is(os.time({ - sec = 0, - min = 0, - hour = 0, - day = 1, - month = 1, - year = 1000, - isdst = 0, -}), nil, "function time -> nil") - -error_like(function () os.time{} end, - "^[^:]+:%d+: field 'day' missing in date table", - "function time (missing field)") - -fname = os.tmpname() -type_ok(fname, 'string', "function tmpname") -ok(fname ~= os.tmpname()) - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/310-debug.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/310-debug.t deleted file mode 100644 index 76055802..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/310-debug.t +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Debug Library - -=head2 Synopsis - - % prove 310-debug.t - -=head2 Description - -Tests Lua Debug Library - -See "Lua 5.2 Reference Manual", section 6.10 "The Debug Library", -L. - -See "Programming in Lua", section 23 "The Debug Library". - -=cut - -]] - -require 'Test.More' - -plan(51) - -debug = require 'debug' - -info = debug.getinfo(is) -type_ok(info, 'table', "function getinfo (function)") -is(info.func, is, " .func") - -info = debug.getinfo(is, 'L') -type_ok(info, 'table', "function getinfo (function, opt)") -type_ok(info.activelines, 'table') - -info = debug.getinfo(1) -type_ok(info, 'table', "function getinfo (level)") -like(info.func, "^function: [0]?[Xx]?%x+", " .func") - -is(debug.getinfo(12), nil, "function getinfo (too depth)") - -error_like(function () debug.getinfo('bad') end, - "bad argument #1 to 'getinfo' %(function or level expected%)", - "function getinfo (bad arg)") - -error_like(function () debug.getinfo(is, 'X') end, - "bad argument #2 to 'getinfo' %(invalid option%)", - "function getinfo (bad opt)") - -local name, value = debug.getlocal(0, 1) -type_ok(name, 'string', "function getlocal (level)") -is(value, 0) - -error_like(function () debug.getlocal(42, 1) end, - "bad argument #1 to 'getlocal' %(level out of range%)", - "function getlocal (out of range)") - -local name, value = debug.getlocal(like, 1) -type_ok(name, 'string', "function getlocal (func)") -is(value, nil) - -t = {} -is(debug.getmetatable(t), nil, "function getmetatable") -t1 = {} -debug.setmetatable(t, t1) -is(debug.getmetatable(t), t1) - -a = true -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -a = 3.14 -is(debug.getmetatable(a), nil) -debug.setmetatable(a, t1) -is(debug.getmetatable(t), t1) - -local reg = debug.getregistry() -type_ok(reg, 'table', "function getregistry") -type_ok(reg._LOADED, 'table') - -local name = debug.getupvalue(plan, 1) -type_ok(name, 'string', "function getupvalue") - -debug.sethook() -hook, mask, count = debug.gethook() -is(hook, nil, "function gethook") -is(mask, '') -is(count, 0) -local function f () end -debug.sethook(f, 'c', 42) -hook , mask, count = debug.gethook() -is(hook, f, "function gethook") -is(mask, 'c') -is(count, 42) - -co = coroutine.create(function () print "thread" end) -hook = debug.gethook(co) -if jit then - todo("LuaJIT TODO. debug.gethook(thread)", 1) -end -is(hook, nil, "function gethook(thread)") - -local name = debug.setlocal(0, 1, 0) -type_ok(name, 'string', "function setlocal (level)") - -local name = debug.setlocal(0, 42, 0) -is(name, nil, "function setlocal (level)") - -error_like(function () debug.setlocal(42, 1, true) end, - "bad argument #1 to 'setlocal' %(level out of range%)", - "function getlocal (out of range)") - -t = {} -t1 = {} -is(debug.setmetatable(t, t1), t, "function setmetatable") -is(getmetatable(t), t1) - -error_like(function () debug.setmetatable(t, true) end, - "^[^:]+:%d+: bad argument #2 to 'setmetatable' %(nil or table expected%)") - -local name = debug.setupvalue(plan, 1, require 'Test.Builder':new()) -type_ok(name, 'string', "function setupvalue") - -local name = debug.setupvalue(plan, 42, true) -is(name, nil) - -local u = io.tmpfile() -local old = debug.getuservalue(u) -if jit then - type_ok(old, 'table', "function getuservalue") -else - is(old, nil, "function getuservalue") -end -is(debug.getuservalue(true), nil) -local data = {} -r = debug.setuservalue(u, data) -is(r, u, "function setuservalue") -is(debug.getuservalue(u), data) -r = debug.setuservalue(u, old) -is(debug.getuservalue(u), old) - -error_like(function () debug.setuservalue({}, data) end, - "^[^:]+:%d+: bad argument #1 to 'setuservalue' %(userdata expected, got table%)") - -error_like(function () debug.setuservalue(u, true) end, - "^[^:]+:%d+: bad argument #2 to 'setuservalue' %(table expected, got boolean%)") - -like(debug.traceback(), "^stack traceback:\n", "function traceback") - -like(debug.traceback("message\n"), "^message\n\nstack traceback:\n", "function traceback with message") - -like(debug.traceback(false), "false", "function traceback") - -local id = debug.upvalueid(plan, 1) -type_ok(id, 'userdata', "function upvalueid") - -debug.upvaluejoin (pass, 1, fail, 1) - -error_like(function () debug.upvaluejoin(true, 1, nil, 1) end, - "bad argument #1 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - -error_like(function () debug.upvaluejoin(pass, 1, true, 1) end, - "bad argument #3 to 'upvaluejoin' %(function expected, got boolean%)", - "function upvaluejoin (bad arg)") - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/314-regex.t b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/314-regex.t deleted file mode 100644 index 89d89142..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/314-regex.t +++ /dev/null @@ -1,346 +0,0 @@ -#! /usr/bin/lua --- --- lua-TestMore : --- --- Copyright (C) 2009-2013, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Regex Compiler - -=head2 Synopsis - - % prove 314-regex.t - -=head2 Description - -Tests Lua Regex - -Individual tests are stored in the C files in the same directory; -There is one test per line: each test consists of the following -columns (separated by one *or more* tabs): - -=over 4 - -=item pattern - -The Lua regex to test. - -=item target - -The string that will be matched against the pattern. Use '' to indicate -an empty string. - -=item result - -The expected result of the match. - -=item description - -Description of the test. - -=back - -=cut - ---]] - -local test_patterns = { - [===[(a.)..(..) zzzabcdefzzz ab\tef basic match]===], - [===[(a(b(c))(d)) abcd abcd\tbc\tc\td nested match]===], - [===[((%w+)) abcd abcd\tabcd nested match]===], - [===[(a*(.)%w(%s*)) aa!b c aa!b \t!\t nested match]===], - [===[(a?).. abcd a opt]===], - [===[(A?).. abcd '' opt]===], - [===[()aa() flaaap 3\t5 empty capture]===], - [===[(.)%1 bookkeeper o backreference]===], - [===[(%w+)%s+%1 hello hello hello backreference]===], - [===[(.*)x 123x 123 repeated dot capture]===], - [===[$(%w+) $abc= abc not escaped]===], - [===[[c] abcdef c character class]===], - [===[^[a] abcdef a anchored character class]===], - [===[[^e] abcdef a negated character class]===], - [===[^[a]? abcdef a anchored optional character class]===], - [===[[^e]? abcdef a negated optional character class]===], - [===[^[^e] abcdef a anchored negated character class]===], - [===[^[^a] abcdef nil anchored negated character class]===], - [===[[b-d] abcdef b character range]===], - [===[[b-d] abxxef b character range]===], - [===[[b-d] axcxef c character range]===], - [===[[b-d] axxdef d character range]===], - [===[[b-d] axxxef nil character range]===], - [===[[^b-d] abcdef a negated character range]===], - [===[[^b-d] bbccdd nil negated character range]===], - [===[[-] ab-def - unescaped hyphen]===], - [===[[%-] ab-def - escaped hyphen]===], - [===[[%-] abcdef nil escaped hyphen]===], - [===[[^%-] ---x-- x negated escaped hyphen]===], - [===[[^%-] ------ nil negated escaped hyphen]===], - [===[[%-+] ab-def - escaped hyphen in range]===], - [===[[%-+] ab+def + escaped hyphen in range]===], - [===[[%-+] abcdef nil escaped hyphen in range]===], - [===[[+%-] ab-def - escaped hyphen in range]===], - [===[[+%-] ab+def + escaped hyphen in range]===], - [===[[+%-] abcdef nil escaped hyphen in range]===], - [===[[^%-+] ---x-- x negated escaped hyphen in range]===], - [===[[^%-+] ------ nil negated escaped hyphen in range]===], - [===[[^+%-] ---x-- x negated escaped hyphen in range]===], - [===[[^+%-] ------ nil negated escaped hyphen in range]===], - [===[["\\] \\ \ escaped backslash]===], - [===[[%]] ] ] escaped close bracket]===], - [===[[%] \\]] /malformed pattern %(missing ']'%)/ unescaped backslash (or no closing brace)]===], - [===[ab\\cd ab\092cd ab\cd literal match with backslash]===], - [===[%? ab --- --- Copyright (C) 2009-2011, Perrad Francois --- --- This code is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- - ---[[ - -=head1 Lua Library - -=head2 Synopsis - - % prove 320-stdin.t - -=head2 Description - -Tests Lua Basic & IO Libraries with stdin - -=cut - ---]] - -require 'Test.More' - -local lua = (platform and platform.lua) or arg[-1] - -if not pcall(io.popen, lua .. [[ -e "a=1"]]) then - skip_all "io.popen not supported" -end - -plan(12) - -f = io.open('lib1.lua', 'w') -f:write[[ -function norm (x, y) - return (x^2 + y^2)^0.5 -end - -function twice (x) - return 2*x -end -]] -f:close() - -cmd = lua .. [[ -e "dofile(); n = norm(3.4, 1.0); print(twice(n))" < lib1.lua]] -f = io.popen(cmd) -like(f:read'*l', '^7%.088', "function dofile (stdin)") -f:close() - -os.remove('lib1.lua') -- clean up - -f = io.open('foo.lua', 'w') -f:write[[ -function foo (x) - return x -end -]] -f:close() - -cmd = lua .. [[ -e "f = loadfile(); print(foo); f(); print(foo('ok'))" < foo.lua]] -f = io.popen(cmd) -is(f:read'*l', 'nil', "function loadfile (stdin)") -is(f:read'*l', 'ok') -f:close() - -os.remove('foo.lua') -- clean up - -f = io.open('file.txt', 'w') -f:write("file with text\n") -f:close() - -cmd = lua .. [[ -e "print(io.read'*l'); print(io.read'*l'); print(io.type(io.stdin))" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.read *l") -is(f:read'*l', 'nil') -is(f:read'*l', 'file') -f:close() - -f = io.open('number.txt', 'w') -f:write("6.0 -3.23 15e12\n") -f:write("4.3 234 1000001\n") -f:close() - -cmd = lua .. [[ -e "while true do local n1, n2, n3 = io.read('*number', '*number', '*number'); if not n1 then break end; print(math.max(n1, n2, n3)) end" < number.txt]] -f = io.popen(cmd) -is(f:read'*l', '15000000000000', "function io:read *number") -is(f:read'*l', '1000001') -f:close() - -os.remove('number.txt') -- clean up - -cmd = lua .. [[ -e "for line in io.lines() do print(line) end" < file.txt]] -f = io.popen(cmd) -is(f:read'*l', 'file with text', "function io.lines") -is(f:read'*l', nil) -f:close() - -os.remove('file.txt') -- clean up - -f = io.open('dbg.txt', 'w') -f:write("print 'ok'\n") -f:write("error 'dbg'\n") -f:write("cont\n") -f:close() - -cmd = lua .. [[ -e "debug.debug()" < dbg.txt]] -f = io.popen(cmd) -is(f:read'*l', 'ok', "function debug.debug") -is(f:read'*l', nil) -f:close() - -os.remove('dbg.txt') -- clean up - - --- Local Variables: --- mode: lua --- lua-indent-level: 4 --- fill-column: 100 --- End: --- vim: ft=lua expandtab shiftwidth=4: diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Makefile b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Makefile deleted file mode 100644 index 7593592c..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Makefile +++ /dev/null @@ -1,67 +0,0 @@ - -LUA = ../../lua-5.2.3/src/lua -LUAJIT = luajit -LUA_COVER = ../../gh-pages/lua-TestMore/lua-5.2.3/src/lua - -LUA_VERSION = $(shell $(LUA) -e "print(_VERSION)") -OSNAME = $(shell perl -MConfig -e "print Config->{osname}") -ARCHNAME = $(shell perl -MConfig -e "print Config->{archname}") -INTSIZE = $(shell perl -MConfig -e "print Config->{longsize}") - -export LUA_PATH=;;../src/?.lua -export LUA_INIT=platform = { osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -version: - @echo $(LUA_VERSION) - -harness: - prove --exec=$(LUA) *.t - -sanity: - prove --exec=$(LUA) 0*.t - -luajit: - prove --exec=$(LUAJIT) *.t - -coverage: - prove --exec=$(LUA_COVER) *.t - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA), $(LUA_VERSION)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: - -prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e '$(upload_pl)' diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/Builder.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/Builder.lua deleted file mode 100644 index 9fc87c9b..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/Builder.lua +++ /dev/null @@ -1,392 +0,0 @@ - --- --- lua-TestMore : --- - -local debug = nil; -- require 'debug' -local io = nil; -- require 'io' -local os = nil; -- require 'os' -local error = error -local gsub = require 'string'.gsub -local match = require 'string'.match -local pairs = pairs -local pcall = pcall -local print = print -local rawget = rawget -local setmetatable = setmetatable -local tconcat = require 'table'.concat -local tonumber = tonumber -local tostring = tostring -local type = type - -_ENV = nil -local m = {} - -local testout = io and io.stdout -local testerr = io and (io.stderr or io.stdout) - -function m.puts (f, str) - f:write(str) -end - -local function _print_to_fh (self, f, ...) - -- if f then - -- local msg = tconcat({...}) - -- gsub(msg, "\n", "\n" .. self.indent) - -- m.puts(f, self.indent .. msg .. "\n") - -- else - print(self.indent, ...) - -- end -end - -local function _print (self, ...) - _print_to_fh(self, self:output(), ...) -end - -local function print_comment (self, f, ...) - local arg = {...} - for k, v in pairs(arg) do - arg[k] = tostring(v) - end - local msg = tconcat(arg) - msg = gsub(msg, "\n", "\n# ") - msg = gsub(msg, "\n# \n", "\n#\n") - msg = gsub(msg, "\n# $", '') - _print_to_fh(self, f, "# ", msg) -end - -function m.create () - local o = { - data = setmetatable({}, { __index = m }), - } - setmetatable(o, { - __index = function (t, k) - return rawget(t, 'data')[k] - end, - __newindex = function (t, k, v) - rawget(o, 'data')[k] = v - end, - }) - o:reset() - return o -end - -local test -function m.new () - test = test or m.create() - return test -end - -local function in_todo (self) - return self.todo_upto >= self.curr_test -end - -function m:child (name) - if self.child_name then - error("You already have a child named (" .. self.child_name .. " running") - end - local child = m.create() - child.indent = self.indent .. ' ' - child.out_file = self.out_file - child.fail_file = in_todo(self) and self.todo_file or self.fail_file - child.todo_file = self.todo_file - child.parent = self - self.child_name = name - return child -end - -local function plan_handled (self) - return self.have_plan or self.no_plan or self._skip_all -end - -function m:subtest (name, func) - if type(func) ~= 'function' then - error("subtest()'s second argument must be a function") - end - self:diag('Subtest: ' .. name) - local child = self:child(name) - local parent = self.data - self.data = child.data - local r, msg = pcall(func) - child.data = self.data - self.data = parent - if not r and not child._skip_all then - error(msg, 0) - end - if not plan_handled(child) then - child:done_testing() - end - child:finalize() -end - -function m:finalize () - if not self.parent then - return - end - if self.child_name then - error("Can't call finalize() with child (" .. self.child_name .. " active") - end - local parent = self.parent - local name = parent.child_name - parent.child_name = nil - if self._skip_all then - parent:skip(self._skip_all) - elseif self.curr_test == 0 then - parent:ok(false, "No tests run for subtest \"" .. name .. "\"", 2) - else - parent:ok(self.is_passing, name, 2) - end - self.parent = nil -end - -function m:reset () - self.curr_test = 0 - self._done_testing = false - self.expected_tests = 0 - self.is_passing = true - self.todo_upto = -1 - self.todo_reason = nil - self.have_plan = false - self.no_plan = false - self._skip_all = false - self.have_output_plan = false - self.indent = '' - self.parent = false - self.child_name = false - self:reset_outputs() -end - -local function _output_plan (self, max, directive, reason) - if self.have_output_plan then - error("The plan was already output") - end - local out = "1.." .. max - if directive then - out = out .. " # " .. directive - end - if reason then - out = out .. " " .. reason - end - _print(self, out) - self.have_output_plan = true -end - -function m:plan (arg) - if self.have_plan then - error("You tried to plan twice") - end - if type(arg) == 'string' and arg == 'no_plan' then - self.have_plan = true - self.no_plan = true - return true - elseif type(arg) ~= 'number' then - error("Need a number of tests") - elseif arg < 0 then - error("Number of tests must be a positive integer. You gave it '" .. arg .."'.") - else - self.expected_tests = arg - self.have_plan = true - _output_plan(self, arg) - return arg - end -end - -function m:done_testing (num_tests) - if num_tests then - self.no_plan = false - end - num_tests = num_tests or self.curr_test - if self._done_testing then - tb:ok(false, "done_testing() was already called") - return - end - self._done_testing = true - if self.expected_tests > 0 and num_tests ~= self.expected_tests then - self:ok(false, "planned to run " .. self.expected_tests - .. " but done_testing() expects " .. num_tests) - else - self.expected_tests = num_tests - end - if not self.have_output_plan then - _output_plan(self, num_tests) - end - self.have_plan = true - -- The wrong number of tests were run - if self.expected_tests ~= self.curr_test then - self.is_passing = false - end - -- No tests were run - if self.curr_test == 0 then - self.is_passing = false - end -end - -function m:has_plan () - if self.expected_tests > 0 then - return self.expected_tests - end - if self.no_plan then - return 'no_plan' - end - return nil -end - -function m:skip_all (reason) - if self.have_plan then - error("You tried to plan twice") - end - self._skip_all = reason - _output_plan(self, 0, 'SKIP', reason) - if self.parent then - error("skip_all in child", 0) - end - -- os.exit(0) -end - -local function _check_is_passing_plan (self) - local plan = self:has_plan() - if not plan or not tonumber(plan) then - return - end - if plan < self.curr_test then - self.is_passing = false - end -end - -function m:ok (test, name, level) - if self.child_name then - name = name or 'unnamed test' - self.is_passing = false - error("Cannot run test (" .. name .. ") with active children") - end - name = name or '' - level = level or 0 - self.curr_test = self.curr_test + 1 - name = tostring(name) - if match(name, '^[%d%s]+$') then - self:diag(" You named your test '" .. name .."'. You shouldn't use numbers for your test names." - .. "\n Very confusing.") - end - local out = '' - if not test then - out = "not " - end - out = out .. "ok " .. self.curr_test - if name ~= '' then - out = out .. " - " .. name - end - if self.todo_reason and in_todo(self) then - out = out .. " # TODO " .. self.todo_reason - end - _print(self, out) - if not test then - local msg = in_todo(self) and "Failed (TODO)" or "Failed" - local info = debug and debug.getinfo(3 + level) - if info then - local file = info.short_src - local line = info.currentline - self:diag(" " .. msg .. " test (" .. file .. " at line " .. line .. ")") - else - self:diag(" " .. msg .. " test") - end - end - if not test and not in_todo(self) then - self.is_passing = false - end - _check_is_passing_plan(self) -end - -function m:BAIL_OUT (reason) - local out = "Bail out!" - if reason then - out = out .. " " .. reason - end - _print(self, out) - os.exit(255) -end - -function m:current_test (num) - if num then - self.curr_test = num - end - return self.curr_test -end - -function m:todo (reason, count) - count = count or 1 - self.todo_upto = self.curr_test + count - self.todo_reason = reason -end - -function m:skip (reason) - local name = "# skip" - if reason then - name = name .. " " .. reason - end - self:ok(true, name, 1) -end - -function m:todo_skip (reason) - local name = "# TODO & SKIP" - if reason then - name = name .. " " .. reason - end - self:ok(false, name, 1) -end - -function m:skip_rest (reason) - for i = self.curr_test, self.expected_tests do - tb:skip(reason) - end -end - -local function diag_file (self) - if in_todo(self) then - return self:todo_output() - else - return self:failure_output() - end -end - -function m:diag (...) - print_comment(self, diag_file(self), ...) -end - -function m:note (...) - print_comment(self, self:output(), ...) -end - -function m:output (f) - if f then - self.out_file = f - end - return self.out_file -end - -function m:failure_output (f) - if f then - self.fail_file = f - end - return self.fail_file -end - -function m:todo_output (f) - if f then - self.todo_file = f - end - return self.todo_file -end - -function m:reset_outputs () - self:output(testout) - self:failure_output(testerr) - self:todo_output(testout) -end - -return m --- --- Copyright (c) 2009-2012 Francois Perrad --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/More.lua b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/More.lua deleted file mode 100644 index 9f417ca4..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/Modules/Test/More.lua +++ /dev/null @@ -1,383 +0,0 @@ - --- --- lua-TestMore : --- - -local loadstring = loadstring or load -local pairs = pairs -local pcall = pcall -local require = require -local tostring = tostring -local type = type -local match = require 'string'.match -local unpack = require 'table'.unpack or unpack -local _G = _G - -local tb = require 'Test.Builder'.new() - -_ENV = nil -local m = {} - -function m.plan (arg) - tb:plan(arg) -end - -function m.done_testing (num_tests) - tb:done_testing(num_tests) -end - -function m.skip_all (reason) - tb:skip_all(reason) -end - -function m.BAIL_OUT (reason) - tb:BAIL_OUT(reason) -end - -function m.ok (test, name) - tb:ok(test, name) -end - -function m.nok (test, name) - tb:ok(not test, name) -end - -function m.is (got, expected, name) - local pass = got == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: " .. tostring(expected)) - end -end - -function m.isnt (got, expected, name) - local pass = got ~= expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. tostring(got) - .. "\n expected: anything else") - end -end - -function m.like (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end -end - -function m.unlike (got, pattern, name) - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - got = tostring(got) - local pass = not match(got, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. got .. "'" - .. "\n matches '" .. pattern .. "'") - end -end - -local cmp = { - ['<'] = function (a, b) return a < b end, - ['<='] = function (a, b) return a <= b end, - ['>'] = function (a, b) return a > b end, - ['>='] = function (a, b) return a >= b end, - ['=='] = function (a, b) return a == b end, - ['~='] = function (a, b) return a ~= b end, -} - -function m.cmp_ok (this, op, that, name) - local f = cmp[op] - if not f then - tb:ok(false, name) - tb:diag("unknown operator : " .. tostring(op)) - return - end - local pass = f(this, that) - tb:ok(pass, name) - if not pass then - tb:diag(" " .. tostring(this) - .. "\n " .. op - .. "\n " .. tostring(that)) - end -end - -function m.type_ok (val, t, name) - if type(t) ~= 'string' then - tb:ok(false, name) - tb:diag("type isn't a string : " .. tostring(t)) - return - end - if type(val) == t then - tb:ok(true, name) - else - tb:ok(false, name) - tb:diag(" " .. tostring(val) .. " isn't a '" .. t .."' it's a '" .. type(val) .. "'") - end -end - -function m.subtest (name, func) - tb:subtest(name, func) -end - -function m.pass (name) - tb:ok(true, name) -end - -function m.fail (name) - tb:ok(false, name) -end - -function m.require_ok (mod) - local r, msg = pcall(require, mod) - tb:ok(r, "require '" .. tostring(mod) .. "'") - if not r then - tb:diag(" " .. msg) - end - return r -end - -function m.eq_array (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - for i = 1, #expected do - local v = expected[i] - local val = got[i] - if val ~= v then - tb:ok(false, name) - tb:diag(" at index: " .. tostring(i) - .. "\n got: " .. tostring(val) - .. "\n expected: " .. tostring(v)) - return - end - end - local extra = #got - #expected - if extra ~= 0 then - tb:ok(false, name) - tb:diag(" " .. tostring(extra) .. " unexpected item(s)") - else - tb:ok(true, name) - end -end - -function m.is_deeply (got, expected, name) - if type(got) ~= 'table' then - tb:ok(false, name) - tb:diag("got value isn't a table : " .. tostring(got)) - return - elseif type(expected) ~= 'table' then - tb:ok(false, name) - tb:diag("expected value isn't a table : " .. tostring(expected)) - return - end - local msg1 - local msg2 - local seen = {} - - local function deep_eq (t1, t2, key_path) - if t1 == t2 or seen[t1] then - return true - end - seen[t1] = true - for k, v2 in pairs(t2) do - local v1 = t1[k] - if type(v1) == 'table' and type(v2) == 'table' then - local r = deep_eq(v1, v2, key_path .. "." .. tostring(k)) - if not r then - return false - end - else - if v1 ~= v2 then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(v1) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - end - for k in pairs(t1) do - local v2 = t2[k] - if v2 == nil then - key_path = key_path .. "." .. tostring(k) - msg1 = " got" .. key_path .. ": " .. tostring(t1[k]) - msg2 = "expected" .. key_path .. ": " .. tostring(v2) - return false - end - end - return true - end -- deep_eq - - local pass = deep_eq(got, expected, '') - tb:ok(pass, name) - if not pass then - tb:diag(" Tables begin differing at:") - tb:diag(" " .. msg1) - tb:diag(" " .. msg2) - end -end - -function m.error_is (code, arg2, arg3, arg4) - local params, expected, name - if type(arg2) == 'table' then - params = arg2 - expected = arg3 - name = arg4 - else - params = {} - expected = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(expected)) - else - local pass = msg == expected - tb:ok(pass, name) - if not pass then - tb:diag(" got: " .. msg - .. "\n expected: " .. tostring(expected)) - end - end -end - -function m.error_like (code, arg2, arg3, arg4) - local params, pattern, name - if type(arg2) == 'table' then - params = arg2 - pattern = arg3 - name = arg4 - else - params = {} - pattern = arg2 - name = arg3 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - if r then - tb:ok(false, name) - tb:diag(" unexpected success" - .. "\n expected: " .. tostring(pattern)) - else - if type(pattern) ~= 'string' then - tb:ok(false, name) - tb:diag("pattern isn't a string : " .. tostring(pattern)) - return - end - local pass = match(msg, pattern) - tb:ok(pass, name) - if not pass then - tb:diag(" '" .. msg .. "'" - .. "\n doesn't match '" .. pattern .. "'") - end - end -end - -function m.lives_ok (code, arg2, arg3) - local params, name - if type(arg2) == 'table' then - params = arg2 - name = arg3 - else - params = {} - name = arg2 - end - if type(code) == 'string' then - local msg - code, msg = loadstring(code) - if not code then - tb:ok(false, name) - tb:diag(" can't compile code :" - .. "\n " .. msg) - return - end - end - local r, msg = pcall(code, unpack(params)) - tb:ok(r, name) - if not r then - tb:diag(" " .. msg) - end -end - -function m.diag (msg) - tb:diag(msg) -end - -function m.note (msg) - tb:note(msg) -end - -function m.skip (reason, count) - count = count or 1 - for i = 1, count do - tb:skip(reason) - end -end - -function m.todo_skip (reason, count) - count = count or 1 - for i = 1, count do - tb:todo_skip(reason) - end -end - -function m.skip_rest (reason) - tb:skip_rest(reason) -end - -function m.todo (reason, count) - tb:todo(reason, count) -end - -for k, v in pairs(m) do -- injection - _G[k] = v -end - -m._VERSION = "0.3.1" -m._DESCRIPTION = "lua-TestMore : an Unit Testing Framework" -m._COPYRIGHT = "Copyright (c) 2009-2012 Francois Perrad" -return m --- --- This library is licensed under the terms of the MIT/X11 license, --- like Lua itself. --- diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/makefile.mak b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/makefile.mak deleted file mode 100644 index e593ef85..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/TestMore/makefile.mak +++ /dev/null @@ -1,68 +0,0 @@ -# nmake /F makefile.mak - -LUAJIT = luajit.exe -LUA = lua.exe -LUAC = luac.exe - -RUN_LUA = $(LUA) -RUN_LUAC = $(LUAC) -OSNAME = MSWin32 -ARCHNAME = MSWin32-x86-multi-thread -INTSIZE = 4 - -harness: env - @prove --exec=$(LUA) *.t - -sanity: env - @prove --exec=$(LUA) 0*.t - -luajit: env - @prove --exec=$(LUAJIT) *.t - -llvm-lua: env - @prove --exec=$(LLVM_LUA) *.t - -env: - @set LUA_PATH=;;../src/?.lua - @set LUA_INIT=platform = { lua=[[$(RUN_LUA)]], luac=[[$(RUN_LUAC)]], osname=[[$(OSNAME)]], intsize=$(INTSIZE), compat=true } - -upload_pl = \ -use strict; \ -use warnings; \ -use LWP::UserAgent; \ -my $$ua = LWP::UserAgent->new(); \ -$$ua->env_proxy(); \ -my $$server = q{http://smolder.parrot.org}; \ -my $$project_id = 7; \ -my $$url = $$server . q{/app/projects/process_add_report/} . $$project_id; \ -my $$response = $$ua->post( \ - $$url, \ - Content_Type => q{form-data}, \ - Content => [ \ - architecture => q{$(ARCHNAME)}, \ - platform => q{$(OSNAME)}, \ - tags => q{$(OSNAME), $(ARCHNAME), $(LUA)}, \ - comments => q{$(LUA)}, \ - username => q{parrot-autobot}, \ - password => q{qa_rocks}, \ - project_id => $$project_id, \ - report_file => [q{test_lua52.tar.gz}], \ - ] \ -); \ -if ($$response->code == 302) { \ - my ($$report_id) = $$response->content =~ /Reported .(\d+) added/i; \ - my $$report_url = $$server . q{/app/public_projects/report_details/} . $$report_id; \ - my $$project_url = $$server . q{/app/public_projects/smoke_reports/} . $$project_id; \ - print qq{Test report successfully sent to Smolder at\n$$report_url} \ - . qq{\nYou can see other recent reports at\n$$project_url .\n\n}; \ -} \ -else { \ - die qq{Could not upload report to Smolder at $$server} \ - . qq{\nHTTP CODE: } . $$response->code . q{ (} \ - . $$response->message . qq{)\n}; \ -} - -smolder: env - -@prove --archive test_lua52.tar.gz --exec=$(LUA) *.t - perl -e "$(upload_pl)" - diff --git a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/packages.config b/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/packages.config deleted file mode 100644 index 512ce05d..00000000 --- a/src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.portable40/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter.Tests/packages.config b/src/MoonSharp.Interpreter.Tests/packages.config deleted file mode 100644 index 0816f446..00000000 --- a/src/MoonSharp.Interpreter.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/CodeAnalysis/AstNode.cs b/src/MoonSharp.Interpreter/CodeAnalysis/AstNode.cs deleted file mode 100644 index 0d098766..00000000 --- a/src/MoonSharp.Interpreter/CodeAnalysis/AstNode.cs +++ /dev/null @@ -1,7 +0,0 @@ - -namespace MoonSharp.Interpreter.CodeAnalysis -{ - class AstNode - { - } -} diff --git a/src/MoonSharp.Interpreter/Compatibility/Attributes.cs b/src/MoonSharp.Interpreter/Compatibility/Attributes.cs deleted file mode 100755 index a53bc57c..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Attributes.cs +++ /dev/null @@ -1,21 +0,0 @@ -#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System.Reflection -{ - internal class ComVisibleAttribute : Attribute - { - public ComVisibleAttribute(bool dummy) - { } - } - internal class GuidAttribute : Attribute - { - public GuidAttribute(string dummy) - { } - } -} -#endif - diff --git a/src/MoonSharp.Interpreter/Compatibility/Framework.cs b/src/MoonSharp.Interpreter/Compatibility/Framework.cs deleted file mode 100755 index 5961fd1e..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Framework.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility.Frameworks; - -namespace MoonSharp.Interpreter.Compatibility -{ - public static class Framework - { - static FrameworkCurrent s_FrameworkCurrent = new FrameworkCurrent(); - - public static FrameworkBase Do { get { return s_FrameworkCurrent; } } - } -} diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs deleted file mode 100755 index fd60c9db..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - public abstract class FrameworkBase - { - public abstract bool StringContainsChar(string str, char chr); - - public abstract bool IsValueType(Type t); - - public abstract Assembly GetAssembly(Type t); - - public abstract Type GetBaseType(Type t); - - public abstract bool IsGenericType(Type t); - - public abstract bool IsGenericTypeDefinition(Type t); - - public abstract bool IsEnum(Type t); - - public abstract bool IsNestedPublic(Type t); - - public abstract bool IsAbstract(Type t); - - public abstract bool IsInterface(Type t); - - public abstract Attribute[] GetCustomAttributes(Type t, bool inherit); - - public abstract Attribute[] GetCustomAttributes(Type t, Type at, bool inherit); - - public abstract Type[] GetInterfaces(Type t); - - public abstract bool IsInstanceOfType(Type t, object o); - - public abstract MethodInfo GetAddMethod(EventInfo ei); - - public abstract MethodInfo GetRemoveMethod(EventInfo ei); - - public abstract MethodInfo GetGetMethod(PropertyInfo pi); - - public abstract MethodInfo GetSetMethod(PropertyInfo pi); - - public abstract Type GetInterface(Type type, string name); - - public abstract PropertyInfo[] GetProperties(Type type); - - public abstract PropertyInfo GetProperty(Type type, string name); - - public abstract Type[] GetNestedTypes(Type type); - - public abstract EventInfo[] GetEvents(Type type); - - public abstract ConstructorInfo[] GetConstructors(Type type); - - public abstract Type[] GetAssemblyTypes(Assembly asm); - - public abstract MethodInfo[] GetMethods(Type type); - - public abstract FieldInfo[] GetFields(Type t); - - public abstract MethodInfo GetMethod(Type type, string name); - - public abstract Type[] GetGenericArguments(Type t); - - public abstract bool IsAssignableFrom(Type current, Type toCompare); - - public abstract bool IsDbNull(object o); - - public abstract MethodInfo GetMethod(Type resourcesType, string v, Type[] type); - } -} diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs deleted file mode 100755 index 1391755b..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs +++ /dev/null @@ -1,111 +0,0 @@ -#if !NETFX_CORE || DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkClrBase : FrameworkReflectionBase - { - BindingFlags BINDINGFLAGS_MEMBER = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - BindingFlags BINDINGFLAGS_INNERCLASS = BindingFlags.Public | BindingFlags.NonPublic; - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.GetAddMethod(true); - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return GetTypeInfoFromType(type).GetConstructors(BINDINGFLAGS_MEMBER); - } - - public override EventInfo[] GetEvents(Type type) - { - return GetTypeInfoFromType(type).GetEvents(BINDINGFLAGS_MEMBER); - } - - public override FieldInfo[] GetFields(Type type) - { - return GetTypeInfoFromType(type).GetFields(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetGenericArguments(Type type) - { - return GetTypeInfoFromType(type).GetGenericArguments(); - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetGetMethod(true); - } - - public override Type[] GetInterfaces(Type t) - { - return GetTypeInfoFromType(t).GetInterfaces(); - } - - public override MethodInfo GetMethod(Type type, string name) - { - return GetTypeInfoFromType(type).GetMethod(name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return GetTypeInfoFromType(type).GetMethods(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetNestedTypes(Type type) - { - return GetTypeInfoFromType(type).GetNestedTypes(BINDINGFLAGS_INNERCLASS); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return GetTypeInfoFromType(type).GetProperties(BINDINGFLAGS_MEMBER); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return GetTypeInfoFromType(type).GetProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.GetRemoveMethod(true); - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.GetSetMethod(true); - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return GetTypeInfoFromType(current).IsAssignableFrom(toCompare); - } - - public override bool IsInstanceOfType(Type t, object o) - { - return GetTypeInfoFromType(t).IsInstanceOfType(o); - } - - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return GetTypeInfoFromType(resourcesType).GetMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return asm.GetTypes(); - } - - } -} - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs deleted file mode 100755 index 10913658..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -#if DOTNET_CORE - using TTypeInfo = System.Reflection.TypeInfo; -#elif NETFX_CORE - using TTypeInfo = System.Reflection.TypeInfo; -#else - using TTypeInfo = System.Type; -#endif - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkReflectionBase : FrameworkBase - { - public abstract TTypeInfo GetTypeInfoFromType(Type t); - - public override Assembly GetAssembly(Type t) - { - return GetTypeInfoFromType(t).Assembly; - } - - public override Type GetBaseType(Type t) - { - return GetTypeInfoFromType(t).BaseType; - } - - - public override bool IsValueType(Type t) - { - return GetTypeInfoFromType(t).IsValueType; - } - - public override bool IsInterface(Type t) - { - return GetTypeInfoFromType(t).IsInterface; - } - - public override bool IsNestedPublic(Type t) - { - return GetTypeInfoFromType(t).IsNestedPublic; - } - public override bool IsAbstract(Type t) - { - return GetTypeInfoFromType(t).IsAbstract; - } - - public override bool IsEnum(Type t) - { - return GetTypeInfoFromType(t).IsEnum; - } - - public override bool IsGenericTypeDefinition(Type t) - { - return GetTypeInfoFromType(t).IsGenericTypeDefinition; - } - - public override bool IsGenericType(Type t) - { - return GetTypeInfoFromType(t).IsGenericType; - } - - public override Attribute[] GetCustomAttributes(Type t, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(inherit).OfType().ToArray(); - } - - public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType().ToArray(); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCLR.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCLR.cs deleted file mode 100755 index a362eb02..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCLR.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if !(DOTNET_CORE || NETFX_CORE) && !PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetTypeInfoFromType(Type t) - { - return t; - } - - public override bool IsDbNull(object o) - { - return o != null && Convert.IsDBNull(o); - } - - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterface(name); - } - } -} - -#endif diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCore.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCore.cs deleted file mode 100755 index c8c0b39a..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkCore.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetInterface(Type type, string name) - { - return type.GetTypeInfo().GetInterface(name); - } - - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - } -} -#endif diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkPCL.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkPCL.cs deleted file mode 100755 index c3bcc58b..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkPCL.cs +++ /dev/null @@ -1,35 +0,0 @@ -#if !(DOTNET_CORE || NETFX_CORE) && PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetTypeInfoFromType(Type t) - { - return t; - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr.ToString()); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterfaces(). - FirstOrDefault(t => t.Name == name); - } - } -} - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkWin8.cs b/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkWin8.cs deleted file mode 100755 index 7fd903b2..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Frameworks/FrameworkWin8.cs +++ /dev/null @@ -1,134 +0,0 @@ -#if NETFX_CORE && !DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkReflectionBase - { - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - private T[] SafeArray(IEnumerable prop) - { - return prop != null ? prop.ToArray() : new T[0]; - } - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.AddMethod; - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); - } - - public override EventInfo[] GetEvents(Type type) - { - return SafeArray(type.GetRuntimeEvents()); - } - - public override FieldInfo[] GetFields(Type type) - { - return SafeArray(type.GetRuntimeFields()); - } - - public override Type[] GetGenericArguments(Type type) - { - return type.GetTypeInfo().GenericTypeArguments; - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetMethod; - } - - public override Type GetInterface(Type type, string name) - { - return type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(t => t.Name == name); - } - - public override Type[] GetInterfaces(Type t) - { - return SafeArray(GetTypeInfoFromType(t).ImplementedInterfaces); - } - - public override MethodInfo GetMethod(Type type, string name) - { - return type.GetRuntimeMethods().FirstOrDefault(mi => mi.Name == name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return SafeArray(type.GetRuntimeMethods()); - } - - public override Type[] GetNestedTypes(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return SafeArray(type.GetRuntimeProperties()); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return type.GetRuntimeProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.RemoveMethod; - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.SetMethod; - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool IsInstanceOfType(Type t, object o) - { - if (o == null) - return false; - - return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo()); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return resourcesType.GetRuntimeMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return SafeArray(asm.DefinedTypes.Select(ti => ti.AsType())); - } - - } -} -#endif diff --git a/src/MoonSharp.Interpreter/Compatibility/Stopwatch.cs b/src/MoonSharp.Interpreter/Compatibility/Stopwatch.cs deleted file mode 100755 index 0655757f..00000000 --- a/src/MoonSharp.Interpreter/Compatibility/Stopwatch.cs +++ /dev/null @@ -1,41 +0,0 @@ -#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System.Diagnostics -{ - internal class Stopwatch - { - DateTime startTime, stopTime; - - public void Start() - { - startTime = DateTime.UtcNow; - } - - public void Stop() - { - stopTime = DateTime.UtcNow; - } - - public static Stopwatch StartNew() - { - Stopwatch sw = new Stopwatch(); - sw.Start(); - return sw; - } - - public long ElapsedMilliseconds - { - get - { - return (long)((stopTime - startTime).TotalMilliseconds); - } - } - - - } -} -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/CoreLib/BasicModule.cs b/src/MoonSharp.Interpreter/CoreLib/BasicModule.cs index 980e138c..a4796055 100755 --- a/src/MoonSharp.Interpreter/CoreLib/BasicModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/BasicModule.cs @@ -53,7 +53,7 @@ public static DynValue assert(ScriptExecutionContext executionContext, CallbackA // collectgarbage ([opt [, arg]]) // ---------------------------------------------------------------------------------------------------------------- - // This function is mostly a stub towards the CLR GC. If mode is nil, "collect" or "restart", a GC is forced. + // This function is a stub. Lua scripts cannot force a .NET GC [MoonSharpModuleMethod] public static DynValue collectgarbage(ScriptExecutionContext executionContext, CallbackArguments args) { @@ -61,14 +61,10 @@ public static DynValue collectgarbage(ScriptExecutionContext executionContext, C string mode = opt.CastToString(); - if (mode == null || mode == "collect" || mode == "restart") + /*if (mode == null || mode == "collect" || mode == "restart") { -#if PCL || ENABLE_DOTNET GC.Collect(); -#else - GC.Collect(2, GCCollectionMode.Forced); -#endif - } + }*/ return DynValue.Nil; } @@ -130,7 +126,7 @@ public static DynValue tostring(ScriptExecutionContext executionContext, Callbac DynValue v = args[0]; DynValue tail = executionContext.GetMetamethodTailCall(v, "__tostring", v); - if (tail == null || tail.IsNil()) + if (tail.IsNil()) return DynValue.NewString(v.ToPrintString()); tail.TailCallData.Continuation = new CallbackFunction(__tostring_continuation, "__tostring"); @@ -229,42 +225,47 @@ public static DynValue tonumber(ScriptExecutionContext executionContext, Callbac if (e.Type != DataType.String) return DynValue.Nil; - double d; - if (double.TryParse(e.String, NumberStyles.Any, CultureInfo.InvariantCulture, out d)) - { - return DynValue.NewNumber(d); - } + double? res = e.CastToNumber(); + if (res != null) return DynValue.NewNumber(res.Value); return DynValue.Nil; } else { - //!COMPAT: tonumber supports only 2,8,10 or 16 as base - //UPDATE: added support for 3-9 base numbers - DynValue ee; + DynValue ee; if (args[0].Type != DataType.Number) ee = args.AsType(0, "tonumber", DataType.String, false); else ee = DynValue.NewString(args[0].Number.ToString(CultureInfo.InvariantCulture)); ; - + if (ee.String.Length < 0) return DynValue.Nil; int bb = (int)b.Number; - uint uiv = 0; - if (bb == 2 || bb == 8 || bb == 10 || bb == 16) + double uiv = 0; + var trimmed = ee.String.Trim(); + if (trimmed.Length == 0) return DynValue.Nil; + bool negate = false; + int startIdx = 0; + if (trimmed[0] == '-') { + negate = true; + startIdx = 1; + } + if (trimmed[0] == '+') { + startIdx = 1; + } + if (bb <= 36 && bb > 1) { - uiv = Convert.ToUInt32(ee.String.Trim(), bb); - } - else if (bb < 10 && bb > 2) // Support for 3, 4, 5, 6, 7 and 9 based numbers - { - foreach (char digit in ee.String.Trim()) + for (int ij = startIdx; ij < trimmed.Length; ij++) { - int value = digit - 48; - if (value < 0 || value >= bb) + char ch = trimmed[ij]; + int value; + if (ch >= 97) value = ch - 87; + else if (ch >= 65) value = ch - 55; + else value = ch - 48; + if (value < 0 || value >= bb) { - throw new ScriptRuntimeException("bad argument #1 to 'tonumber' (invalid character)"); - } - - uiv = (uint)(uiv * bb) + (uint)value; + return DynValue.Nil; + } + uiv = uiv * bb + value; } } else @@ -272,7 +273,7 @@ public static DynValue tonumber(ScriptExecutionContext executionContext, Callbac throw new ScriptRuntimeException("bad argument #2 to 'tonumber' (base out of range)"); } - return DynValue.NewNumber(uiv); + return DynValue.NewNumber(negate ? -uiv : uiv); } } diff --git a/src/MoonSharp.Interpreter/CoreLib/DebugModule.cs b/src/MoonSharp.Interpreter/CoreLib/DebugModule.cs index c61d30ba..6343192c 100644 --- a/src/MoonSharp.Interpreter/CoreLib/DebugModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/DebugModule.cs @@ -36,7 +36,7 @@ public static DynValue debug(ScriptExecutionContext executionContext, CallbackAr { DynValue result = interpreter.Evaluate(s); - if (result != null && result.Type != DataType.Void) + if (result.IsNotNil() && result.Type != DataType.Void) script.Options.DebugPrint(string.Format("{0}", result)); } catch (InterpreterException ex) @@ -58,7 +58,7 @@ public static DynValue getuservalue(ScriptExecutionContext executionContext, Cal if (v.Type != DataType.UserData) return DynValue.Nil; - return v.UserData.UserValue ?? DynValue.Nil; + return v.UserData.UserValue; } [MoonSharpModuleMethod] @@ -125,7 +125,7 @@ public static DynValue getupvalue(ScriptExecutionContext executionContext, Callb return DynValue.NewTuple( DynValue.NewString(closure.Symbols[index]), - closure[index]); + closure[index].Value()); } @@ -163,7 +163,7 @@ public static DynValue setupvalue(ScriptExecutionContext executionContext, Callb if (index < 0 || index >= closure.Count) return DynValue.Nil; - closure[index].Assign(args[2]); + closure[index].Value() = args[2]; return DynValue.NewString(closure.Symbols[index]); } diff --git a/src/MoonSharp.Interpreter/CoreLib/ErrorHandlingModule.cs b/src/MoonSharp.Interpreter/CoreLib/ErrorHandlingModule.cs index ffa21d03..ef9122ed 100644 --- a/src/MoonSharp.Interpreter/CoreLib/ErrorHandlingModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/ErrorHandlingModule.cs @@ -14,7 +14,7 @@ public class ErrorHandlingModule [MoonSharpModuleMethod] public static DynValue pcall(ScriptExecutionContext executionContext, CallbackArguments args) { - return SetErrorHandlerStrategy("pcall", executionContext, args, null); + return SetErrorHandlerStrategy("pcall", executionContext, args, DynValue.Nil); } @@ -115,7 +115,7 @@ public static DynValue xpcall(ScriptExecutionContext executionContext, CallbackA a.Add(args[i]); } - DynValue handler = null; + DynValue handler = DynValue.Nil; if (args[1].Type == DataType.Function || args[1].Type == DataType.ClrFunction) { handler = args[1]; diff --git a/src/MoonSharp.Interpreter/CoreLib/IO/FileUserDataBase.cs b/src/MoonSharp.Interpreter/CoreLib/IO/FileUserDataBase.cs index a2177c56..418e825e 100755 --- a/src/MoonSharp.Interpreter/CoreLib/IO/FileUserDataBase.cs +++ b/src/MoonSharp.Interpreter/CoreLib/IO/FileUserDataBase.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.CoreLib.IO { @@ -14,7 +13,7 @@ public DynValue lines(ScriptExecutionContext executionContext, CallbackArguments { List readLines = new List(); - DynValue readValue = null; + DynValue readValue; do { @@ -191,10 +190,10 @@ private bool IsNumericChar(char c, string numAsFar) return numAsFar.Length == 0; if (c == '.') - return !Framework.Do.StringContainsChar(numAsFar, '.'); + return !numAsFar.Contains('.'); if (c == 'E' || c == 'e') - return !(Framework.Do.StringContainsChar(numAsFar, 'E') || Framework.Do.StringContainsChar(numAsFar, 'e')); + return !(numAsFar.Contains('E') || numAsFar.Contains('e')); return false; } diff --git a/src/MoonSharp.Interpreter/CoreLib/IO/StandardIOFileUserDataBase.cs b/src/MoonSharp.Interpreter/CoreLib/IO/StandardIOFileUserDataBase.cs index de00ec50..af830986 100644 --- a/src/MoonSharp.Interpreter/CoreLib/IO/StandardIOFileUserDataBase.cs +++ b/src/MoonSharp.Interpreter/CoreLib/IO/StandardIOFileUserDataBase.cs @@ -22,7 +22,7 @@ public static StandardIOFileUserDataBase CreateInputStream(Stream stream) public static StandardIOFileUserDataBase CreateOutputStream(Stream stream) { var f = new StandardIOFileUserDataBase(); - f.Initialize(stream, null, new StreamWriter(stream)); + f.Initialize(stream, null, new StreamWriter(stream) { AutoFlush = true }); return f; } diff --git a/src/MoonSharp.Interpreter/CoreLib/IoModule.cs b/src/MoonSharp.Interpreter/CoreLib/IoModule.cs index f7b1cd2d..c5b554e2 100755 --- a/src/MoonSharp.Interpreter/CoreLib/IoModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/IoModule.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Text; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.CoreLib.IO; using MoonSharp.Interpreter.Platforms; @@ -222,7 +221,7 @@ public static DynValue open(ScriptExecutionContext executionContext, CallbackArg // list of codes: http://msdn.microsoft.com/en-us/library/vstudio/system.text.encoding%28v=vs.90%29.aspx. // In addition, "binary" is available. Encoding e = null; - bool isBinary = Framework.Do.StringContainsChar(mode, 'b'); + bool isBinary = mode.Contains('b'); if (encoding == "binary") { diff --git a/src/MoonSharp.Interpreter/CoreLib/LoadModule.cs b/src/MoonSharp.Interpreter/CoreLib/LoadModule.cs index 3aaf96a4..017b5111 100755 --- a/src/MoonSharp.Interpreter/CoreLib/LoadModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/LoadModule.cs @@ -23,12 +23,8 @@ public static void MoonSharpInit(Table globalTable, Table ioTable) { throw new InternalErrorException("'package' global variable was found and it is not a table"); } - -#if PCL || ENABLE_DOTNET || NETFX_CORE - string cfg = "\\\n;\n?\n!\n-\n"; -#else + string cfg = System.IO.Path.DirectorySeparatorChar + "\n;\n?\n!\n-\n"; -#endif package.Table.Set("config", DynValue.NewString(cfg)); } diff --git a/src/MoonSharp.Interpreter/CoreLib/MetaTableModule.cs b/src/MoonSharp.Interpreter/CoreLib/MetaTableModule.cs index 6ba58cc3..a6e224e7 100644 --- a/src/MoonSharp.Interpreter/CoreLib/MetaTableModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/MetaTableModule.cs @@ -24,7 +24,7 @@ public static DynValue setmetatable(ScriptExecutionContext executionContext, Cal DynValue curmeta = executionContext.GetMetamethod(table, "__metatable"); - if (curmeta != null) + if (curmeta.IsNotNil()) { throw new ScriptRuntimeException("cannot change a protected metatable"); } @@ -56,7 +56,7 @@ public static DynValue getmetatable(ScriptExecutionContext executionContext, Cal if (meta == null) return DynValue.Nil; - else if (meta.RawGet("__metatable") != null) + else if (meta.RawGet("__metatable").IsNotNil()) return meta.Get("__metatable"); else return DynValue.NewTable(meta); diff --git a/src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs b/src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs index 762632fa..ad89ce70 100755 --- a/src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs @@ -35,7 +35,9 @@ private static DateTime FromUnixTime(double unixtime) [MoonSharpModuleMethod] public static DynValue clock(ScriptExecutionContext executionContext, CallbackArguments args) { - return GetUnixTime(DateTime.UtcNow, Time0); + var t = GetUnixTime(DateTime.UtcNow, Time0); + if (t.IsNil()) return DynValue.NewNumber(0.0); + return t; } [MoonSharpModuleMethod] @@ -119,7 +121,6 @@ public static DynValue date(ScriptExecutionContext executionContext, CallbackArg } else { -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) try { @@ -131,7 +132,6 @@ public static DynValue date(ScriptExecutionContext executionContext, CallbackArg // this catches a weird mono bug: https://bugzilla.xamarin.com/show_bug.cgi?id=11817 // however the behavior is definitely not correct. damn. } -#endif } diff --git a/src/MoonSharp.Interpreter/CoreLib/StringLib/KopiLua_StrLib.cs b/src/MoonSharp.Interpreter/CoreLib/StringLib/KopiLua_StrLib.cs index f9b90cb3..cd51912c 100644 --- a/src/MoonSharp.Interpreter/CoreLib/StringLib/KopiLua_StrLib.cs +++ b/src/MoonSharp.Interpreter/CoreLib/StringLib/KopiLua_StrLib.cs @@ -101,7 +101,7 @@ public class capture_ }; - public const int MAXCCALLS = 200; + public const int MAXCCALLS = 1000; public const char L_ESC = '%'; public const string SPECIALS = "^$*+?.([%-"; @@ -959,7 +959,7 @@ public static int str_format(LuaState L) case 's': { uint l; - CharPtr s = LuaLCheckLString(L, arg, out l); + CharPtr s = LuaLCheckLString(L, arg, out l, true); if ((strchr(form, '.') == null) && l >= 100) { /* no precision and string is too long to be formatted; diff --git a/src/MoonSharp.Interpreter/CoreLib/TableIteratorsModule.cs b/src/MoonSharp.Interpreter/CoreLib/TableIteratorsModule.cs index 6e3b84fe..a5d95fe8 100644 --- a/src/MoonSharp.Interpreter/CoreLib/TableIteratorsModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/TableIteratorsModule.cs @@ -23,7 +23,7 @@ public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackA DynValue meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray()); - return meta ?? DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0)); + return meta.IsNotNil() ? meta : DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(executionContext.OwnerScript.Options.IndexTablesFrom == 0 ? -1 : 0)); } // pairs (t) @@ -40,7 +40,7 @@ public static DynValue pairs(ScriptExecutionContext executionContext, CallbackAr DynValue meta = executionContext.GetMetamethodTailCall(table, "__pairs", args.GetArray()); - return meta ?? DynValue.NewTuple(DynValue.NewCallback(next), table); + return meta.IsNotNil() ? meta : DynValue.NewTuple(DynValue.NewCallback(next), table); } // next (table [, index]) diff --git a/src/MoonSharp.Interpreter/CoreLib/TableModule.cs b/src/MoonSharp.Interpreter/CoreLib/TableModule.cs index 1f623a06..593bcc01 100644 --- a/src/MoonSharp.Interpreter/CoreLib/TableModule.cs +++ b/src/MoonSharp.Interpreter/CoreLib/TableModule.cs @@ -41,7 +41,7 @@ public static DynValue pack(ScriptExecutionContext executionContext, CallbackArg DynValue v = DynValue.NewTable(t); for (int i = 0; i < args.Count; i++) - t.Set(i + 1, args[i]); + t.Set(i + executionContext.OwnerScript.Options.IndexTablesFrom, args[i]); t.Set("n", DynValue.NewNumber(args.Count)); @@ -61,7 +61,7 @@ public static DynValue sort(ScriptExecutionContext executionContext, CallbackArg List values = new List(); - for (int i = 1; i <= end; i++) + for (int i = executionContext.OwnerScript.Options.IndexTablesFrom; i < end + executionContext.OwnerScript.Options.IndexTablesFrom; i++) values.Add(vlist.Table.Get(i)); try @@ -76,7 +76,7 @@ public static DynValue sort(ScriptExecutionContext executionContext, CallbackArg for (int i = 0; i < values.Count; i++) { - vlist.Table.Set(i + 1, values[i]); + vlist.Table.Set(i + executionContext.OwnerScript.Options.IndexTablesFrom, values[i]); } return vlist; @@ -84,11 +84,11 @@ public static DynValue sort(ScriptExecutionContext executionContext, CallbackArg private static int SortComparer(ScriptExecutionContext executionContext, DynValue a, DynValue b, DynValue lt) { - if (lt == null || lt.IsNil()) + if (lt.IsNil()) { lt = executionContext.GetBinaryMetamethod(a, b, "__lt"); - if (lt == null || lt.IsNil()) + if (lt.IsNil()) { if (a.Type == DataType.Number && b.Type == DataType.Number) return a.Number.CompareTo(b.Number); @@ -144,7 +144,7 @@ public static DynValue insert(ScriptExecutionContext executionContext, CallbackA if (vvalue.IsNil()) { vvalue = vpos; - vpos = DynValue.NewNumber(len + 1); + vpos = DynValue.NewNumber(len + executionContext.OwnerScript.Options.IndexTablesFrom); } if (vpos.Type != DataType.Number) @@ -152,12 +152,12 @@ public static DynValue insert(ScriptExecutionContext executionContext, CallbackA int pos = (int)vpos.Number; - if (pos > len + 1 || pos < 1) + if (pos > len + 1 || pos < executionContext.OwnerScript.Options.IndexTablesFrom) throw new ScriptRuntimeException("bad argument #2 to 'insert' (position out of bounds)"); for (int i = len; i >= pos; i--) { - list.Set(i + 1, list.Get(i)); + list.Set(i + executionContext.OwnerScript.Options.IndexTablesFrom, list.Get(i)); } list.Set(pos, vvalue); @@ -181,7 +181,7 @@ public static DynValue remove(ScriptExecutionContext executionContext, CallbackA int pos = vpos.IsNil() ? len : (int)vpos.Number; - if (pos >= len + 1 || (pos < 1 && len > 0)) + if (pos >= len + 1 || (pos < executionContext.OwnerScript.Options.IndexTablesFrom && len > 0)) throw new ScriptRuntimeException("bad argument #1 to 'remove' (position out of bounds)"); for (int i = pos; i <= len; i++) @@ -210,24 +210,15 @@ public static DynValue concat(ScriptExecutionContext executionContext, CallbackA Table list = vlist.Table; string sep = vsep.IsNil() ? "" : vsep.String; - int start = vstart.IsNilOrNan() ? 1 : (int)vstart.Number; - int end; - - if (vend.IsNilOrNan()) - { - end = GetTableLength(executionContext, vlist); - } - else - { - end = (int)vend.Number; - } + int start = vstart.IsNilOrNan() ? executionContext.OwnerScript.Options.IndexTablesFrom : vstart.CastToInt() ?? 0; + int end = vend.IsNilOrNan() ? GetTableLength(executionContext, vlist) : vend.CastToInt() ?? 0; if (end < start) return DynValue.NewString(string.Empty); StringBuilder sb = new StringBuilder(); - for (int i = start; i <= end; i++) + for (int i = start; i < end + executionContext.OwnerScript.Options.IndexTablesFrom; i++) { DynValue v = list.Get(i); @@ -250,7 +241,7 @@ private static int GetTableLength(ScriptExecutionContext executionContext, DynVa { DynValue __len = executionContext.GetMetamethod(vlist, "__len"); - if (__len != null) + if (__len.IsNotNil()) { DynValue lenv = executionContext.GetScript().Call(__len, vlist); diff --git a/src/MoonSharp.Interpreter/DataStructs/FastStack.cs b/src/MoonSharp.Interpreter/DataStructs/FastStack.cs index f9dbf83c..3ac9a3b0 100644 --- a/src/MoonSharp.Interpreter/DataStructs/FastStack.cs +++ b/src/MoonSharp.Interpreter/DataStructs/FastStack.cs @@ -13,27 +13,48 @@ internal class FastStack : IList { T[] m_Storage; int m_HeadIdx = 0; + private int maxCapacity; - public FastStack(int maxCapacity) + public int MaxCapacity => maxCapacity; + + public FastStack(int initialCapacity, int maxCapacity) { - m_Storage = new T[maxCapacity]; + m_Storage = new T[initialCapacity]; + this.maxCapacity = maxCapacity; } - public T this[int index] + public ref T this[int index] => ref m_Storage[index]; + + + + void Grow(int newSize) { - get { return m_Storage[index]; } - set { m_Storage[index] = value; } + if (newSize < m_Storage.Length) return; + if (newSize > maxCapacity) + { + throw new OutOfMemoryException($"Trying to grow stack beyond Max Capacity ({newSize} > {maxCapacity})."); + } + int sz = m_Storage.Length; + while (newSize > sz) { + sz *= 2; + } + if (sz >= maxCapacity) sz = maxCapacity; + Array.Resize(ref m_Storage, sz); } public T Push(T item) { + Grow(m_HeadIdx + 1); m_Storage[m_HeadIdx++] = item; return item; } - public void Expand(int size) + public int Reserve(int size) { + Grow(m_HeadIdx + size); + var retval = m_HeadIdx; m_HeadIdx += size; + return retval; } private void Zero(int from, int to) @@ -46,10 +67,10 @@ private void Zero(int index) m_Storage[index] = default(T); } - public T Peek(int idxofs = 0) + public ref T Peek(int idxofs = 0) { - T item = m_Storage[m_HeadIdx - 1 - idxofs]; - return item; + ref T item = ref m_Storage[m_HeadIdx - 1 - idxofs]; + return ref item; } public void Set(int idxofs, T item) @@ -91,6 +112,12 @@ public void Clear() m_HeadIdx = 0; } + public void ClearSection(int index, int length) + { + Array.Clear(m_Storage, index, length); + } + + public int Count { get { return m_HeadIdx; } diff --git a/src/MoonSharp.Interpreter/DataStructs/FastStackDynamic.cs b/src/MoonSharp.Interpreter/DataStructs/FastStackDynamic.cs deleted file mode 100644 index 00c54f8b..00000000 --- a/src/MoonSharp.Interpreter/DataStructs/FastStackDynamic.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ -#if USE_DYNAMIC_STACKS - internal class FastStack : FastStackDynamic - { - public FastStack(int startingCapacity) - : base(startingCapacity) - { - } - } -#endif - - /// - /// A non preallocated, non_fixed size stack - /// - /// - internal class FastStackDynamic : List - { - public FastStackDynamic(int startingCapacity) - : base(startingCapacity) - { - } - - - public void Set(int idxofs, T item) - { - this[this.Count - 1 - idxofs] = item; - } - - - public T Push(T item) - { - this.Add(item); - return item; - } - - public void Expand(int size) - { - for(int i = 0; i < size; i++) - this.Add(default(T)); - } - - public void Zero(int index) - { - this[index] = default(T); - } - - public T Peek(int idxofs = 0) - { - T item = this[this.Count - 1 - idxofs]; - return item; - } - public void CropAtCount(int p) - { - RemoveLast(Count - p); - } - - public void RemoveLast( int cnt = 1) - { - if (cnt == 1) - { - this.RemoveAt(this.Count - 1); - } - else - { - this.RemoveRange(this.Count - cnt, cnt); - } - } - - public T Pop() - { - T retval = this[this.Count - 1]; - this.RemoveAt(this.Count - 1); - return retval; - } - } -} - - diff --git a/src/MoonSharp.Interpreter/DataStructs/LinkedListArrayIndex.cs b/src/MoonSharp.Interpreter/DataStructs/LinkedListArrayIndex.cs new file mode 100644 index 00000000..2d2ee362 --- /dev/null +++ b/src/MoonSharp.Interpreter/DataStructs/LinkedListArrayIndex.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; + +namespace MoonSharp.Interpreter.DataStructs +{ + internal class LinkedListArrayIndex : LinkedListIndex + { + + /// + /// Initializes a new instance of the class. + /// + /// The linked list to be indexed. + public LinkedListArrayIndex(LinkedList linkedList) : base(linkedList) { } + + private LinkedListNode[] positive; + + /// + /// Finds the node indexed by the specified key, or null. + /// + /// The key. + public override LinkedListNode Find(int key) + { + if (key >= 0) + { + if (positive != null && key < positive.Length) + return positive[key]; + } + return base.Find(key); + } + + /// + /// Updates or creates a new node in the linked list, indexed by the specified key. + /// + /// The key. + /// The value. + /// The previous value of the element + public override TValue Set(int key, TValue value) + { + LinkedListNode node = Find(key); + + if (node == null) + { + Add(key, value); + return default(TValue); + } + else + { + TValue val = node.Value; + node.Value = value; + return val; + } + } + + /// + /// Creates a new node in the linked list, indexed by the specified key. + /// + /// The key. + /// The value. + public override void Add(int key, TValue value) + { + if (key >= 0) + { + if (positive == null || key >= positive.Length) + { + int pLen = positive?.Length ?? 0; + int newLen = Math.Max(pLen + 16, pLen * 2); + if (key > newLen) + base.Add(key,value); + else + { + if (positive == null) positive = new LinkedListNode[16]; + else Array.Resize(ref positive, newLen); + var node = m_LinkedList.AddLast(value); + positive[key] = node; + } + } + else + { + var node = m_LinkedList.AddLast(value); + positive[key] = node; + } + } + else + { + base.Add(key, value); + } + } + + /// + /// Removes the specified key from the index, and the node indexed by the key from the linked list. + /// + /// The key. + public override bool Remove(int key) + { + if (key >= 0 && positive != null && key < positive.Length) + { + if (positive[key] != null) + { + positive[key] = null; + return true; + } + } + return base.Remove(key); + } + + /// + /// Clears this instance (removes all elements) + /// + public override void Clear() + { + if(positive != null) Array.Clear(positive, 0, positive.Length); + base.Clear(); + } + + public override bool ContainsKey(int key) + { + if (key >= 0 && positive != null && key < positive.Length) + { + if (positive[key] != null) + { + return true; + } + } + return base.ContainsKey(key); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/DataStructs/LinkedListIndex.cs b/src/MoonSharp.Interpreter/DataStructs/LinkedListIndex.cs index 58d41595..374d3cdf 100644 --- a/src/MoonSharp.Interpreter/DataStructs/LinkedListIndex.cs +++ b/src/MoonSharp.Interpreter/DataStructs/LinkedListIndex.cs @@ -11,7 +11,7 @@ namespace MoonSharp.Interpreter.DataStructs /// The type of the values contained in the linked list. internal class LinkedListIndex { - LinkedList m_LinkedList; + protected LinkedList m_LinkedList; Dictionary> m_Map = null; /// @@ -27,7 +27,7 @@ public LinkedListIndex(LinkedList linkedList) /// Finds the node indexed by the specified key, or null. /// /// The key. - public LinkedListNode Find(TKey key) + public virtual LinkedListNode Find(TKey key) { LinkedListNode node; @@ -46,7 +46,7 @@ public LinkedListNode Find(TKey key) /// The key. /// The value. /// The previous value of the element - public TValue Set(TKey key, TValue value) + public virtual TValue Set(TKey key, TValue value) { LinkedListNode node = Find(key); @@ -68,7 +68,7 @@ public TValue Set(TKey key, TValue value) /// /// The key. /// The value. - public void Add(TKey key, TValue value) + public virtual void Add(TKey key, TValue value) { var node = m_LinkedList.AddLast(value); @@ -82,7 +82,7 @@ public void Add(TKey key, TValue value) /// Removes the specified key from the index, and the node indexed by the key from the linked list. /// /// The key. - public bool Remove(TKey key) + public virtual bool Remove(TKey key) { LinkedListNode node = Find(key); @@ -100,7 +100,7 @@ public bool Remove(TKey key) /// Determines whether the index contains the specified key. /// /// The key. - public bool ContainsKey(TKey key) + public virtual bool ContainsKey(TKey key) { if (m_Map == null) return false; @@ -111,7 +111,7 @@ public bool ContainsKey(TKey key) /// /// Clears this instance (removes all elements) /// - public void Clear() + public virtual void Clear() { if(m_Map != null) m_Map.Clear(); diff --git a/src/MoonSharp.Interpreter/DataTypes/Annotation.cs b/src/MoonSharp.Interpreter/DataTypes/Annotation.cs new file mode 100644 index 00000000..515cac4d --- /dev/null +++ b/src/MoonSharp.Interpreter/DataTypes/Annotation.cs @@ -0,0 +1,19 @@ +namespace MoonSharp.Interpreter +{ + public class Annotation + { + public string Name { get; private set; } + public DynValue Value { get; private set; } + + public Annotation(string name, DynValue value) + { + Name = name; + Value = value; + } + + public override string ToString() + { + return $"{Name}: {Value}"; + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs b/src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs index 435bac90..a596cba4 100644 --- a/src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs +++ b/src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs @@ -68,7 +68,7 @@ public DynValue this[int index] { get { - return RawGet(index, true) ?? DynValue.Void; + return RawGet(index, true); } } @@ -83,7 +83,7 @@ public DynValue RawGet(int index, bool translateVoids) DynValue v; if (index >= m_Count) - return null; + return DynValue.Void; //Special case of returning void for no argument provided. Not translated if (!m_LastIsTuple || index < m_Args.Count - 1) v = m_Args[index]; @@ -192,7 +192,7 @@ public long AsLong(int argNum, string funcName) public string AsStringUsingMeta(ScriptExecutionContext executionContext, int argNum, string funcName) { if ((this[argNum].Type == DataType.Table) && (this[argNum].Table.MetaTable != null) && - (this[argNum].Table.MetaTable.RawGet("__tostring") != null)) + (this[argNum].Table.MetaTable.RawGet("__tostring").IsNotNil())) { var v = executionContext.GetScript().Call(this[argNum].Table.MetaTable.RawGet("__tostring"), this[argNum]); diff --git a/src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs b/src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs index 33e68c4a..ea164baf 100755 --- a/src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs +++ b/src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs @@ -88,12 +88,9 @@ public static CallbackFunction FromDelegate(Script script, Delegate del, Interop { if (accessMode == InteropAccessMode.Default) accessMode = m_DefaultAccessMode; - -#if NETFX_CORE - MethodMemberDescriptor descr = new MethodMemberDescriptor(del.GetMethodInfo(), accessMode); -#else + MethodMemberDescriptor descr = new MethodMemberDescriptor(del.Method, accessMode); -#endif + return descr.GetCallbackFunction(script, del.Target); } diff --git a/src/MoonSharp.Interpreter/DataTypes/Closure.cs b/src/MoonSharp.Interpreter/DataTypes/Closure.cs index 0ed8e705..5f19590a 100644 --- a/src/MoonSharp.Interpreter/DataTypes/Closure.cs +++ b/src/MoonSharp.Interpreter/DataTypes/Closure.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter @@ -26,6 +28,11 @@ public enum UpvaluesType /// Closure } + + /// + /// Gets the annotations made on this function. + /// + public IReadOnlyList Annotations { get; private set; } /// @@ -58,12 +65,14 @@ public enum UpvaluesType /// The index. /// The symbols. /// The resolved locals. - internal Closure(Script script, int idx, SymbolRef[] symbols, IEnumerable resolvedLocals) + internal Closure(Script script, int idx, SymbolRef[] symbols, Annotation[] annotations, IEnumerable resolvedLocals) { OwnerScript = script; EntryPointByteCodeLocation = idx; + Annotations = annotations ?? Array.Empty(); + if (symbols.Length > 0) ClosureContext = new ClosureContext(symbols, resolvedLocals); else @@ -101,6 +110,21 @@ public DynValue Call(params DynValue[] args) { return OwnerScript.Call(this, args); } + + public Task CallAsync() + { + return OwnerScript.CallAsync(this); + } + + public Task CallAsync(params object[] args) + { + return OwnerScript.CallAsync(this, args); + } + + public Task CallAsync(params DynValue[] args) + { + return OwnerScript.CallAsync(this, args); + } /// @@ -142,13 +166,13 @@ public string GetUpvalueName(int idx) } /// - /// Gets the value of an upvalue. To set the value, use GetUpvalue(idx).Assign(...); + /// Gets the value of an upvalue. To set the value, use GetUpvalue(idx) = ...; /// /// The index of the upvalue. /// The value of an upvalue - public DynValue GetUpvalue(int idx) + public ref DynValue GetUpvalue(int idx) { - return ClosureContext[idx]; + return ref ClosureContext[idx].Value(); } /// diff --git a/src/MoonSharp.Interpreter/DataTypes/DataType.cs b/src/MoonSharp.Interpreter/DataTypes/DataType.cs index 46694a6e..59f07bbc 100644 --- a/src/MoonSharp.Interpreter/DataTypes/DataType.cs +++ b/src/MoonSharp.Interpreter/DataTypes/DataType.cs @@ -64,6 +64,11 @@ public enum DataType /// A request to coroutine.yield /// YieldRequest, + + /// + /// A request to await a task + /// + AwaitRequest } /// diff --git a/src/MoonSharp.Interpreter/DataTypes/DynValue.cs b/src/MoonSharp.Interpreter/DataTypes/DynValue.cs index 9df80fe0..40eefa58 100644 --- a/src/MoonSharp.Interpreter/DataTypes/DynValue.cs +++ b/src/MoonSharp.Interpreter/DataTypes/DynValue.cs @@ -2,35 +2,51 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Text; +using System.Threading.Tasks; +using MoonSharp.Interpreter.Tree; namespace MoonSharp.Interpreter { /// /// A class representing a value in a Lua/MoonSharp script. /// - public sealed class DynValue + [StructLayout(LayoutKind.Explicit)] + public struct DynValue { - static int s_RefIDCounter = 0; - - private int m_RefID = ++s_RefIDCounter; - private int m_HashCode = -1; - - private bool m_ReadOnly; + private static readonly object m_NumberTag = new object(); + [FieldOffset(0)] private double m_Number; + [FieldOffset(0)] + private ulong m_U64; + [FieldOffset(8)] private object m_Object; - private DataType m_Type; - - /// - /// Gets a unique reference identifier. This is guaranteed to be unique only for dynvalues created in a single thread as it's not thread-safe. - /// - public int ReferenceID { get { return m_RefID; } } + private const ulong QNAN = 0x7ffc000000000000; + private const ulong BOOLEAN_MASK = 0x0FFFFFFFFF; + private const ulong BOOL_TRUE = QNAN | ((ulong)DataType.Boolean << 40) | BOOLEAN_MASK; + private const ulong BOOL_FALSE = QNAN | ((ulong) DataType.Boolean << 40); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static ulong TYPE(DataType type) + { + return QNAN | ((ulong) type) << 40; + } /// /// Gets the type of the value. /// - public DataType Type { get { return m_Type; } } + public DataType Type + { + get + { + if (m_Object == m_NumberTag) return DataType.Number; + return (DataType) ((m_U64 >> 40) & 0xFF); + } + } + /// /// Gets the function (valid only if the is ) /// @@ -55,7 +71,7 @@ public sealed class DynValue /// /// Gets the boolean value (valid only if the is ) /// - public bool Boolean { get { return Number != 0; } } + public bool Boolean { get { return (m_U64 & BOOLEAN_MASK) != 0; } } /// /// Gets the string value (valid only if the is ) /// @@ -76,21 +92,8 @@ public sealed class DynValue /// Gets the tail call data. /// public UserData UserData { get { return m_Object as UserData; } } - - /// - /// Returns true if this instance is write protected. - /// - public bool ReadOnly { get { return m_ReadOnly; } } - - - - /// - /// Creates a new writable value initialized to Nil. - /// - public static DynValue NewNil() - { - return new DynValue(); - } + + internal Task Task { get { return m_Object as Task; } } /// /// Creates a new writable value initialized to the specified boolean. @@ -99,8 +102,7 @@ public static DynValue NewBoolean(bool v) { return new DynValue() { - m_Number = v ? 1 : 0, - m_Type = DataType.Boolean, + m_U64 = v ? BOOL_TRUE : BOOL_FALSE }; } @@ -112,8 +114,7 @@ public static DynValue NewNumber(double num) return new DynValue() { m_Number = num, - m_Type = DataType.Number, - m_HashCode = -1, + m_Object = m_NumberTag, }; } @@ -125,7 +126,7 @@ public static DynValue NewString(string str) return new DynValue() { m_Object = str, - m_Type = DataType.String, + m_U64 = TYPE(DataType.String) }; } @@ -137,7 +138,7 @@ public static DynValue NewString(StringBuilder sb) return new DynValue() { m_Object = sb.ToString(), - m_Type = DataType.String, + m_U64 = TYPE(DataType.String) }; } @@ -149,7 +150,7 @@ public static DynValue NewString(string format, params object[] args) return new DynValue() { m_Object = string.Format(format, args), - m_Type = DataType.String, + m_U64 = TYPE(DataType.String) }; } @@ -164,7 +165,7 @@ public static DynValue NewCoroutine(Coroutine coroutine) return new DynValue() { m_Object = coroutine, - m_Type = DataType.Thread + m_U64 = TYPE(DataType.Thread) }; } @@ -176,7 +177,7 @@ public static DynValue NewClosure(Closure function) return new DynValue() { m_Object = function, - m_Type = DataType.Function, + m_U64 = TYPE(DataType.Function) }; } @@ -188,7 +189,7 @@ public static DynValue NewCallback(Func - /// Returns this value as readonly - eventually cloning it in the process if it isn't readonly to start with. - /// - public DynValue AsReadOnly() - { - if (ReadOnly) - return this; - else - { - return Clone(true); - } - } - - /// - /// Clones this instance. - /// - /// - public DynValue Clone() - { - return Clone(this.ReadOnly); - } - - /// - /// Clones this instance, overriding the "readonly" status. - /// - /// if set to true the new instance is set as readonly, or writeable otherwise. - /// - public DynValue Clone(bool readOnly) - { - DynValue v = new DynValue(); - v.m_Object = this.m_Object; - v.m_Number = this.m_Number; - v.m_HashCode = this.m_HashCode; - v.m_Type = this.m_Type; - v.m_ReadOnly = readOnly; - return v; - } - - /// - /// Clones this instance, returning a writable copy. - /// - /// Can't clone Symbol values - public DynValue CloneAsWritable() - { - return Clone(false); - } - /// /// A preinitialized, readonly instance, equaling Void @@ -441,10 +404,10 @@ public DynValue CloneAsWritable() static DynValue() { - Nil = new DynValue() { m_Type = DataType.Nil }.AsReadOnly(); - Void = new DynValue() { m_Type = DataType.Void }.AsReadOnly(); - True = DynValue.NewBoolean(true).AsReadOnly(); - False = DynValue.NewBoolean(false).AsReadOnly(); + Nil = new DynValue() { }; + Void = new DynValue() { m_U64 = TYPE(DataType.Void) }; + True = DynValue.NewBoolean(true); + False = DynValue.NewBoolean(false); } @@ -560,6 +523,7 @@ public override string ToString() } } + /// /// Returns a hash code for this instance. /// @@ -568,47 +532,20 @@ public override string ToString() /// public override int GetHashCode() { - if (m_HashCode != -1) - return m_HashCode; - int baseValue = ((int)(Type)) << 27; - switch (Type) { case DataType.Void: case DataType.Nil: - m_HashCode = 0; - break; + return 0; case DataType.Boolean: - m_HashCode = Boolean ? 1 : 2; - break; + return Boolean ? 1 : 2; case DataType.Number: - m_HashCode = baseValue ^ Number.GetHashCode(); - break; - case DataType.String: - m_HashCode = baseValue ^ String.GetHashCode(); - break; - case DataType.Function: - m_HashCode = baseValue ^ Function.GetHashCode(); - break; - case DataType.ClrFunction: - m_HashCode = baseValue ^ Callback.GetHashCode(); - break; - case DataType.Table: - m_HashCode = baseValue ^ Table.GetHashCode(); - break; - case DataType.Tuple: - case DataType.TailCallRequest: - m_HashCode = baseValue ^ Tuple.GetHashCode(); - break; - case DataType.UserData: - case DataType.Thread: + return baseValue ^ Number.GetHashCode(); default: - m_HashCode = 999; - break; + if (m_Object == null) return 0; + else return baseValue ^ m_Object.GetHashCode(); } - - return m_HashCode; } /// @@ -620,10 +557,8 @@ public override int GetHashCode() /// public override bool Equals(object obj) { - DynValue other = obj as DynValue; - - if (other == null) return false; - + if (!(obj is DynValue other)) return false; + if ((other.Type == DataType.Nil && this.Type == DataType.Void) || (other.Type == DataType.Void && this.Type == DataType.Nil)) return true; @@ -650,7 +585,12 @@ public override bool Equals(object obj) return Table == other.Table; case DataType.Tuple: case DataType.TailCallRequest: - return Tuple == other.Tuple; + if (Tuple.Length != other.Tuple.Length) + return false; + for(int i = 0; i < Tuple.Length; i++) + if (!Equals(Tuple[i], other.Tuple[i])) + return false; + return true; case DataType.Thread: return Coroutine == other.Coroutine; case DataType.UserData: @@ -673,7 +613,7 @@ public override bool Equals(object obj) return false; } default: - return object.ReferenceEquals(this, other); + return false; } } @@ -684,7 +624,7 @@ public override bool Equals(object obj) /// The string representation, or null if not number, not string. public string CastToString() { - DynValue rv = ToScalar(); + ref DynValue rv = ref ScalarReference(ref this); if (rv.Type == DataType.Number) { return rv.Number.ToString(); @@ -702,28 +642,242 @@ public string CastToString() /// The string representation, or null if not number, not string or non-convertible-string. public double? CastToNumber() { - DynValue rv = ToScalar(); + ref DynValue rv = ref ScalarReference(ref this); if (rv.Type == DataType.Number) { return rv.Number; } else if (rv.Type == DataType.String) { - double num; - if (double.TryParse(rv.String, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) - return num; + if (ToNumber(rv.String, out double n)) + { + return n; + } } return null; } + + public int? CastToInt() + { + ref DynValue rv = ref ScalarReference(ref this); + switch (rv.Type) + { + case DataType.Number: + return (int)rv.Number; + case DataType.String when ToNumber(rv.String, out int n): + return n; + default: + return null; + } + } + + internal double AssertNumber(int stage) + { + if (!TryCastToNumber(out var num)) + throw ScriptRuntimeException.ConvertToNumberFailed(stage); + return num; + } + + public bool TryCastToNumber(out double d) + { + ref DynValue rv = ref ScalarReference(ref this); + if (rv.Type == DataType.Number) + { + d = rv.Number; + return true; + } + else if (rv.Type == DataType.String) + { + if (ToNumber(rv.String, out d)) + { + return true; + } + } + d = 0.0; + return false; + } + + public static bool ToNumber(string str, out int num) + { + //Validate characters + num = 0; + bool hex = false; + for (int i = 0; i < str.Length; i++) + { + if (char.IsWhiteSpace(str[i]) || + char.IsDigit(str[i]) || + (str[i] >= 'A' && str[i] <= 'F') || + (str[i] >= 'a' && str[i] <= 'f') || + str[i] == '-' || + str[i] == 'p' || + str[i] == 'P' || + str[i] == '+' || + str[i] == '.') + continue; + + if (str[i] == 'x' || str[i] == 'X') + { + hex = true; + continue; + } + + return false; + } + + //hex float + if (hex) + { + if (ParseHexFloat(str, out num)) + return true; + } + else + { + if (int.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + return true; + } + return false; + } + + public static bool ToNumber(string str, out double num) + { + //Validate characters + num = 0.0; + bool hex = false; + for (int i = 0; i < str.Length; i++) + { + if (char.IsWhiteSpace(str[i]) || + char.IsDigit(str[i]) || + (str[i] >= 'A' && str[i] <= 'F') || + (str[i] >= 'a' && str[i] <= 'f') || + str[i] == '-' || + str[i] == 'p' || + str[i] == 'P' || + str[i] == '+' || + str[i] == '.') + continue; + + if (str[i] == 'x' || str[i] == 'X') + { + hex = true; + continue; + } + + return false; + } + + //hex float + if (hex) + { + if (ParseHexFloat(str, out num)) + return true; + } + else + { + if (double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) + return true; + } + return false; + } + + static bool ParseHexFloat(string s, out double result) + { + bool negate = false; + result = 0.0; + s = s.Trim(); + if (s[0] == '+') + s = s.Substring(1); + if (s[0] == '-') { + negate = true; + s = s.Substring(1); + } + if ((s.Length < 3) || s[0] != '0' || char.ToUpperInvariant(s[1]) != 'X') + return false; + + s = s.Substring(2); + double value = 0.0; + int dummy, exp = 0; + + s = LexerUtils.ReadHexProgressive(s, ref value, out dummy); + + if (s.Length > 0 && s[0] == '.') + { + s = s.Substring(1); + s = LexerUtils.ReadHexProgressive(s, ref value, out exp); + } + + exp *= -4; + + if (s.Length > 0 && char.ToUpper(s[0]) == 'P') + { + if (s.Length == 1) + return false; + s = s.Substring(s[1] == '+' ? 2 : 1); + int exp1 = int.Parse(s, CultureInfo.InvariantCulture); + if (exp1 < 0) return false; //can't add negative exponent + exp += exp1; + s = ""; + } + + if (s.Length > 0) return false; + + result = value * Math.Pow(2, exp); + if (negate) result = -result; + return true; + } + + static bool ParseHexFloat(string s, out int result) + { + bool negate = false; + result = 0; + s = s.Trim(); + if (s[0] == '+') + s = s.Substring(1); + if (s[0] == '-') { + negate = true; + s = s.Substring(1); + } + if ((s.Length < 3) || s[0] != '0' || char.ToUpperInvariant(s[1]) != 'X') + return false; + s = s.Substring(2); + double value = 0.0; + int dummy, exp = 0; + s = LexerUtils.ReadHexProgressive(s, ref value, out dummy); + + if (s.Length > 0 && s[0] == '.') + { + s = s.Substring(1); + s = LexerUtils.ReadHexProgressive(s, ref value, out exp); + } + + exp *= -4; + + if (s.Length > 0 && char.ToUpper(s[0]) == 'P') + { + if (s.Length == 1) + return false; + s = s.Substring(s[1] == '+' ? 2 : 1); + int exp1 = int.Parse(s, CultureInfo.InvariantCulture); + if (exp1 < 0) return false; //can't add negative exponent + exp += exp1; + s = ""; + } + + if (s.Length > 0) return false; + + result = (int)(value * Math.Pow(2, exp)); + if (negate) result = -result; + return true; + } + /// /// Casts this DynValue to a bool /// /// False if value is false or nil, true otherwise. public bool CastToBool() { - DynValue rv = ToScalar(); + ref DynValue rv = ref ScalarReference(ref this); if (rv.Type == DataType.Boolean) return rv.Boolean; else return (rv.Type != DataType.Nil && rv.Type != DataType.Void); @@ -754,20 +908,14 @@ public DynValue ToScalar() return Tuple[0].ToScalar(); } - /// - /// Performs an assignment, overwriting the value with the specified one. - /// - /// The value. - /// If the value is readonly. - public void Assign(DynValue value) + static internal ref DynValue ScalarReference(ref DynValue d) { - if (this.ReadOnly) - throw new ScriptRuntimeException("Assigning on r-value"); - - this.m_Number = value.m_Number; - this.m_Object = value.m_Object; - this.m_Type = value.Type; - this.m_HashCode = -1; + if (d.Type != DataType.Tuple) + return ref d; + if (d.Tuple.Length == 0) { + return ref d; + } + return ref ScalarReference(ref d.Tuple[0]); } @@ -827,19 +975,7 @@ public bool IsNilOrNan() return (this.Type == DataType.Nil) || (this.Type == DataType.Void) || (this.Type == DataType.Number && double.IsNaN(this.Number)); } - /// - /// Changes the numeric value of a number DynValue. - /// - internal void AssignNumber(double num) - { - if (this.ReadOnly) - throw new InternalErrorException(null, "Writing on r-value"); - - if (this.Type != DataType.Number) - throw new InternalErrorException("Can't assign number to type {0}", this.Type); - - this.m_Number = num; - } + /// /// Creates a new DynValue from a CLR object diff --git a/src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs b/src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs index 6bb38dd1..9f8c183c 100644 --- a/src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs +++ b/src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs @@ -26,7 +26,7 @@ public static void CheckScriptOwnership(this IScriptPrivateResource containingRe public static void CheckScriptOwnership(this IScriptPrivateResource containingResource, DynValue value) { - if (value != null) + if (!value.IsNil()) { var otherResource = value.GetAsPrivateResource(); diff --git a/src/MoonSharp.Interpreter/DataTypes/SymbolRef.cs b/src/MoonSharp.Interpreter/DataTypes/SymbolRef.cs index 8ff6648e..5818b1bd 100644 --- a/src/MoonSharp.Interpreter/DataTypes/SymbolRef.cs +++ b/src/MoonSharp.Interpreter/DataTypes/SymbolRef.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using MoonSharp.Interpreter.IO; namespace MoonSharp.Interpreter { @@ -94,39 +95,39 @@ public override string ToString() /// /// Writes this instance to a binary stream /// - internal void WriteBinary(BinaryWriter bw) + internal void WriteBinary(BinDumpWriter bw) { - bw.Write((byte)this.i_Type); - bw.Write(i_Index); - bw.Write(i_Name); + bw.WriteByte((byte)this.i_Type); + bw.WriteVarInt32(i_Index); + bw.WriteString(i_Name); } /// /// Reads a symbolref from a binary stream /// - internal static SymbolRef ReadBinary(BinaryReader br) + internal static SymbolRef ReadBinary(BinDumpReader br) { SymbolRef that = new SymbolRef(); that.i_Type = (SymbolRefType)br.ReadByte(); - that.i_Index = br.ReadInt32(); + that.i_Index = br.ReadVarInt32(); that.i_Name = br.ReadString(); return that; } - internal void WriteBinaryEnv(BinaryWriter bw, Dictionary symbolMap) + internal void WriteBinaryEnv(BinDumpWriter bw, Dictionary symbolMap) { if (this.i_Env != null) - bw.Write(symbolMap[i_Env]); + bw.WriteVarUInt32((uint)(symbolMap[i_Env] + 1)); else - bw.Write(-1); + bw.WriteVarUInt32(0); } - internal void ReadBinaryEnv(BinaryReader br, SymbolRef[] symbolRefs) + internal void ReadBinaryEnv(BinDumpReader br, SymbolRef[] symbolRefs) { - int idx = br.ReadInt32(); + uint idx = br.ReadVarUInt32(); - if (idx >= 0) - i_Env = symbolRefs[idx]; + if (idx >= 1) + i_Env = symbolRefs[idx - 1]; } } } diff --git a/src/MoonSharp.Interpreter/DataTypes/Table.cs b/src/MoonSharp.Interpreter/DataTypes/Table.cs index c4a4bec4..9a22d093 100644 --- a/src/MoonSharp.Interpreter/DataTypes/Table.cs +++ b/src/MoonSharp.Interpreter/DataTypes/Table.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using MoonSharp.Interpreter.DataStructs; namespace MoonSharp.Interpreter @@ -12,12 +13,12 @@ public class Table : RefIdObject, IScriptPrivateResource readonly LinkedList m_Values; readonly LinkedListIndex m_ValueMap; readonly LinkedListIndex m_StringMap; - readonly LinkedListIndex m_ArrayMap; - readonly Script m_Owner; + readonly LinkedListArrayIndex m_ArrayMap; int m_InitArray = 0; int m_CachedLength = -1; bool m_ContainsNilEntries = false; + int m_IndexFrom => OwnerScript?.Options.IndexTablesFrom ?? 1; /// /// Initializes a new instance of the class. @@ -27,9 +28,9 @@ public Table(Script owner) { m_Values = new LinkedList(); m_StringMap = new LinkedListIndex(m_Values); - m_ArrayMap = new LinkedListIndex(m_Values); + m_ArrayMap = new LinkedListArrayIndex(m_Values); m_ValueMap = new LinkedListIndex(m_Values); - m_Owner = owner; + OwnerScript = owner; } /// @@ -42,17 +43,14 @@ public Table(Script owner, params DynValue[] arrayValues) { for (int i = 0; i < arrayValues.Length; i++) { - this.Set(DynValue.NewNumber(i + 1), arrayValues[i]); + Set(DynValue.NewNumber(i + m_IndexFrom), arrayValues[i]); } } /// /// Gets the script owning this resource. /// - public Script OwnerScript - { - get { return m_Owner; } - } + public Script OwnerScript { get; } /// /// Removes all items from the Table. @@ -69,16 +67,17 @@ public void Clear() /// /// Gets the integral key from a double. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private int GetIntegralKey(double d) { - int v = ((int)d); + int v = (int)d; - if (d >= 1.0 && d == v) + if (d >= m_IndexFrom && d == v) return v; return -1; } - + /// /// Gets or sets the /// with the specified key(s). @@ -130,11 +129,11 @@ private Table ResolveMultipleKeys(object[] keys, out object key) Table t = this; key = (keys.Length > 0) ? keys[0] : null; - for (int i = 1; i < keys.Length; ++i) + for (int i = m_IndexFrom; i < keys.Length; ++i) { DynValue vt = t.RawGet(key); - if (vt == null) + if (vt.IsNil()) throw new ScriptRuntimeException("Key '{0}' did not point to anything"); if (vt.Type != DataType.Table) @@ -146,6 +145,18 @@ private Table ResolveMultipleKeys(object[] keys, out object key) return t; } + + /// + /// Append the values to the table using the next available integer indexes. + /// + /// The value. + public void Append(IEnumerable values) + { + foreach (DynValue value in values) + { + Append(value); + } + } /// /// Append the value to the table using the next available integer index. @@ -154,7 +165,28 @@ private Table ResolveMultipleKeys(object[] keys, out object key) public void Append(DynValue value) { this.CheckScriptOwnership(value); - PerformTableSet(m_ArrayMap, Length + 1, DynValue.NewNumber(Length + 1), value, true, Length + 1); + PerformTableSet(m_ArrayMap, Length + m_IndexFrom, DynValue.NewNumber(Length + m_IndexFrom), value, true, Length + m_IndexFrom); + } + + /// + /// Append the value to the table using the next available integer index. + /// + /// The value. + public void Append(object value) + { + Append(DynValue.FromObject(OwnerScript, value)); + } + + /// + /// Append the values to the table using the next available integer indexes. + /// + /// The value. + public void Append(IEnumerable values) + { + foreach (object value in values) + { + Append(DynValue.FromObject(OwnerScript, value)); + } } #region Set @@ -164,7 +196,7 @@ private void PerformTableSet(LinkedListIndex listIndex, T key, TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value)); // If this is an insert, we can invalidate all iterators and collect dead keys - if (m_ContainsNilEntries && value.IsNotNil() && (prev.Value == null || prev.Value.IsNil())) + if (m_ContainsNilEntries && value.IsNotNil() && prev.Value.IsNil()) { CollectDeadKeys(); } @@ -179,13 +211,13 @@ private void PerformTableSet(LinkedListIndex listIndex, T key, else if (isNumber) { // If this is an array insert, we might have to invalidate the array length - if (prev.Value == null || prev.Value.IsNilOrNan()) + if (prev.Value.IsNilOrNan()) { // If this is an array append, let's check the next element before blindly invalidating if (appendKey >= 0) { LinkedListNode next = m_ArrayMap.Find(appendKey + 1); - if (next == null || next.Value.Value == null || next.Value.Value.IsNil()) + if (next == null || next.Value.Value.IsNil()) { m_CachedLength += 1; } @@ -226,6 +258,16 @@ public void Set(int key, DynValue value) this.CheckScriptOwnership(value); PerformTableSet(m_ArrayMap, key, DynValue.NewNumber(key), value, true, -1); } + + /// + /// Sets the value associated to the specified key. + /// + /// The key. + /// The value. + public void Set(int key, object value) + { + Set(key, DynValue.FromObject(OwnerScript, value)); + } /// /// Sets the value associated to the specified key. @@ -252,7 +294,7 @@ public void Set(DynValue key, DynValue value) { int idx = GetIntegralKey(key.Number); - if (idx > 0) + if (idx >= m_IndexFrom) { Set(idx, value); return; @@ -309,7 +351,7 @@ public void Set(object[] keys, DynValue value) public DynValue Get(string key) { //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; + return RawGet(key); } /// @@ -319,7 +361,7 @@ public DynValue Get(string key) public DynValue Get(int key) { //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; + return RawGet(key); } /// @@ -329,7 +371,7 @@ public DynValue Get(int key) public DynValue Get(DynValue key) { //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; + return RawGet(key); } /// @@ -340,7 +382,7 @@ public DynValue Get(DynValue key) public DynValue Get(object key) { //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; + return RawGet(key); } /// @@ -353,7 +395,7 @@ public DynValue Get(object key) public DynValue Get(params object[] keys) { //Contract.Ensures(Contract.Result() != null); - return RawGet(keys) ?? DynValue.Nil; + return RawGet(keys); } #endregion @@ -362,7 +404,7 @@ public DynValue Get(params object[] keys) private static DynValue RawGetValue(LinkedListNode linkedListNode) { - return (linkedListNode != null) ? linkedListNode.Value.Value : null; + return (linkedListNode != null) ? linkedListNode.Value.Value : DynValue.Nil; } /// @@ -398,7 +440,7 @@ public DynValue RawGet(DynValue key) if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); - if (idx > 0) + if (idx >= m_IndexFrom) return RawGet(idx); } @@ -413,7 +455,7 @@ public DynValue RawGet(DynValue key) public DynValue RawGet(object key) { if (key == null) - return null; + return DynValue.Nil; if (key is string) return RawGet((string)key); @@ -434,7 +476,7 @@ public DynValue RawGet(object key) public DynValue RawGet(params object[] keys) { if (keys == null || keys.Length <= 0) - return null; + return DynValue.Nil; object key; return ResolveMultipleKeys(keys, out key).RawGet(key); @@ -489,7 +531,7 @@ public bool Remove(DynValue key) if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); - if (idx > 0) + if (idx >= m_IndexFrom) return Remove(idx); } @@ -578,7 +620,7 @@ public void CollectDeadKeys() { int idx = GetIntegralKey(v.Number); - if (idx > 0) + if (idx >= m_IndexFrom) { return GetNextOf(m_ArrayMap.Find(idx)); } @@ -616,8 +658,8 @@ public int Length { m_CachedLength = 0; - for (int i = 1; m_ArrayMap.ContainsKey(i) && !m_ArrayMap.Find(i).Value.Value.IsNil(); i++) - m_CachedLength = i; + for (int i = m_IndexFrom; m_ArrayMap.ContainsKey(i) && !m_ArrayMap.Find(i).Value.Value.IsNil(); i++) + m_CachedLength++; } return m_CachedLength; @@ -633,7 +675,14 @@ internal void InitNextArrayKeys(DynValue val, bool lastpos) } else { - Set(++m_InitArray, val.ToScalar()); + if (m_IndexFrom > 0) + { + Set(++m_InitArray, val.ToScalar()); + } + else + { + Set(m_InitArray++, val.ToScalar()); + } } } @@ -684,5 +733,17 @@ public IEnumerable Values return m_Values.Select(n => n.Value); } } + + /// + /// Enumerates value, key + /// + + public IEnumerable ReversePair + { + get + { + return m_Values.Select(n => DynValue.NewTuple(n.Value, n.Key)); + } + } } } diff --git a/src/MoonSharp.Interpreter/DataTypes/UserData.cs b/src/MoonSharp.Interpreter/DataTypes/UserData.cs index c56f2285..e37ed5f0 100755 --- a/src/MoonSharp.Interpreter/DataTypes/UserData.cs +++ b/src/MoonSharp.Interpreter/DataTypes/UserData.cs @@ -48,7 +48,8 @@ static UserData() RegisterType(InteropAccessMode.HideMembers); RegisterType(InteropAccessMode.NoReflectionAllowed); RegisterType(InteropAccessMode.Reflection); - + RegisterType(); + DefaultAccessMode = InteropAccessMode.LazyOptimized; } @@ -144,11 +145,7 @@ public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTy { if (asm == null) { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif + asm = Assembly.GetCallingAssembly(); } TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); @@ -230,7 +227,7 @@ public static DynValue Create(object o) if (o is Type) return CreateStatic((Type)o); - return null; + return DynValue.Nil; } return Create(o, descr); @@ -243,7 +240,7 @@ public static DynValue Create(object o) /// public static DynValue CreateStatic(IUserDataDescriptor descr) { - if (descr == null) return null; + if (descr == null) return DynValue.Nil; return DynValue.NewUserData(new UserData() { diff --git a/src/MoonSharp.Interpreter/Debugging/SourceRef.cs b/src/MoonSharp.Interpreter/Debugging/SourceRef.cs index 10c2fecd..9c33e52e 100755 --- a/src/MoonSharp.Interpreter/Debugging/SourceRef.cs +++ b/src/MoonSharp.Interpreter/Debugging/SourceRef.cs @@ -1,4 +1,5 @@ using System; +using MoonSharp.Interpreter.IO; namespace MoonSharp.Interpreter.Debugging { @@ -61,6 +62,55 @@ public SourceRef(SourceRef src, bool isStepStop) IsStepStop = isStepStop; } + public override bool Equals(object obj) + { + if(obj is SourceRef r) + { + return Equals(r); + } + return false; + } + + protected bool Equals(SourceRef other) + { + return Breakpoint == other.Breakpoint && + IsClrLocation == other.IsClrLocation && + SourceIdx == other.SourceIdx && + FromChar == other.FromChar && + ToChar == other.ToChar && + FromLine == other.FromLine && + ToLine == other.ToLine && + IsStepStop == other.IsStepStop && + CannotBreakpoint == other.CannotBreakpoint; + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Breakpoint.GetHashCode(); + hashCode = (hashCode * 397) ^ IsClrLocation.GetHashCode(); + hashCode = (hashCode * 397) ^ SourceIdx; + hashCode = (hashCode * 397) ^ FromChar; + hashCode = (hashCode * 397) ^ ToChar; + hashCode = (hashCode * 397) ^ FromLine; + hashCode = (hashCode * 397) ^ ToLine; + hashCode = (hashCode * 397) ^ IsStepStop.GetHashCode(); + hashCode = (hashCode * 397) ^ CannotBreakpoint.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(SourceRef left, SourceRef right) + { + return Equals(left, right); + } + + public static bool operator !=(SourceRef left, SourceRef right) + { + return !Equals(left, right); + } + public SourceRef(int sourceIdx, int from, int to, int fromline, int toline, bool isStepStop) { @@ -202,5 +252,24 @@ public string FormatLocation(Script script, bool forceClassicFormat = false) return string.Format("{0}:({1},{2}-{3},{4})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar); } } + + internal void WriteBinary(BinDumpWriter writer) + { + writer.WriteVarUInt32((uint)FromChar); + writer.WriteVarInt32(ToChar - FromChar); + writer.WriteVarUInt32((uint)FromLine); + writer.WriteVarInt32(ToLine - FromLine); + writer.WriteBoolean(IsStepStop); + } + + internal static SourceRef ReadBinary(BinDumpReader reader, int sourceID) + { + var fromChar = (int) reader.ReadVarUInt32(); + int toChar = fromChar + reader.ReadVarInt32(); + var fromLine = (int) reader.ReadVarUInt32(); + int toLine = fromLine + reader.ReadVarInt32(); + + return new SourceRef(sourceID, fromChar, toChar, fromLine, toLine, reader.ReadBoolean()); + } } } diff --git a/src/MoonSharp.Interpreter/Debugging/WatchItem.cs b/src/MoonSharp.Interpreter/Debugging/WatchItem.cs index 740f2bb7..d0210af9 100644 --- a/src/MoonSharp.Interpreter/Debugging/WatchItem.cs +++ b/src/MoonSharp.Interpreter/Debugging/WatchItem.cs @@ -52,7 +52,7 @@ public override string ToString() { return string.Format("{0}:{1}:{2}:{3}:{4}:{5}", Address, BasePtr, RetAddress, Name ?? "(null)", - Value != null ? Value.ToString() : "(null)", + Value.ToString(), LValue != null ? LValue.ToString() : "(null)"); } diff --git a/src/MoonSharp.Interpreter/Errors/DynamicExpressionException.cs b/src/MoonSharp.Interpreter/Errors/DynamicExpressionException.cs index 97a1e960..3bb68a72 100755 --- a/src/MoonSharp.Interpreter/Errors/DynamicExpressionException.cs +++ b/src/MoonSharp.Interpreter/Errors/DynamicExpressionException.cs @@ -6,9 +6,7 @@ namespace MoonSharp.Interpreter /// /// Exception thrown when a dynamic expression is invalid /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) [Serializable] -#endif public class DynamicExpressionException : ScriptRuntimeException { /// diff --git a/src/MoonSharp.Interpreter/Errors/InternalErrorException.cs b/src/MoonSharp.Interpreter/Errors/InternalErrorException.cs index 651d2eea..29844fef 100755 --- a/src/MoonSharp.Interpreter/Errors/InternalErrorException.cs +++ b/src/MoonSharp.Interpreter/Errors/InternalErrorException.cs @@ -5,9 +5,7 @@ namespace MoonSharp.Interpreter /// /// Exception thrown when an inconsistent state is reached in the interpreter /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) [Serializable] -#endif public class InternalErrorException : InterpreterException { internal InternalErrorException(string message) diff --git a/src/MoonSharp.Interpreter/Errors/InterpreterException.cs b/src/MoonSharp.Interpreter/Errors/InterpreterException.cs index a63fe83c..8ba05340 100755 --- a/src/MoonSharp.Interpreter/Errors/InterpreterException.cs +++ b/src/MoonSharp.Interpreter/Errors/InterpreterException.cs @@ -7,9 +7,7 @@ namespace MoonSharp.Interpreter /// /// Base type of all exceptions thrown in MoonSharp /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) [Serializable] -#endif public class InterpreterException : Exception { /// diff --git a/src/MoonSharp.Interpreter/Errors/ScriptRuntimeException.cs b/src/MoonSharp.Interpreter/Errors/ScriptRuntimeException.cs index e73adfd8..ac240f75 100755 --- a/src/MoonSharp.Interpreter/Errors/ScriptRuntimeException.cs +++ b/src/MoonSharp.Interpreter/Errors/ScriptRuntimeException.cs @@ -8,9 +8,7 @@ namespace MoonSharp.Interpreter /// Exception for all runtime errors. In addition to constructors, it offers a lot of static methods /// generating more "standard" Lua errors. /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) [Serializable] -#endif public class ScriptRuntimeException : InterpreterException { /// @@ -62,13 +60,13 @@ public ScriptRuntimeException(string format, params object[] args) /// The right operand (or null). /// The exception to be raised. /// If both are numbers - public static ScriptRuntimeException ArithmeticOnNonNumber(DynValue l, DynValue r = null) + public static ScriptRuntimeException ArithmeticOnNonNumber(DynValue l, DynValue? r = null) { if (l.Type != DataType.Number && l.Type != DataType.String) return new ScriptRuntimeException("attempt to perform arithmetic on a {0} value", l.Type.ToLuaTypeString()); - else if (r != null && r.Type != DataType.Number && r.Type != DataType.String) - return new ScriptRuntimeException("attempt to perform arithmetic on a {0} value", r.Type.ToLuaTypeString()); - else if (l.Type == DataType.String || (r != null && r.Type == DataType.String)) + else if (r != null && r.Value.Type != DataType.Number && r.Value.Type != DataType.String) + return new ScriptRuntimeException("attempt to perform arithmetic on a {0} value", r.Value.Type.ToLuaTypeString()); + else if (l.Type == DataType.String || (r != null && r.Value.Type == DataType.String)) return new ScriptRuntimeException("attempt to perform arithmetic on a string value"); else throw new InternalErrorException("ArithmeticOnNonNumber - both are numbers"); @@ -86,7 +84,7 @@ public static ScriptRuntimeException ConcatOnNonString(DynValue l, DynValue r) { if (l.Type != DataType.Number && l.Type != DataType.String) return new ScriptRuntimeException("attempt to concatenate a {0} value", l.Type.ToLuaTypeString()); - else if (r != null && r.Type != DataType.Number && r.Type != DataType.String) + else if (r.IsNotNil() && r.Type != DataType.Number && r.Type != DataType.String) return new ScriptRuntimeException("attempt to concatenate a {0} value", r.Type.ToLuaTypeString()); else throw new InternalErrorException("ConcatOnNonString - both are numbers/strings"); diff --git a/src/MoonSharp.Interpreter/Errors/SyntaxErrorException.cs b/src/MoonSharp.Interpreter/Errors/SyntaxErrorException.cs index 8bb572f6..7c29d2a7 100755 --- a/src/MoonSharp.Interpreter/Errors/SyntaxErrorException.cs +++ b/src/MoonSharp.Interpreter/Errors/SyntaxErrorException.cs @@ -7,9 +7,7 @@ namespace MoonSharp.Interpreter /// /// Exception for all parsing/lexing errors. /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) [Serializable] -#endif public class SyntaxErrorException : InterpreterException { internal Token Token { get; private set; } diff --git a/src/MoonSharp.Interpreter/Execution/DynamicExpression.cs b/src/MoonSharp.Interpreter/Execution/DynamicExpression.cs index e53b92c6..d30bdb0b 100644 --- a/src/MoonSharp.Interpreter/Execution/DynamicExpression.cs +++ b/src/MoonSharp.Interpreter/Execution/DynamicExpression.cs @@ -40,7 +40,7 @@ public DynValue Evaluate(ScriptExecutionContext context = null) this.CheckScriptOwnership(context.GetScript()); - if (m_Constant != null) + if (!m_Constant.IsNil()) return m_Constant; return m_Exp.Eval(context); @@ -79,7 +79,7 @@ public Script OwnerScript /// public bool IsConstant() { - return m_Constant != null; + return m_Constant.IsNotNil(); } /// diff --git a/src/MoonSharp.Interpreter/Execution/InstructionFieldUsage.cs b/src/MoonSharp.Interpreter/Execution/InstructionFieldUsage.cs index e64f1335..2154bc38 100644 --- a/src/MoonSharp.Interpreter/Execution/InstructionFieldUsage.cs +++ b/src/MoonSharp.Interpreter/Execution/InstructionFieldUsage.cs @@ -9,11 +9,12 @@ internal enum InstructionFieldUsage None = 0, Symbol = 0x1, SymbolList = 0x2, - Name = 0x4, - Value = 0x8, + String = 0x4, + Number = 0x8, NumVal = 0x10, NumVal2 = 0x20, - NumValAsCodeAddress = 0x8010 + NumValAsCodeAddress = 0x8010, + Annotations = 0x10000 } internal static class InstructionFieldUsage_Extensions @@ -32,6 +33,7 @@ internal static InstructionFieldUsage GetFieldUsage(this OpCode op) case OpCode.Less: case OpCode.Eq: case OpCode.Add: + case OpCode.AddStr: case OpCode.Sub: case OpCode.Mul: case OpCode.Div: @@ -42,7 +44,12 @@ internal static InstructionFieldUsage GetFieldUsage(this OpCode op) case OpCode.Power: case OpCode.CNot: case OpCode.ToBool: + case OpCode.PushNil: + case OpCode.PushTrue: + case OpCode.PushFalse: return InstructionFieldUsage.None; + case OpCode.Annot: + return InstructionFieldUsage.Annotations; case OpCode.Pop: case OpCode.Copy: case OpCode.TblInitI: @@ -51,32 +58,37 @@ internal static InstructionFieldUsage GetFieldUsage(this OpCode op) case OpCode.ToNum: case OpCode.Ret: case OpCode.MkTuple: + case OpCode.CloseUp: + case OpCode.StrFormat: return InstructionFieldUsage.NumVal; case OpCode.Jump: case OpCode.Jf: + case OpCode.Jt: case OpCode.JNil: + case OpCode.JNilChk: case OpCode.JFor: case OpCode.JtOrPop: case OpCode.JfOrPop: return InstructionFieldUsage.NumValAsCodeAddress; case OpCode.Swap: case OpCode.Clean: + case OpCode.CopyValue: + case OpCode.JLclInit: return InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; case OpCode.Local: case OpCode.Upvalue: - return InstructionFieldUsage.Symbol; + return InstructionFieldUsage.NumVal; case OpCode.IndexSet: case OpCode.IndexSetN: case OpCode.IndexSetL: - return InstructionFieldUsage.Symbol | InstructionFieldUsage.Value | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; + return InstructionFieldUsage.String | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; case OpCode.StoreLcl: case OpCode.StoreUpv: return InstructionFieldUsage.Symbol | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; case OpCode.Index: case OpCode.IndexL: case OpCode.IndexN: - case OpCode.Literal: - return InstructionFieldUsage.Value; + return InstructionFieldUsage.String; case OpCode.Args: return InstructionFieldUsage.SymbolList; case OpCode.BeginFn: @@ -86,14 +98,17 @@ internal static InstructionFieldUsage GetFieldUsage(this OpCode op) case OpCode.Nop: case OpCode.Debug: case OpCode.Invalid: - return InstructionFieldUsage.Name; + case OpCode.PushString: + return InstructionFieldUsage.String; + case OpCode.PushNumber: + return InstructionFieldUsage.Number; case OpCode.Call: case OpCode.ThisCall: - return InstructionFieldUsage.NumVal | InstructionFieldUsage.Name; + return InstructionFieldUsage.NumVal | InstructionFieldUsage.String; case OpCode.Meta: - return InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2 | InstructionFieldUsage.Value | InstructionFieldUsage.Name; + return InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2 | InstructionFieldUsage.String; default: - throw new NotImplementedException(string.Format("InstructionFieldUsage for instruction {0}", (int)op)); + throw new NotImplementedException(string.Format("InstructionFieldUsage for instruction {0}", op)); } } } diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScope.cs b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScope.cs index 63a83282..560e95dd 100644 --- a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScope.cs +++ b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScope.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using MoonSharp.Interpreter.Execution.Scopes; +using MoonSharp.Interpreter.Tree; using MoonSharp.Interpreter.Tree.Statements; namespace MoonSharp.Interpreter.Execution @@ -10,11 +11,15 @@ internal class BuildTimeScope List m_Frames = new List(); List m_ClosureBuilders = new List(); - - public void PushFunction(IClosureBuilder closureBuilder, bool hasVarArgs) + public void PushFunction(IClosureBuilder closureBuilder) { m_ClosureBuilders.Add(closureBuilder); - m_Frames.Add(new BuildTimeScopeFrame(hasVarArgs)); + m_Frames.Add(new BuildTimeScopeFrame()); + } + + public void SetHasVarArgs() + { + m_Frames.Last().HasVarArgs = true; } public void PushBlock() @@ -98,6 +103,14 @@ public SymbolRef TryDefineLocal(string name) return m_Frames.Last().TryDefineLocal(name); } + public void BlockResolution(IEnumerable locals) + { + m_Frames.Last().BlockResolution(locals); + } + + public void UnblockResolution() => m_Frames.Last().UnblockResolution(); + + public bool CurrentFunctionHasVarArgs() { return m_Frames.Last().HasVarArgs; diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeBlock.cs b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeBlock.cs index 78987b41..ac5b91b6 100644 --- a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeBlock.cs +++ b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeBlock.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using MoonSharp.Interpreter.Tree.Statements; namespace MoonSharp.Interpreter.Execution.Scopes @@ -8,13 +9,9 @@ internal class BuildTimeScopeBlock { internal BuildTimeScopeBlock Parent { get; private set; } internal List ChildNodes { get; private set; } - internal RuntimeScopeBlock ScopeBlock { get; private set; } - Dictionary m_DefinedNames = new Dictionary(); - - - + internal void Rename(string name) { SymbolRef sref = m_DefinedNames[name]; @@ -37,8 +34,25 @@ internal BuildTimeScopeBlock AddChild() return block; } + private HashSet blockedNames = new HashSet(); + internal void BlockResolution(IEnumerable locals) + { + foreach(var l in locals) { + if (!m_DefinedNames.ContainsValue(l)) + throw new InternalErrorException("Tried to block resolution of local outside of block"); + blockedNames.Add(l.Name); + } + } + + internal void UnblockResolution() + { + blockedNames.Clear(); + } + + internal SymbolRef Find(string name) { + if (blockedNames.Contains(name)) return null; return m_DefinedNames.GetOrDefault(name); } diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeFrame.cs b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeFrame.cs index 7d22709f..94c96561 100644 --- a/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeFrame.cs +++ b/src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScopeFrame.cs @@ -1,4 +1,6 @@ -using MoonSharp.Interpreter.Tree.Statements; +using System.Collections.Generic; +using System.Linq; +using MoonSharp.Interpreter.Tree.Statements; namespace MoonSharp.Interpreter.Execution.Scopes { @@ -8,11 +10,10 @@ internal class BuildTimeScopeFrame BuildTimeScopeBlock m_ScopeTreeHead; RuntimeScopeFrame m_ScopeFrame = new RuntimeScopeFrame(); - public bool HasVarArgs { get; private set;} + public bool HasVarArgs { get; set;} - internal BuildTimeScopeFrame(bool hasVarArgs) + internal BuildTimeScopeFrame() { - HasVarArgs = hasVarArgs; m_ScopeTreeHead = m_ScopeTreeRoot = new BuildTimeScopeBlock(null); } @@ -63,6 +64,13 @@ internal SymbolRef DefineLocal(string name) return m_ScopeTreeHead.Define(name); } + internal void BlockResolution(IEnumerable locals) + { + m_ScopeTreeHead.BlockResolution(locals); + } + + internal void UnblockResolution() => m_ScopeTreeHead.UnblockResolution(); + internal SymbolRef TryDefineLocal(string name) { if (m_ScopeTreeHead.Find(name) != null) diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/ClosureContext.cs b/src/MoonSharp.Interpreter/Execution/Scopes/ClosureContext.cs index 095fcd5b..2bcc542e 100644 --- a/src/MoonSharp.Interpreter/Execution/Scopes/ClosureContext.cs +++ b/src/MoonSharp.Interpreter/Execution/Scopes/ClosureContext.cs @@ -6,14 +6,14 @@ namespace MoonSharp.Interpreter.Execution /// /// The scope of a closure (container of upvalues) /// - internal class ClosureContext : List + internal class ClosureContext : List { /// /// Gets the symbols. /// public string[] Symbols { get; private set; } - internal ClosureContext(SymbolRef[] symbols, IEnumerable values) + internal ClosureContext(SymbolRef[] symbols, IEnumerable values) { Symbols = symbols.Select(s => s.i_Name).ToArray(); this.AddRange(values); diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/LoopTracker.cs b/src/MoonSharp.Interpreter/Execution/Scopes/LoopTracker.cs index d9dd8292..40297ea9 100644 --- a/src/MoonSharp.Interpreter/Execution/Scopes/LoopTracker.cs +++ b/src/MoonSharp.Interpreter/Execution/Scopes/LoopTracker.cs @@ -6,12 +6,13 @@ namespace MoonSharp.Interpreter.Execution interface ILoop { void CompileBreak(ByteCode bc); + void CompileContinue(ByteCode bc); bool IsBoundary(); } internal class LoopTracker { - public FastStack Loops = new FastStack(16384); + public FastStack Loops = new FastStack(32, 16384); } } diff --git a/src/MoonSharp.Interpreter/Execution/Scopes/Upvalue.cs b/src/MoonSharp.Interpreter/Execution/Scopes/Upvalue.cs new file mode 100644 index 00000000..2f9be9c1 --- /dev/null +++ b/src/MoonSharp.Interpreter/Execution/Scopes/Upvalue.cs @@ -0,0 +1,46 @@ +using System.Threading; +using MoonSharp.Interpreter.DataStructs; + +namespace MoonSharp.Interpreter.Execution +{ + /// + /// Holds a reference to a local in another function + /// + internal class Upvalue + { + public FastStack ParentScope; + public int Index; + private DynValue storage; + + private static int s = 1; + private int _refID; + public int ReferenceID { get => _refID; } + + public Upvalue(FastStack parentScope, int index) + { + ParentScope = parentScope; + Index = index; + _refID = Interlocked.Increment(ref s); + } + + protected Upvalue() + { + } + + public void Close() + { + storage = ParentScope[Index]; + ParentScope = null; + } + + public ref DynValue Value() + { + if(ParentScope != null) + return ref ParentScope[Index]; + return ref storage; + } + + public static Upvalue NewNil() => new Upvalue(); + public static Upvalue Create(DynValue obj) => new Upvalue() {storage = obj}; + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Execution/ScriptExecutionContext.cs b/src/MoonSharp.Interpreter/Execution/ScriptExecutionContext.cs index 0a42ccfb..d2286188 100644 --- a/src/MoonSharp.Interpreter/Execution/ScriptExecutionContext.cs +++ b/src/MoonSharp.Interpreter/Execution/ScriptExecutionContext.cs @@ -12,6 +12,8 @@ public class ScriptExecutionContext : IScriptPrivateResource { Processor m_Processor; CallbackFunction m_Callback; + + internal bool CanAwait { get; set; } internal ScriptExecutionContext(Processor p, CallbackFunction callBackFunction, SourceRef sourceRef, bool isDynamic = false) { @@ -83,7 +85,7 @@ public DynValue GetMetamethod(DynValue value, string metamethod) public DynValue GetMetamethodTailCall(DynValue value, string metamethod, params DynValue[] args) { DynValue meta = this.GetMetamethod(value, metamethod); - if (meta == null) return null; + if (meta.IsNil()) return meta; return DynValue.NewTailCallReq(meta, args); } @@ -181,7 +183,7 @@ public DynValue Call(DynValue func, params DynValue[] args) { DynValue v = this.GetMetamethod(func, "__call"); - if (v == null && v.IsNil()) + if (v.IsNil()) { throw ScriptRuntimeException.AttemptToCallNonFunc(func.Type); } @@ -234,7 +236,7 @@ public Table CurrentGlobalEnv { DynValue env = EvaluateSymbolByName(WellKnownSymbols.ENV); - if (env == null || env.Type != DataType.Table) + if (env.IsNil() || env.Type != DataType.Table) return null; else return env.Table; } @@ -247,7 +249,7 @@ public Table CurrentGlobalEnv /// The exception. public void PerformMessageDecorationBeforeUnwind(DynValue messageHandler, ScriptRuntimeException exception) { - if (messageHandler != null) + if (messageHandler.IsNotNil()) exception.DecoratedMessage = m_Processor.PerformMessageDecorationBeforeUnwind(messageHandler, exception.Message, CallingLocation); else exception.DecoratedMessage = exception.Message; diff --git a/src/MoonSharp.Interpreter/Execution/ScriptLoadingContext.cs b/src/MoonSharp.Interpreter/Execution/ScriptLoadingContext.cs index 69093c10..4800a0c0 100644 --- a/src/MoonSharp.Interpreter/Execution/ScriptLoadingContext.cs +++ b/src/MoonSharp.Interpreter/Execution/ScriptLoadingContext.cs @@ -1,4 +1,5 @@ -using MoonSharp.Interpreter.Debugging; +using System.Collections.Generic; +using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Tree; namespace MoonSharp.Interpreter.Execution @@ -11,6 +12,13 @@ class ScriptLoadingContext public bool Anonymous { get; set; } public bool IsDynamicExpression { get; set; } public Lexer Lexer { get; set; } + + public ScriptSyntax Syntax { get; set; } + + //Compiler state + internal List ChunkAnnotations { get; set; } = new List(); + internal List FunctionAnnotations { get; set; } = new List(); + public ScriptLoadingContext(Script s) { diff --git a/src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs b/src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs index 41a66e89..1f332f0a 100755 --- a/src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/ByteCode.cs @@ -12,12 +12,15 @@ namespace MoonSharp.Interpreter.Execution.VM internal class ByteCode : RefIdObject { public List Code = new List(); + public List SourceRefs = new List(); public Script Script { get; private set; } private List m_SourceRefStack = new List(); private SourceRef m_CurrentSourceRef = null; internal LoopTracker LoopTracker = new LoopTracker(); + public Stack NilChainTargets = new Stack(); + public ByteCode(Script script) { Script = script; @@ -59,8 +62,7 @@ public void PopSourceRef() m_CurrentSourceRef = (m_SourceRefStack.Count > 0) ? m_SourceRefStack[m_SourceRefStack.Count - 1] : null; } - #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) && (!(NETFX_CORE)) - public void Dump(string file) + public string Dump() { StringBuilder sb = new StringBuilder(); @@ -72,9 +74,8 @@ public void Dump(string file) sb.AppendFormat("{0:X8} {1}\n", i, Code[i]); } - File.WriteAllText(file, sb.ToString()); + return sb.ToString(); } - #endif public int GetJumpPointForNextInstruction() { @@ -85,66 +86,88 @@ public int GetJumpPointForLastInstruction() return Code.Count - 1; } - public Instruction GetLastInstruction() + private int AppendInstruction(Instruction c) { - return Code[Code.Count - 1]; + Code.Add(c); + SourceRefs.Add(m_CurrentSourceRef); + return Code.Count - 1; } - private Instruction AppendInstruction(Instruction c) + public void SetNumVal(int instruction, int val) { - Code.Add(c); - return c; + var ins = Code[instruction]; + ins.NumVal = val; + Code[instruction] = ins; } - public Instruction Emit_Nop(string comment) + public int Emit_Nop(string comment) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Nop, Name = comment }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Nop, String = comment }); } - public Instruction Emit_Invalid(string type) + public int Emit_Invalid(string type) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Invalid, Name = type }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Invalid, String = type }); } - public Instruction Emit_Pop(int num = 1) + public int Emit_Pop(int num = 1) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Pop, NumVal = num }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Pop, NumVal = num }); } public void Emit_Call(int argCount, string debugName) { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Call, NumVal = argCount, Name = debugName }); + AppendInstruction(new Instruction() { OpCode = OpCode.Call, NumVal = argCount, String = debugName }); } public void Emit_ThisCall(int argCount, string debugName) { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ThisCall, NumVal = argCount, Name = debugName }); + AppendInstruction(new Instruction() { OpCode = OpCode.ThisCall, NumVal = argCount, String = debugName }); + } + + public int Emit_Literal(DynValue value) + { + switch (value.Type) + { + case DataType.Nil: + return AppendInstruction(new Instruction() {OpCode = OpCode.PushNil}); + case DataType.Boolean: + if (value.Boolean) + return AppendInstruction(new Instruction() {OpCode = OpCode.PushTrue}); + else + return AppendInstruction(new Instruction() {OpCode = OpCode.PushFalse}); + case DataType.Number: + return AppendInstruction(new Instruction() {OpCode = OpCode.PushNumber, Number = value.Number}); + case DataType.String: + return AppendInstruction(new Instruction() {OpCode = OpCode.PushString, String = value.String}); + } + throw new InvalidOperationException(value.Type.ToString()); } - public Instruction Emit_Literal(DynValue value) + public int Emit_StrFormat(int argCount) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Literal, Value = value }); + return AppendInstruction(new Instruction() {OpCode = OpCode.StrFormat, NumVal = argCount}); } - public Instruction Emit_Jump(OpCode jumpOpCode, int idx, int optPar = 0) + public int Emit_Jump(OpCode jumpOpCode, int idx, int optPar = 0) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = jumpOpCode, NumVal = idx, NumVal2 = optPar }); + return AppendInstruction(new Instruction() { OpCode = jumpOpCode, NumVal = idx, NumVal2 = optPar }); } - public Instruction Emit_MkTuple(int cnt) + public int Emit_MkTuple(int cnt) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.MkTuple, NumVal = cnt }); + return AppendInstruction(new Instruction() { OpCode = OpCode.MkTuple, NumVal = cnt }); } - public Instruction Emit_Operator(OpCode opcode) + public int Emit_Operator(OpCode opcode) { - var i = AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = opcode }); + var i = AppendInstruction(new Instruction() { OpCode = opcode }); if (opcode == OpCode.LessEq) - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.CNot }); + AppendInstruction(new Instruction() { OpCode = OpCode.CNot }); if (opcode == OpCode.Eq || opcode == OpCode.Less) - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ToBool }); + AppendInstruction(new Instruction() { OpCode = OpCode.ToBool }); return i; } @@ -153,89 +176,99 @@ public Instruction Emit_Operator(OpCode opcode) [Conditional("EMIT_DEBUG_OPS")] public void Emit_Debug(string str) { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) }); + AppendInstruction(new Instruction() { OpCode = OpCode.Debug, String = str.Substring(0, Math.Min(32, str.Length)) }); } - public Instruction Emit_Enter(RuntimeScopeBlock runtimeScopeBlock) + public int Emit_Enter(RuntimeScopeBlock runtimeScopeBlock) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); } - public Instruction Emit_Leave(RuntimeScopeBlock runtimeScopeBlock) + public int Emit_Leave(RuntimeScopeBlock runtimeScopeBlock) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.To }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.To }); } - public Instruction Emit_Exit(RuntimeScopeBlock runtimeScopeBlock) + public int Emit_Exit(RuntimeScopeBlock runtimeScopeBlock) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); } - public Instruction Emit_Clean(RuntimeScopeBlock runtimeScopeBlock) + public int Emit_Clean(RuntimeScopeBlock runtimeScopeBlock) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.To + 1, NumVal2 = runtimeScopeBlock.ToInclusive }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.To + 1, NumVal2 = runtimeScopeBlock.ToInclusive }); } - public Instruction Emit_Closure(SymbolRef[] symbols, int jmpnum) + public int Emit_CloseUp(SymbolRef sym) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Closure, SymbolList = symbols, NumVal = jmpnum }); + if (sym.Type != SymbolRefType.Local) + throw new InternalErrorException("Can only emit CloseUp for locals"); + return AppendInstruction(new Instruction() { OpCode = OpCode.CloseUp, NumVal = sym.i_Index }); } - public Instruction Emit_Args(params SymbolRef[] symbols) + public int Emit_Closure(SymbolRef[] symbols, int jmpnum) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Args, SymbolList = symbols }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Closure, SymbolList = symbols, NumVal = jmpnum }); } - public Instruction Emit_Ret(int retvals) + public int Emit_Args(params SymbolRef[] symbols) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Ret, NumVal = retvals }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Args, SymbolList = symbols }); } - public Instruction Emit_ToNum(int stage = 0) + public int Emit_Ret(int retvals) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ToNum, NumVal = stage }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Ret, NumVal = retvals }); } - public Instruction Emit_Incr(int i) + public int Emit_Incr(int i) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Incr, NumVal = i }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Incr, NumVal = i }); } - public Instruction Emit_NewTable(bool shared) + public int Emit_NewTable(bool shared) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.NewTable, NumVal = shared ? 1 : 0 }); + return AppendInstruction(new Instruction() { OpCode = OpCode.NewTable, NumVal = shared ? 1 : 0 }); } - public Instruction Emit_IterPrep() + public int Emit_IterPrep() { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IterPrep }); + return AppendInstruction(new Instruction() { OpCode = OpCode.IterPrep }); } - public Instruction Emit_ExpTuple(int stackOffset) + public int Emit_ExpTuple(int stackOffset) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ExpTuple, NumVal = stackOffset }); + return AppendInstruction(new Instruction() { OpCode = OpCode.ExpTuple, NumVal = stackOffset }); } - public Instruction Emit_IterUpd() + public int Emit_IterUpd() { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IterUpd }); + return AppendInstruction(new Instruction() { OpCode = OpCode.IterUpd }); } - public Instruction Emit_Meta(string funcName, OpCodeMetadataType metaType, DynValue value = null) + public int Emit_Meta(string funcName, OpCodeMetadataType metaType) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) + return AppendInstruction(new Instruction() { OpCode = OpCode.Meta, - Name = funcName, - NumVal2 = (int)metaType, - Value = value + String = funcName, + NumVal2 = (int)metaType + }); + } + + public int Emit_Annot(Annotation[] annotations) + { + return AppendInstruction(new Instruction() + { + OpCode = OpCode.Annot, + Annotations = annotations }); } - public Instruction Emit_BeginFn(RuntimeScopeFrame stackFrame) + public int Emit_BeginFn(RuntimeScopeFrame stackFrame) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) + return AppendInstruction(new Instruction() { OpCode = OpCode.BeginFn, SymbolList = stackFrame.DebugSymbols.ToArray(), @@ -244,9 +277,9 @@ public Instruction Emit_BeginFn(RuntimeScopeFrame stackFrame) }); } - public Instruction Emit_Scalar() + public int Emit_Scalar() { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Scalar }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Scalar }); } public int Emit_Load(SymbolRef sym) @@ -255,13 +288,13 @@ public int Emit_Load(SymbolRef sym) { case SymbolRefType.Global: Emit_Load(sym.i_Env); - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Index, Value = DynValue.NewString(sym.i_Name) }); + AppendInstruction(new Instruction() { OpCode = OpCode.Index, String = sym.i_Name }); return 2; case SymbolRefType.Local: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Local, Symbol = sym }); + AppendInstruction(new Instruction() { OpCode = OpCode.Local, NumVal = sym.i_Index }); return 1; case SymbolRefType.Upvalue: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Upvalue, Symbol = sym }); + AppendInstruction(new Instruction() { OpCode = OpCode.Upvalue, NumVal = sym.i_Index }); return 1; default: throw new InternalErrorException("Unexpected symbol type : {0}", sym); @@ -274,58 +307,68 @@ public int Emit_Store(SymbolRef sym, int stackofs, int tupleidx) { case SymbolRefType.Global: Emit_Load(sym.i_Env); - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IndexSet, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx, Value = DynValue.NewString(sym.i_Name) }); + AppendInstruction(new Instruction() { OpCode = OpCode.IndexSet, NumVal = stackofs, NumVal2 = tupleidx, String = sym.i_Name }); return 2; case SymbolRefType.Local: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.StoreLcl, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); + AppendInstruction(new Instruction() { OpCode = OpCode.StoreLcl, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); return 1; case SymbolRefType.Upvalue: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.StoreUpv, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); + AppendInstruction(new Instruction() { OpCode = OpCode.StoreUpv, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); return 1; default: throw new InternalErrorException("Unexpected symbol type : {0}", sym); } } - public Instruction Emit_TblInitN() + public int Emit_TblInitN() { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.TblInitN }); + return AppendInstruction(new Instruction() { OpCode = OpCode.TblInitN }); } - public Instruction Emit_TblInitI(bool lastpos) + public int Emit_TblInitI(bool lastpos) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.TblInitI, NumVal = lastpos ? 1 : 0 }); + return AppendInstruction(new Instruction() { OpCode = OpCode.TblInitI, NumVal = lastpos ? 1 : 0 }); } - public Instruction Emit_Index(DynValue index = null, bool isNameIndex = false, bool isExpList = false) + public int Emit_Index(string index = null, bool isNameIndex = false, bool isExpList = false) { OpCode o; if (isNameIndex) o = OpCode.IndexN; else if (isExpList) o = OpCode.IndexL; else o = OpCode.Index; - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = o, Value = index }); + return AppendInstruction(new Instruction() { OpCode = o, String = index }); } - public Instruction Emit_IndexSet(int stackofs, int tupleidx, DynValue index = null, bool isNameIndex = false, bool isExpList = false) + public int Emit_IndexSet(int stackofs, int tupleidx, string index = null, bool isNameIndex = false, bool isExpList = false) { OpCode o; if (isNameIndex) o = OpCode.IndexSetN; else if (isExpList) o = OpCode.IndexSetL; else o = OpCode.IndexSet; - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = o, NumVal = stackofs, NumVal2 = tupleidx, Value = index }); + return AppendInstruction(new Instruction() { OpCode = o, NumVal = stackofs, NumVal2 = tupleidx, String = index }); } - public Instruction Emit_Copy(int numval) + public int Emit_Copy(int numval) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Copy, NumVal = numval }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Copy, NumVal = numval }); + } + + public int Emit_CopyValue(int numval, int tupleidx) + { + return AppendInstruction(new Instruction() { OpCode = OpCode.Copy, NumVal = numval, NumVal2 = tupleidx }); } - public Instruction Emit_Swap(int p1, int p2) + public int Emit_Swap(int p1, int p2) { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Swap, NumVal = p1, NumVal2 = p2 }); + return AppendInstruction(new Instruction() { OpCode = OpCode.Swap, NumVal = p1, NumVal2 = p2 }); } + public int Emit_JLclInit(SymbolRef sym, int target) + { + if(sym.Type != SymbolRefType.Local) throw new InternalErrorException("Unexpected symbol type : {0}", sym); + return AppendInstruction(new Instruction() { OpCode = OpCode.JLclInit, NumVal = target, NumVal2 = sym.Index }); + } } } diff --git a/src/MoonSharp.Interpreter/Execution/VM/CallStackItem.cs b/src/MoonSharp.Interpreter/Execution/VM/CallStackItem.cs index 9d29fb9c..4262d132 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/CallStackItem.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/CallStackItem.cs @@ -1,9 +1,12 @@ -using MoonSharp.Interpreter.Debugging; +using System.Collections.Generic; +using MoonSharp.Interpreter.Debugging; namespace MoonSharp.Interpreter.Execution.VM { - internal class CallStackItem + internal struct CallStackItem { + public bool IsNil => BasePointer == 0; + public int Debug_EntryPoint; public SymbolRef[] Debug_Symbols; @@ -15,8 +18,11 @@ internal class CallStackItem public DynValue ErrorHandlerBeforeUnwind; public int BasePointer; + public int LocalBase; + public int LocalCount; public int ReturnAddress; - public DynValue[] LocalScope; + + public List OpenClosures; public ClosureContext ClosureScope; public CallStackItemFlags Flags; diff --git a/src/MoonSharp.Interpreter/Execution/VM/ExecutionState.cs b/src/MoonSharp.Interpreter/Execution/VM/ExecutionState.cs index ed35fc3d..412a0902 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/ExecutionState.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/ExecutionState.cs @@ -4,8 +4,8 @@ namespace MoonSharp.Interpreter.Execution.VM { internal sealed class ExecutionState { - public FastStack ValueStack = new FastStack(131072); - public FastStack ExecutionStack = new FastStack(131072); + public FastStack ValueStack = new FastStack(1024, 131072); + public FastStack ExecutionStack = new FastStack(1024, 131072); public int InstructionPtr = 0; public CoroutineState State = CoroutineState.NotStarted; } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Instruction.cs b/src/MoonSharp.Interpreter/Execution/VM/Instruction.cs index c6034014..02f4f16d 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Instruction.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Instruction.cs @@ -2,26 +2,47 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.IO; +using MoonSharp.Interpreter.Serialization; namespace MoonSharp.Interpreter.Execution.VM { - internal class Instruction + [StructLayout(LayoutKind.Explicit)] + internal struct Instruction { - internal OpCode OpCode; - internal SymbolRef Symbol; - internal SymbolRef[] SymbolList; - internal string Name; - internal DynValue Value; - internal int NumVal; - internal int NumVal2; - internal SourceRef SourceCodeRef; - - internal Instruction(SourceRef sourceref) + [FieldOffset(0)] internal OpCode OpCode; + [FieldOffset(4)] internal double Number; + [FieldOffset(4)] internal int NumVal; + [FieldOffset(8)] internal int NumVal2; + [FieldOffset(16)] object _object; + + internal SymbolRef Symbol + { + get => _object as SymbolRef; + set => _object = value; + } + + internal SymbolRef[] SymbolList + { + get => _object as SymbolRef[]; + set => _object = value; + } + + internal string String { - SourceCodeRef = sourceref; + get => _object as string; + set => _object = value; } + internal Annotation[] Annotations + { + get => _object as Annotation[]; + set => _object = value; + } + + public override string ToString() { string append = this.OpCode.ToString().ToUpperInvariant(); @@ -35,15 +56,13 @@ public override string ToString() append += " " + NumVal.ToString("X8"); else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) append += " " + NumVal.ToString(); - + else if ((usage & ((int)InstructionFieldUsage.Number)) != 0) + append += " " + Number.ToString(); if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) append += " " + NumVal2.ToString(); - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - append += " " + Name; - - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - append += " " + PurifyFromNewLines(Value); + if ((usage & ((int)InstructionFieldUsage.String)) != 0) + append += " " + (String == null ? "" : DynValue.NewString(String).SerializeValue()); if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) append += " " + Symbol; @@ -51,15 +70,10 @@ public override string ToString() if (((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) && (SymbolList != null)) append += " " + string.Join(",", SymbolList.Select(s => s.ToString()).ToArray()); - return append; - } + if (((usage & ((int) InstructionFieldUsage.Annotations)) != 0) && (Annotations != null)) + append += " " + string.Join(",", Annotations.Select((x => x.ToString()))); - private string PurifyFromNewLines(DynValue Value) - { - if (Value == null) - return ""; - - return Value.ToString().Replace('\n', ' ').Replace('\r', ' '); + return append; } private string GenSpaces() @@ -67,145 +81,209 @@ private string GenSpaces() return new string(' ', 10 - this.OpCode.ToString().Length); } - internal void WriteBinary(BinaryWriter wr, int baseAddress, Dictionary symbolMap) + internal void WriteBinary(BinDumpWriter wr, int baseAddress, Dictionary symbolMap) { - wr.Write((byte)this.OpCode); + wr.WriteByte((byte)this.OpCode); int usage = (int)OpCode.GetFieldUsage(); - if ((usage & ((int)InstructionFieldUsage.NumValAsCodeAddress)) == (int)InstructionFieldUsage.NumValAsCodeAddress) - wr.Write(this.NumVal - baseAddress); - else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) - wr.Write(this.NumVal); - - if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) - wr.Write(this.NumVal2); - - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - wr.Write(Name ?? ""); + if ((usage & (int) InstructionFieldUsage.Number) == 0 + && (usage & (int) InstructionFieldUsage.NumVal2) == 0 && + (usage & (int) InstructionFieldUsage.NumVal) == 0 && + (usage & (int) InstructionFieldUsage.NumValAsCodeAddress) == 0 && + (NumVal != 0 || NumVal2 != 0)) + throw new Exception("NumVal usage"); + + if ((usage & ((int)InstructionFieldUsage.String)) == 0 && + (usage & ((int)InstructionFieldUsage.Symbol)) == 0 && + (usage & ((int)InstructionFieldUsage.SymbolList)) == 0 && + (usage & ((int)InstructionFieldUsage.Annotations)) == 0 && + _object != null) + { + throw new Exception("Object usage"); + } + + if ((usage & ((int) InstructionFieldUsage.Number)) == (int) InstructionFieldUsage.Number) + { + wr.WriteDouble(this.Number); + } + else + { + if ((usage & ((int) InstructionFieldUsage.NumValAsCodeAddress)) == + (int) InstructionFieldUsage.NumValAsCodeAddress) + wr.WriteVarInt32(this.NumVal - baseAddress); + else if ((usage & ((int) InstructionFieldUsage.NumVal)) != 0) + wr.WriteVarInt32(this.NumVal); + if ((usage & ((int) InstructionFieldUsage.NumVal2)) != 0) + wr.WriteVarInt32(this.NumVal2); + } - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - DumpValue(wr, Value); + if ((usage & ((int)InstructionFieldUsage.String)) != 0) + wr.WriteString(String); if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) WriteSymbol(wr, Symbol, symbolMap); if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) { - wr.Write(this.SymbolList.Length); + wr.WriteVarUInt32((uint)this.SymbolList.Length); for (int i = 0; i < this.SymbolList.Length; i++) WriteSymbol(wr, SymbolList[i], symbolMap); } + + if ((usage & ((int) InstructionFieldUsage.Annotations)) != 0) + { + wr.WriteVarUInt32((uint)this.Annotations.Length); + for (int i = 0; i < Annotations.Length; i++) + { + wr.WriteString(Annotations[i].Name); + WriteDynValue(wr, Annotations[i].Value, true); + } + } } - private static void WriteSymbol(BinaryWriter wr, SymbolRef symbolRef, Dictionary symbolMap) + private static void WriteSymbol(BinDumpWriter wr, SymbolRef symbolRef, Dictionary symbolMap) { - int id = (symbolRef == null) ? -1 : symbolMap[symbolRef]; - wr.Write(id); + int id = (symbolRef == null) ? 0 : symbolMap[symbolRef] + 1; + wr.WriteVarUInt32((uint)id); } - private static SymbolRef ReadSymbol(BinaryReader rd, SymbolRef[] deserializedSymbols) + private static SymbolRef ReadSymbol(BinDumpReader rd, SymbolRef[] deserializedSymbols) { - int id = rd.ReadInt32(); + uint id = rd.ReadVarUInt32(); - if (id < 0) return null; - return deserializedSymbols[id]; + if (id < 1) return null; + return deserializedSymbols[id - 1]; } - internal static Instruction ReadBinary(SourceRef chunkRef, BinaryReader rd, int baseAddress, Table envTable, SymbolRef[] deserializedSymbols) + static void WriteDynValue(BinDumpWriter wr, DynValue d, bool allowTable) { - Instruction that = new Instruction(chunkRef); - - that.OpCode = (OpCode)rd.ReadByte(); - - int usage = (int)that.OpCode.GetFieldUsage(); - - if ((usage & ((int)InstructionFieldUsage.NumValAsCodeAddress)) == (int)InstructionFieldUsage.NumValAsCodeAddress) - that.NumVal = rd.ReadInt32() + baseAddress; - else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) - that.NumVal = rd.ReadInt32(); - - if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) - that.NumVal2 = rd.ReadInt32(); - - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - that.Name = rd.ReadString(); - - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - that.Value = ReadValue(rd, envTable); - - if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) - that.Symbol = ReadSymbol(rd, deserializedSymbols); + switch (d.Type) { + case DataType.Nil: + wr.WriteByte((byte)d.Type); + break; + case DataType.Void: + wr.WriteByte((byte)d.Type); + break; + case DataType.Boolean: + if(d.Boolean) wr.WriteByte((byte)DataType.Boolean | 0x80); + else wr.WriteByte((byte)DataType.Boolean); + break; + case DataType.String: + wr.WriteByte((byte)d.Type); + wr.WriteString(d.String); + break; + case DataType.Number: + wr.WriteByte((byte)d.Type); + wr.WriteDouble(d.Number); + break; + case DataType.Table when allowTable: + wr.WriteByte((byte)d.Type); + WriteTable(wr, d.Table); + break; + case DataType.Table when !allowTable: + throw new Exception("Stored table key cannot be table"); + default: + throw new Exception("Can only store DynValue of string/number/bool/nil/table"); + } + } - if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) + static void WriteTable(BinDumpWriter wr, Table t) + { + //this enumerates twice. not ideal + wr.WriteVarInt32(t.Pairs.Count()); + foreach (var p in t.Pairs) { - int len = rd.ReadInt32(); - that.SymbolList = new SymbolRef[len]; - - for (int i = 0; i < that.SymbolList.Length; i++) - that.SymbolList[i] = ReadSymbol(rd, deserializedSymbols); + WriteDynValue(wr, p.Key, false); + WriteDynValue(wr, p.Value, true); } - - return that; } - private static DynValue ReadValue(BinaryReader rd, Table envTable) + static DynValue ReadDynValue(BinDumpReader rd, bool allowTable) { - bool isnull = !rd.ReadBoolean(); - - if (isnull) return null; - - DataType dt = (DataType)rd.ReadByte(); - - switch (dt) - { + var b = rd.ReadByte(); + var type = (DataType) (b & 0x7f); + switch (type) { case DataType.Nil: - return DynValue.NewNil(); + return DynValue.Nil; case DataType.Void: return DynValue.Void; case DataType.Boolean: - return DynValue.NewBoolean(rd.ReadBoolean()); - case DataType.Number: - return DynValue.NewNumber(rd.ReadDouble()); + if ((b & 0x80) == 0x80) return DynValue.True; + return DynValue.False; case DataType.String: return DynValue.NewString(rd.ReadString()); - case DataType.Table : - return DynValue.NewTable(envTable); + case DataType.Number: + return DynValue.NewNumber(rd.ReadDouble()); + case DataType.Table when allowTable: + return ReadTable(rd); default: - throw new NotSupportedException(string.Format("Unsupported type in chunk dump : {0}", dt)); + throw new InternalErrorException("Invalid DynValue storage in bytecode"); } } + static DynValue ReadTable(BinDumpReader rd) + { + var d = DynValue.NewPrimeTable(); + var table = d.Table; + var c = rd.ReadVarInt32(); + for (int i = 0; i < c; i++) { + table.Set(ReadDynValue(rd, false), ReadDynValue(rd, true)); + } + return d; + } - private void DumpValue(BinaryWriter wr, DynValue value) + internal static Instruction ReadBinary(BinDumpReader rd, int baseAddress, Table envTable, SymbolRef[] deserializedSymbols) { - if (value == null) + Instruction that = new Instruction(); + + that.OpCode = (OpCode)rd.ReadByte(); + + int usage = (int)that.OpCode.GetFieldUsage(); + + if ((usage & ((int) InstructionFieldUsage.Number)) == (int)InstructionFieldUsage.Number) { - wr.Write(false); - return; + that.Number = rd.ReadDouble(); + } + else + { + if ((usage & ((int) InstructionFieldUsage.NumValAsCodeAddress)) == + (int) InstructionFieldUsage.NumValAsCodeAddress) + that.NumVal = rd.ReadVarInt32() + baseAddress; + else if ((usage & ((int) InstructionFieldUsage.NumVal)) != 0) + that.NumVal = rd.ReadVarInt32(); + + if ((usage & ((int) InstructionFieldUsage.NumVal2)) != 0) + that.NumVal2 = rd.ReadVarInt32(); } - wr.Write(true); - wr.Write((byte)value.Type); + if ((usage & ((int)InstructionFieldUsage.String)) != 0) + that.String = rd.ReadString(); - switch (value.Type) + if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) + that.Symbol = ReadSymbol(rd, deserializedSymbols); + + if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) { - case DataType.Nil: - case DataType.Void: - case DataType.Table: - break; - case DataType.Boolean: - wr.Write(value.Boolean); - break; - case DataType.Number: - wr.Write(value.Number); - break; - case DataType.String: - wr.Write(value.String); - break; - default: - throw new NotSupportedException(string.Format("Unsupported type in chunk dump : {0}", value.Type)); + int len = (int)rd.ReadVarUInt32(); + that.SymbolList = new SymbolRef[len]; + + for (int i = 0; i < that.SymbolList.Length; i++) + that.SymbolList[i] = ReadSymbol(rd, deserializedSymbols); } + + if ((usage & ((int) InstructionFieldUsage.Annotations)) != 0) + { + int len = (int) rd.ReadVarUInt32(); + that.Annotations = new Annotation[len]; + for (int i = 0; i < that.Annotations.Length; i++) + { + that.Annotations[i] = new Annotation(rd.ReadString(), ReadDynValue(rd, true)); + } + } + + + return that; } internal void GetSymbolReferences(out SymbolRef[] symbolList, out SymbolRef symbol) @@ -220,7 +298,6 @@ internal void GetSymbolReferences(out SymbolRef[] symbolList, out SymbolRef symb if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) symbolList = this.SymbolList; - } } } diff --git a/src/MoonSharp.Interpreter/Execution/VM/OpCode.cs b/src/MoonSharp.Interpreter/Execution/VM/OpCode.cs index 15ba552b..74192e01 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/OpCode.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/OpCode.cs @@ -10,8 +10,13 @@ internal enum OpCode // Stack ops and assignment Pop, // Discards the topmost n elements from the v-stack. Copy, // Copies the n-th value of the stack on the top + CopyValue, // Copies the n-th value of the stack on the top, fetching tupleidx from NumVal2 Swap, // Swaps two entries relative to the v-stack - Literal, // Pushes a literal (constant value) on the stack. + PushNil, // Pushes nil to the v-stack + PushTrue, // Pushes true to the v-stack + PushFalse, // Pushes false to the v-stack + PushNumber, // Pushes a number to the v-stack + PushString, // Pushes a string to the v-stack Closure, // Creates a closure on the top of the v-stack, using the symbols for upvalues and num-val for entry point of the function. NewTable, // Creates a new empty table on the stack TblInitN, // Initializes a table named entry @@ -21,12 +26,15 @@ internal enum OpCode StoreUpv, Upvalue, IndexSet, Index, IndexSetN, IndexN, - IndexSetL, IndexL, + IndexSetL, IndexL, + // Stack-frame ops and calls Clean, // Cleansup locals setting them as null + CloseUp, // Close a specific upvalue Meta, // Injects function metadata used for reflection things (dumping, debugging) + Annot, //Injects annotations BeginFn, // Adjusts for start of function, taking in parameters and allocating locals Args, // Takes the arguments passed to a function and sets the appropriate symbols in the local scope Call, // Calls the function specified on the specified element from the top of the v-stack. If the function is a MoonSharp function, it pushes its numeric value on the v-stack, then pushes the current PC onto the x-stack, enters the function closure and jumps to the function first instruction. If the function is a CLR function, it pops the function value from the v-stack, then invokes the function synchronously and finally pushes the result on the v-stack. @@ -36,17 +44,21 @@ internal enum OpCode // Jumps Jump, // Jumps to the specified PC Jf, // Pops the top of the v-stack and jumps to the specified location if it's false - JNil, // Jumps if the top of the stack is nil + Jt, // Pops the top of the v-stack and jumps to the specified location if it's true + JNil, // Jumps if the top of the stack is nil (pops stack) + JNilChk, // Jumps if the top of the stack is nil (does not pop stack) JFor, // Peeks at the top, top-1 and top-2 values of the v-stack which it assumes to be numbers. Then if top-1 is less than zero, checks if top is <= top-2, otherwise it checks that top is >= top-2. Then if the condition is false, it jumps. JtOrPop, // Peeks at the topmost value of the v-stack as a boolean. If true, it performs a jump, otherwise it removes the topmost value from the v-stack. JfOrPop, // Peeks at the topmost value of the v-stack as a boolean. If false, it performs a jump, otherwise it removes the topmost value from the v-stack. - + // + StrFormat, // Format using string.Format // Operators Concat, // Concatenation of the two topmost operands on the v-stack LessEq, // Compare <= of the two topmost operands on the v-stack Less, // Compare < of the two topmost operands on the v-stack Eq, // Compare == of the two topmost operands on the v-stack Add, // Addition of the two topmost operands on the v-stack + AddStr, // Addition of the two topmost operands on the v-stack, will concat strings Sub, // Subtraction of the two topmost operands on the v-stack Mul, // Multiplication of the two topmost operands on the v-stack Div, // Division of the two topmost operands on the v-stack @@ -56,7 +68,15 @@ internal enum OpCode Neg, // Negation (unary minus) operator of the topmost operand on the v-stack Power, // Power of the two topmost operands on the v-stack CNot, // Conditional NOT - takes second operand from the v-stack (must be bool), if true execs a NOT otherwise execs a TOBOOL - + + //Bit Operators + BAnd, + BOr, + BXor, + BLShift, + BRShiftA, + BRShiftL, + BNot, // Type conversions and manipulations MkTuple, // Creates a tuple from the topmost n values @@ -70,7 +90,13 @@ internal enum OpCode // Iterators IterPrep, // Prepares an iterator for execution IterUpd, // Updates the var part of an iterator + + // Nil coalescing + NilCoalescing, + NilCoalescingInverse, + JLclInit, // Inits a param value if a default one is specified and not provided at callsite. + // Meta Invalid, // Crashes the executor with an unrecoverable NotImplementedException. This MUST always be the last opcode in enum } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs index 7e2a068f..bd736b95 100755 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.Interop; namespace MoonSharp.Interpreter.Execution.VM { @@ -10,13 +12,13 @@ sealed partial class Processor { ByteCode m_RootChunk; - FastStack m_ValueStack = new FastStack(131072); - FastStack m_ExecutionStack = new FastStack(131072); + FastStack m_ValueStack = new FastStack(8192, 131072); + FastStack m_ExecutionStack = new FastStack(512, 131072); List m_CoroutinesStack; Table m_GlobalTable; Script m_Script; - Processor m_Parent = null; + Processor m_Parent; CoroutineState m_State; bool m_CanYield = true; int m_SavedInstructionPtr = -1; @@ -79,12 +81,55 @@ public DynValue Call(DynValue function, DynValue[] args) LeaveProcessor(); } } + + public async Task CallAsync(DynValue function, DynValue[] args) + { + List coroutinesStack = m_Parent != null ? m_Parent.m_CoroutinesStack : this.m_CoroutinesStack; + + if (coroutinesStack.Count > 0 && coroutinesStack[coroutinesStack.Count - 1] != this) + return await coroutinesStack[coroutinesStack.Count - 1].CallAsync(function, args); + + EnterProcessor(); + + try + { + var stopwatch = this.m_Script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Execution); + + m_CanYield = false; + + try + { + + m_SavedInstructionPtr = PushClrToScriptStackFrame(CallStackItemFlags.CallEntryPoint, function, args); + DynValue retval; + while ((retval = Processing_Loop(m_SavedInstructionPtr, true)).Type == DataType.AwaitRequest) + { + await retval.Task; + m_ValueStack.Push(TaskWrapper.TaskResultToDynValue(m_Script, retval.Task)); + } + return retval; + } + finally + { + m_CanYield = true; + + if (stopwatch != null) + stopwatch.Dispose(); + } + } + finally + { + LeaveProcessor(); + } + } + + // pushes all what's required to perform a clr-to-script function call. function can be null if it's already // at vstack top. private int PushClrToScriptStackFrame(CallStackItemFlags flags, DynValue function, DynValue[] args) { - if (function == null) + if (function.IsNil()) function = m_ValueStack.Peek(); else m_ValueStack.Push(function); // func val @@ -132,11 +177,7 @@ private void LeaveProcessor() int GetThreadId() { - #if ENABLE_DOTNET || NETFX_CORE - return 1; - #else - return Thread.CurrentThread.ManagedThreadId; - #endif + return Thread.CurrentThread.ManagedThreadId; } private void EnterProcessor() diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_BinaryDump.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_BinaryDump.cs index 549ee9d3..5ddd7831 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_BinaryDump.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_BinaryDump.cs @@ -10,14 +10,14 @@ namespace MoonSharp.Interpreter.Execution.VM { sealed partial class Processor { - const ulong DUMP_CHUNK_MAGIC = 0x1A0D234E4F4F4D1D; - const int DUMP_CHUNK_VERSION = 0x150; + const ulong DUMP_CHUNK_MAGIC = 0x0A04504D55444342; // "BCDUMP^D\n" + const byte DUMP_CHUNK_VERSION = 0x01; //version internal static bool IsDumpStream(Stream stream) { if (stream.Length >= 8) { - using (BinaryReader br = new BinaryReader(stream, Encoding.UTF8)) + using (BinaryReader br = new BinaryReader(stream, Encoding.UTF8, true)) { ulong magic = br.ReadUInt64(); stream.Seek(-8, SeekOrigin.Current); @@ -27,63 +27,86 @@ internal static bool IsDumpStream(Stream stream) return false; } - internal int Dump(Stream stream, int baseAddress, bool hasUpvalues) + internal string DumpString(int baseAddress) { - using (BinaryWriter bw = new BinDumpBinaryWriter(stream, Encoding.UTF8)) + Instruction? meta = FindMeta(ref baseAddress); + if (meta == null) + throw new ArgumentException("baseAddress"); + var builder = new StringBuilder(); + for (int i = 0; i <= meta.Value.NumVal; i++) { - Dictionary symbolMap = new Dictionary(); + builder.AppendLine(m_RootChunk.Code[baseAddress + i].ToString()); + } + return builder.ToString(); + } + + internal int Dump(Stream stream, int baseAddress, bool hasUpvalues, bool writeSourceRefs) + { + var bw = new BinDumpWriter(stream); - Instruction meta = FindMeta(ref baseAddress); + Dictionary symbolMap = new Dictionary(); - if (meta == null) - throw new ArgumentException("baseAddress"); + Instruction? meta = FindMeta(ref baseAddress); - bw.Write(DUMP_CHUNK_MAGIC); - bw.Write(DUMP_CHUNK_VERSION); - bw.Write(hasUpvalues); - bw.Write(meta.NumVal); + if (meta == null) + throw new ArgumentException("baseAddress"); - for (int i = 0; i <= meta.NumVal; i++) - { - SymbolRef[] symbolList; - SymbolRef symbol; + bw.WriteUInt64(DUMP_CHUNK_MAGIC); + bw.WriteByte(DUMP_CHUNK_VERSION); + bw.WriteBoolean(hasUpvalues); + bw.WriteVarUInt32((uint) meta.Value.NumVal); - m_RootChunk.Code[baseAddress + i].GetSymbolReferences(out symbolList, out symbol); + for (int i = 0; i <= meta.Value.NumVal; i++) + { + SymbolRef[] symbolList; + SymbolRef symbol; - if (symbol != null) - AddSymbolToMap(symbolMap, symbol); + m_RootChunk.Code[baseAddress + i].GetSymbolReferences(out symbolList, out symbol); - if (symbolList != null) - foreach (var s in symbolList) - AddSymbolToMap(symbolMap, s); - } + if (symbol != null) + AddSymbolToMap(symbolMap, symbol); - foreach (SymbolRef sr in symbolMap.Keys.ToArray()) - { - if (sr.i_Env != null) - AddSymbolToMap(symbolMap, sr.i_Env); - } + if (symbolList != null) + foreach (var s in symbolList) + AddSymbolToMap(symbolMap, s); + } - SymbolRef[] allSymbols = new SymbolRef[symbolMap.Count]; + foreach (SymbolRef sr in symbolMap.Keys.ToArray()) + { + if (sr.i_Env != null) + AddSymbolToMap(symbolMap, sr.i_Env); + } - foreach (KeyValuePair pair in symbolMap) - { - allSymbols[pair.Value] = pair.Key; - } + SymbolRef[] allSymbols = new SymbolRef[symbolMap.Count]; - bw.Write(symbolMap.Count); + foreach (KeyValuePair pair in symbolMap) + { + allSymbols[pair.Value] = pair.Key; + } - foreach (SymbolRef sym in allSymbols) - sym.WriteBinary(bw); + bw.WriteVarUInt32((uint) symbolMap.Count); - foreach (SymbolRef sym in allSymbols) - sym.WriteBinaryEnv(bw, symbolMap); + foreach (SymbolRef sym in allSymbols) + sym.WriteBinary(bw); - for (int i = 0; i <= meta.NumVal; i++) - m_RootChunk.Code[baseAddress + i].WriteBinary(bw, baseAddress, symbolMap); + foreach (SymbolRef sym in allSymbols) + sym.WriteBinaryEnv(bw, symbolMap); - return meta.NumVal + baseAddress + 1; + for (int i = 0; i <= meta.Value.NumVal; i++) + m_RootChunk.Code[baseAddress + i].WriteBinary(bw, baseAddress, symbolMap); + for (int i = 0; i <= meta.Value.NumVal; i++) + { + if(m_RootChunk.SourceRefs[baseAddress + i] == null || !writeSourceRefs) bw.WriteByte(0); + else if(i != 0 && m_RootChunk.SourceRefs[baseAddress + i] == m_RootChunk.SourceRefs[baseAddress + i - 1]) bw.WriteByte(1); + else + { + bw.WriteByte(2); + m_RootChunk.SourceRefs[baseAddress + i].WriteBinary(bw); + } } + + + return meta.Value.NumVal + baseAddress + 1; } private void AddSymbolToMap(Dictionary symbolMap, SymbolRef s) @@ -97,39 +120,43 @@ internal int Undump(Stream stream, int sourceID, Table envTable, out bool hasUpv int baseAddress = m_RootChunk.Code.Count; SourceRef sourceRef = new SourceRef(sourceID, 0, 0, 0, 0, false); - using (BinaryReader br = new BinDumpBinaryReader(stream, Encoding.UTF8)) - { - ulong headerMark = br.ReadUInt64(); + var br = new BinDumpReader(stream); + ulong headerMark = br.ReadUInt64(); - if (headerMark != DUMP_CHUNK_MAGIC) - throw new ArgumentException("Not a MoonSharp chunk"); + if (headerMark != DUMP_CHUNK_MAGIC) + throw new ArgumentException("Not a MoonSharp chunk"); - int version = br.ReadInt32(); + int version = br.ReadByte(); - if (version != DUMP_CHUNK_VERSION) - throw new ArgumentException("Invalid version"); + if (version != DUMP_CHUNK_VERSION) + throw new ArgumentException("Invalid version"); - hasUpvalues = br.ReadBoolean(); + hasUpvalues = br.ReadBoolean(); - int len = br.ReadInt32(); + int len = (int)br.ReadVarUInt32(); - int numSymbs = br.ReadInt32(); - SymbolRef[] allSymbs = new SymbolRef[numSymbs]; + int numSymbs = (int)br.ReadVarUInt32(); + SymbolRef[] allSymbs = new SymbolRef[numSymbs]; - for (int i = 0; i < numSymbs; i++) - allSymbs[i] = SymbolRef.ReadBinary(br); + for (int i = 0; i < numSymbs; i++) + allSymbs[i] = SymbolRef.ReadBinary(br); - for (int i = 0; i < numSymbs; i++) - allSymbs[i].ReadBinaryEnv(br, allSymbs); + for (int i = 0; i < numSymbs; i++) + allSymbs[i].ReadBinaryEnv(br, allSymbs); - for (int i = 0; i <= len; i++) - { - Instruction I = Instruction.ReadBinary(sourceRef, br, baseAddress, envTable, allSymbs); - m_RootChunk.Code.Add(I); - } - - return baseAddress; + for (int i = 0; i <= len; i++) { + Instruction I = Instruction.ReadBinary(br, baseAddress, envTable, allSymbs); + m_RootChunk.Code.Add(I); } + for (int i = 0; i <= len; i++) + { + var c = br.ReadByte(); + if(c == 0) m_RootChunk.SourceRefs.Add(sourceRef); + else if (c == 1) m_RootChunk.SourceRefs.Add(m_RootChunk.SourceRefs[m_RootChunk.SourceRefs.Count - 1]); + else m_RootChunk.SourceRefs.Add(SourceRef.ReadBinary(br, sourceID)); + } + + return baseAddress; } } } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Coroutines.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Coroutines.cs index a9664670..eafecf09 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Coroutines.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Coroutines.cs @@ -35,7 +35,7 @@ public DynValue Coroutine_Resume(DynValue[] args) if (m_State == CoroutineState.NotStarted) { - entrypoint = PushClrToScriptStackFrame(CallStackItemFlags.ResumeEntryPoint, null, args); + entrypoint = PushClrToScriptStackFrame(CallStackItemFlags.ResumeEntryPoint, DynValue.Nil, args); } else if (m_State == CoroutineState.Suspended) { diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs index f7878780..550d0df3 100755 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs @@ -10,7 +10,7 @@ namespace MoonSharp.Interpreter.Execution.VM // Same reason for the "sealed" declaration. sealed partial class Processor { - internal Instruction FindMeta(ref int baseAddress) + internal Instruction? FindMeta(ref int baseAddress) { Instruction meta = m_RootChunk.Code[baseAddress]; @@ -27,6 +27,25 @@ internal Instruction FindMeta(ref int baseAddress) return meta; } + internal Annotation[] FindAnnotations(int baseAddress) + { + Instruction meta = m_RootChunk.Code[baseAddress]; + + // skip nops + while (meta.OpCode == OpCode.Nop) + { + baseAddress++; + meta = m_RootChunk.Code[baseAddress]; + } + + if (meta.OpCode != OpCode.Meta) + return null; + baseAddress++; + if (m_RootChunk.Code[baseAddress].OpCode != OpCode.Annot) + return null; + return m_RootChunk.Code[baseAddress].Annotations; + } + internal void AttachDebugger(IDebugger debugger) { @@ -45,27 +64,28 @@ internal bool DebuggerEnabled private void ListenDebugger(Instruction instr, int instructionPtr) { bool isOnDifferentRef = false; - - if (instr.SourceCodeRef != null && m_Debug.LastHlRef != null) + var instr_SourceCodeRef = m_RootChunk.SourceRefs[instructionPtr]; + + if (instr_SourceCodeRef != null && m_Debug.LastHlRef != null) { if (m_Debug.LineBasedBreakPoints) { - isOnDifferentRef = instr.SourceCodeRef.SourceIdx != m_Debug.LastHlRef.SourceIdx || - instr.SourceCodeRef.FromLine != m_Debug.LastHlRef.FromLine; + isOnDifferentRef = instr_SourceCodeRef.SourceIdx != m_Debug.LastHlRef.SourceIdx || + instr_SourceCodeRef.FromLine != m_Debug.LastHlRef.FromLine; } else { - isOnDifferentRef = instr.SourceCodeRef != m_Debug.LastHlRef; + isOnDifferentRef = instr_SourceCodeRef != m_Debug.LastHlRef; } } else if (m_Debug.LastHlRef == null) { - isOnDifferentRef = instr.SourceCodeRef != null; + isOnDifferentRef = instr_SourceCodeRef != null; } if (m_Debug.DebuggerAttached.IsPauseRequested() || - (instr.SourceCodeRef != null && instr.SourceCodeRef.Breakpoint && isOnDifferentRef)) + (instr_SourceCodeRef != null && instr_SourceCodeRef.Breakpoint && isOnDifferentRef)) { m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.None; m_Debug.DebuggerCurrentActionTarget = -1; @@ -75,7 +95,7 @@ private void ListenDebugger(Instruction instr, int instructionPtr) { case DebuggerAction.ActionType.Run: if (m_Debug.LineBasedBreakPoints) - m_Debug.LastHlRef = instr.SourceCodeRef; + m_Debug.LastHlRef = instr_SourceCodeRef; return; case DebuggerAction.ActionType.ByteCodeStepOver: if (m_Debug.DebuggerCurrentActionTarget != instructionPtr) return; @@ -85,10 +105,10 @@ private void ListenDebugger(Instruction instr, int instructionPtr) if (m_ExecutionStack.Count >= m_Debug.ExStackDepthAtStep) return; break; case DebuggerAction.ActionType.StepIn: - if ((m_ExecutionStack.Count >= m_Debug.ExStackDepthAtStep) && (instr.SourceCodeRef == null || instr.SourceCodeRef == m_Debug.LastHlRef)) return; + if ((m_ExecutionStack.Count >= m_Debug.ExStackDepthAtStep) && (instr_SourceCodeRef == null || instr_SourceCodeRef == m_Debug.LastHlRef)) return; break; case DebuggerAction.ActionType.StepOver: - if (instr.SourceCodeRef == null || instr.SourceCodeRef == m_Debug.LastHlRef || m_ExecutionStack.Count > m_Debug.ExStackDepthAtStep) return; + if (instr_SourceCodeRef == null || instr_SourceCodeRef == m_Debug.LastHlRef || m_ExecutionStack.Count > m_Debug.ExStackDepthAtStep) return; break; } @@ -97,7 +117,7 @@ private void ListenDebugger(Instruction instr, int instructionPtr) while (true) { - var action = m_Debug.DebuggerAttached.GetAction(instructionPtr, instr.SourceCodeRef); + var action = m_Debug.DebuggerAttached.GetAction(instructionPtr, instr_SourceCodeRef); switch (action.Action) { @@ -106,7 +126,7 @@ private void ListenDebugger(Instruction instr, int instructionPtr) case DebuggerAction.ActionType.StepOut: case DebuggerAction.ActionType.ByteCodeStepOut: m_Debug.DebuggerCurrentAction = action.Action; - m_Debug.LastHlRef = instr.SourceCodeRef; + m_Debug.LastHlRef = instr_SourceCodeRef; m_Debug.ExStackDepthAtStep = m_ExecutionStack.Count; return; case DebuggerAction.ActionType.ByteCodeStepIn: @@ -119,7 +139,7 @@ private void ListenDebugger(Instruction instr, int instructionPtr) return; case DebuggerAction.ActionType.Run: m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.Run; - m_Debug.LastHlRef = instr.SourceCodeRef; + m_Debug.LastHlRef = instr_SourceCodeRef; m_Debug.DebuggerCurrentActionTarget = -1; return; case DebuggerAction.ActionType.ToggleBreakpoint: @@ -309,11 +329,11 @@ private List Debugger_RefreshWatches(ScriptExecutionContext context, private List Debugger_RefreshLocals(ScriptExecutionContext context) { List locals = new List(); - var top = this.m_ExecutionStack.Peek(); + ref var top = ref m_ExecutionStack.Peek(); - if (top != null && top.Debug_Symbols != null && top.LocalScope != null) + if (!top.IsNil && top.Debug_Symbols != null && top.LocalCount != 0) { - int len = Math.Min(top.Debug_Symbols.Length, top.LocalScope.Length); + int len = Math.Min(top.Debug_Symbols.Length, top.LocalCount); for (int i = 0; i < len; i++) { @@ -321,7 +341,7 @@ private List Debugger_RefreshLocals(ScriptExecutionContext context) { IsError = false, LValue = top.Debug_Symbols[i], - Value = top.LocalScope[i], + Value = m_ValueStack[top.BasePointer + i], Name = top.Debug_Symbols[i].i_Name }); } @@ -366,7 +386,7 @@ internal List Debugger_GetCallStack(SourceRef startingRef) var I = m_RootChunk.Code[c.Debug_EntryPoint]; - string callname = I.OpCode == OpCode.Meta ? I.Name : null; + string callname = I.OpCode == OpCode.Meta ? I.String : null; if (c.ClrFunction != null) { diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Errors.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Errors.cs index 65e78659..dc0e6ddf 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Errors.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Errors.cs @@ -8,7 +8,7 @@ private SourceRef GetCurrentSourceRef(int instructionPtr) { if (instructionPtr >= 0 && instructionPtr < m_RootChunk.Code.Count) { - return m_RootChunk.Code[instructionPtr].SourceCodeRef; + return m_RootChunk.SourceRefs[instructionPtr]; } return null; } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_IExecutionContext.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_IExecutionContext.cs index e826f240..0417adb4 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_IExecutionContext.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_IExecutionContext.cs @@ -25,7 +25,7 @@ internal DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventNa if (op1_MetaTable != null) { DynValue meta1 = op1_MetaTable.RawGet(eventName); - if (meta1 != null && meta1.IsNotNil()) + if (meta1.IsNotNil()) return meta1; } @@ -33,7 +33,7 @@ internal DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventNa if (op2_MetaTable != null) { DynValue meta2 = op2_MetaTable.RawGet(eventName); - if (meta2 != null && meta2.IsNotNil()) + if (meta2.IsNotNil()) return meta2; } @@ -42,7 +42,7 @@ internal DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventNa DynValue meta = op1.UserData.Descriptor.MetaIndex(this.m_Script, op1.UserData.Object, eventName); - if (meta != null) + if (meta.IsNotNil()) return meta; } @@ -51,11 +51,11 @@ internal DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventNa DynValue meta = op2.UserData.Descriptor.MetaIndex(this.m_Script, op2.UserData.Object, eventName); - if (meta != null) + if (meta.IsNotNil()) return meta; } - return null; + return DynValue.Nil; } internal DynValue GetMetamethod(DynValue value, string metamethod) @@ -63,7 +63,7 @@ internal DynValue GetMetamethod(DynValue value, string metamethod) if (value.Type == DataType.UserData) { DynValue v = value.UserData.Descriptor.MetaIndex(m_Script, value.UserData.Object, metamethod); - if (v != null) + if (v.IsNotNil()) return v; } @@ -76,13 +76,10 @@ internal DynValue GetMetamethodRaw(DynValue value, string metamethod) var metatable = GetMetatable(value); if (metatable == null) - return null; + return DynValue.Nil; var metameth = metatable.RawGet(metamethod); - if (metameth == null || metameth.IsNil()) - return null; - return metameth; } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs index 38c0f63e..6d8e608f 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Debugging; @@ -10,10 +11,11 @@ namespace MoonSharp.Interpreter.Execution.VM sealed partial class Processor { const int YIELD_SPECIAL_TRAP = -99; + const int YIELD_SPECIAL_AWAIT = -100; internal long AutoYieldCounter = 0; - private DynValue Processing_Loop(int instructionPtr) + private DynValue Processing_Loop(int instructionPtr, bool canAwait = false) { // This is the main loop of the processor, has a weird control flow and needs to be as fast as possible. // This sentence is just a convoluted way to say "don't complain about gotos". @@ -28,7 +30,7 @@ private DynValue Processing_Loop(int instructionPtr) while (true) { Instruction i = m_RootChunk.Code[instructionPtr]; - + int currentPtr = instructionPtr; if (m_Debug.DebuggerAttached != null) { ListenDebugger(i, instructionPtr); @@ -49,6 +51,7 @@ private DynValue Processing_Loop(int instructionPtr) case OpCode.Nop: case OpCode.Debug: case OpCode.Meta: + case OpCode.Annot: break; case OpCode.Pop: m_ValueStack.RemoveLast(i.NumVal); @@ -56,16 +59,56 @@ private DynValue Processing_Loop(int instructionPtr) case OpCode.Copy: m_ValueStack.Push(m_ValueStack.Peek(i.NumVal)); break; + case OpCode.CopyValue: + m_ValueStack.Push(GetStoreValue(i)); + break; case OpCode.Swap: ExecSwap(i); break; - case OpCode.Literal: - m_ValueStack.Push(i.Value); + case OpCode.PushNil: + m_ValueStack.Push(DynValue.Nil); + break; + case OpCode.PushTrue: + m_ValueStack.Push(DynValue.True); + break; + case OpCode.PushFalse: + m_ValueStack.Push(DynValue.False); + break; + case OpCode.PushNumber: + m_ValueStack.Push(DynValue.NewNumber(i.Number)); + break; + case OpCode.PushString: + m_ValueStack.Push(DynValue.NewString(i.String)); + break; + case OpCode.BNot: + ExecBNot(i); + break; + case OpCode.BAnd: + ExecBAnd(i); + break; + case OpCode.BOr: + ExecBOr(i); + break; + case OpCode.BXor: + ExecBXor(i); + break; + case OpCode.BLShift: + ExecBLShift(i); + break; + case OpCode.BRShiftA: + ExecBRShiftA(i); + break; + case OpCode.BRShiftL: + ExecBRShiftL(i); break; case OpCode.Add: instructionPtr = ExecAdd(i, instructionPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; break; + case OpCode.AddStr: + instructionPtr = ExecAddStr(i, instructionPtr); + if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; + break; case OpCode.Concat: instructionPtr = ExecConcat(i, instructionPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; @@ -112,12 +155,26 @@ private DynValue Processing_Loop(int instructionPtr) break; case OpCode.Call: case OpCode.ThisCall: - instructionPtr = Internal_ExecCall(i.NumVal, instructionPtr, null, null, i.OpCode == OpCode.ThisCall, i.Name); + instructionPtr = Internal_ExecCall(canAwait, i.NumVal, instructionPtr, null, null, i.OpCode == OpCode.ThisCall, i.String); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; + if (instructionPtr == YIELD_SPECIAL_AWAIT) goto yield_to_await; break; case OpCode.Scalar: m_ValueStack.Push(m_ValueStack.Pop().ToScalar()); break; + case OpCode.CloseUp: + { + ref var csi = ref m_ExecutionStack.Peek(); + if (csi.OpenClosures == null) break; + for (int j = csi.OpenClosures.Count - 1; j >= 0; j--) { + if (csi.OpenClosures[j].Index == csi.BasePointer + i.NumVal) + { + csi.OpenClosures[j].Close(); + csi.OpenClosures.RemoveAt(j); + } + } + break; + } case OpCode.Not: ExecNot(i); break; @@ -138,10 +195,20 @@ private DynValue Processing_Loop(int instructionPtr) } if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; break; + case OpCode.JNilChk: + { + if(m_ValueStack.Peek().IsNil()) + instructionPtr = i.NumVal; + } + break; case OpCode.Jf: instructionPtr = JumpBool(i, false, instructionPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; break; + case OpCode.Jt: + instructionPtr = JumpBool(i, true, instructionPtr); + if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; + break; case OpCode.Jump: instructionPtr = i.NumVal; if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; @@ -159,13 +226,19 @@ private DynValue Processing_Loop(int instructionPtr) ExecBeginFn(i); break; case OpCode.ToBool: - m_ValueStack.Push(DynValue.NewBoolean(m_ValueStack.Pop().ToScalar().CastToBool())); + { + ref var top = ref m_ValueStack.Peek(); + top = DynValue.NewBoolean(top.CastToBool()); + break; + } + case OpCode.StrFormat: + ExecStrFormat(i); break; case OpCode.Args: ExecArgs(i); break; case OpCode.Ret: - instructionPtr = ExecRet(i); + instructionPtr = ExecRet(i, currentPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; if (instructionPtr < 0) goto return_to_native_code; @@ -173,9 +246,6 @@ private DynValue Processing_Loop(int instructionPtr) case OpCode.Incr: ExecIncr(i); break; - case OpCode.ToNum: - ExecToNum(i); - break; case OpCode.JFor: instructionPtr = ExecJFor(i, instructionPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; @@ -196,13 +266,15 @@ private DynValue Processing_Loop(int instructionPtr) ExecExpTuple(i); break; case OpCode.Local: - var scope = m_ExecutionStack.Peek().LocalScope; - var index = i.Symbol.i_Index; - m_ValueStack.Push(scope[index].AsReadOnly()); + var scope = m_ExecutionStack.Peek().BasePointer; + m_ValueStack.Push(m_ValueStack[scope + i.NumVal]); break; case OpCode.Upvalue: - m_ValueStack.Push(m_ExecutionStack.Peek().ClosureScope[i.Symbol.i_Index].AsReadOnly()); + { + var cs = m_ExecutionStack.Peek().ClosureScope; + m_ValueStack.Push(cs[i.NumVal].Value()); break; + } case OpCode.StoreUpv: ExecStoreUpv(i); break; @@ -227,8 +299,20 @@ private DynValue Processing_Loop(int instructionPtr) instructionPtr = ExecIndexSet(i, instructionPtr); if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; break; + case OpCode.NilCoalescing: + instructionPtr = ExecNilCoalescingAssignment(i, instructionPtr); + if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; + break; + case OpCode.NilCoalescingInverse: + instructionPtr = ExecNilCoalescingAssignmentInverse(i, instructionPtr); + if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; + break; + case OpCode.JLclInit: + if(m_ValueStack[m_ExecutionStack.Peek().BasePointer + i.NumVal2].IsNotNil()) + instructionPtr = i.NumVal; + break; case OpCode.Invalid: - throw new NotImplementedException(string.Format("Invalid opcode : {0}", i.Name)); + throw new NotImplementedException(string.Format("Invalid opcode : {0}", i.String)); default: throw new NotImplementedException(string.Format("Execution for {0} not implented yet!", i.OpCode)); } @@ -244,6 +328,10 @@ private DynValue Processing_Loop(int instructionPtr) throw ScriptRuntimeException.CannotYieldMain(); else throw ScriptRuntimeException.CannotYield(); + + yield_to_await: + DynValue awaitRequest = m_ValueStack.Pop().ToScalar(); + return awaitRequest; } catch (InterpreterException ex) @@ -271,7 +359,7 @@ private DynValue Processing_Loop(int instructionPtr) { var c = m_ExecutionStack.Peek(i); - if (c.ErrorHandlerBeforeUnwind != null) + if (c.ErrorHandlerBeforeUnwind.IsNotNil()) ex.DecoratedMessage = PerformMessageDecorationBeforeUnwind(c.ErrorHandlerBeforeUnwind, ex.DecoratedMessage, GetCurrentSourceRef(instructionPtr)); } @@ -354,12 +442,7 @@ internal string PerformMessageDecorationBeforeUnwind(DynValue messageHandler, st private void AssignLocal(SymbolRef symref, DynValue value) { var stackframe = m_ExecutionStack.Peek(); - - DynValue v = stackframe.LocalScope[symref.i_Index]; - if (v == null) - stackframe.LocalScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); + m_ValueStack[stackframe.LocalBase + symref.i_Index] = value; } private void ExecStoreLcl(Instruction i) @@ -376,12 +459,11 @@ private void ExecStoreUpv(Instruction i) SymbolRef symref = i.Symbol; var stackframe = m_ExecutionStack.Peek(); - - DynValue v = stackframe.ClosureScope[symref.i_Index]; - if (v == null) - stackframe.ClosureScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); + + if(stackframe.ClosureScope[symref.i_Index] == null) + stackframe.ClosureScope[symref.i_Index] = Upvalue.NewNil(); + + stackframe.ClosureScope[symref.i_Index].Value() = value; } private void ExecSwap(Instruction i) @@ -399,30 +481,39 @@ private DynValue GetStoreValue(Instruction i) int stackofs = i.NumVal; int tupleidx = i.NumVal2; - DynValue v = m_ValueStack.Peek(stackofs); + ref DynValue v = ref m_ValueStack.Peek(stackofs); if (v.Type == DataType.Tuple) { - return (tupleidx < v.Tuple.Length) ? v.Tuple[tupleidx] : DynValue.NewNil(); + return (tupleidx < v.Tuple.Length) ? v.Tuple[tupleidx] : DynValue.Nil; } else { - return (tupleidx == 0) ? v : DynValue.NewNil(); + return (tupleidx == 0) ? v : DynValue.Nil; } } private void ExecClosure(Instruction i) { - Closure c = new Closure(this.m_Script, i.NumVal, i.SymbolList, + Closure c = new Closure(this.m_Script, i.NumVal, i.SymbolList, FindAnnotations(i.NumVal), i.SymbolList.Select(s => this.GetUpvalueSymbol(s)).ToList()); - m_ValueStack.Push(DynValue.NewClosure(c)); } - private DynValue GetUpvalueSymbol(SymbolRef s) + private Upvalue GetUpvalueSymbol(SymbolRef s) { if (s.Type == SymbolRefType.Local) - return m_ExecutionStack.Peek().LocalScope[s.i_Index]; + { + ref var ex = ref m_ExecutionStack.Peek(); + for (int i = 0; i < ex.OpenClosures?.Count; i++) { + if (ex.OpenClosures[i].Index == ex.LocalBase + s.i_Index) return ex.OpenClosures[i]; + } + var upval = new Upvalue(m_ValueStack, ex.LocalBase + s.i_Index); + + ex.OpenClosures ??= new List(); + ex.OpenClosures.Add(upval); + return upval; + } else if (s.Type == SymbolRefType.Upvalue) return m_ExecutionStack.Peek().ClosureScope[s.i_Index]; else @@ -440,16 +531,6 @@ private void ExecMkTuple(Instruction i) m_ValueStack.Push(DynValue.NewTuple(v)); } - private void ExecToNum(Instruction i) - { - double? v = m_ValueStack.Pop().ToScalar().CastToNumber(); - if (v.HasValue) - m_ValueStack.Push(DynValue.NewNumber(v.Value)); - else - throw ScriptRuntimeException.ConvertToNumberFailed(i.NumVal); - } - - private void ExecIterUpd(Instruction i) { DynValue v = m_ValueStack.Peek(0); @@ -494,7 +575,7 @@ private void ExecIterPrep(Instruction i) { DynValue meta = this.GetMetamethod(f, "__iterator"); - if (meta != null && !meta.IsNil()) + if (!meta.IsNil()) { if (meta.Type != DataType.Tuple) v = this.GetScript().Call(meta, f, s, var); @@ -512,7 +593,7 @@ private void ExecIterPrep(Instruction i) { DynValue callmeta = this.GetMetamethod(f, "__call"); - if (callmeta == null || callmeta.IsNil()) + if (callmeta.IsNil()) { m_ValueStack.Push(EnumerableWrapper.ConvertTable(f.Table)); return; @@ -526,9 +607,9 @@ private void ExecIterPrep(Instruction i) private int ExecJFor(Instruction i, int instructionPtr) { - double val = m_ValueStack.Peek(0).Number; - double step = m_ValueStack.Peek(1).Number; - double stop = m_ValueStack.Peek(2).Number; + double val = m_ValueStack.Peek(0).AssertNumber(1); + double step = m_ValueStack.Peek(1).AssertNumber(2); + double stop = m_ValueStack.Peek(2).AssertNumber(3); bool whileCond = (step > 0) ? val <= stop : val >= stop; @@ -542,20 +623,10 @@ private int ExecJFor(Instruction i, int instructionPtr) private void ExecIncr(Instruction i) { - DynValue top = m_ValueStack.Peek(0); + ref DynValue top = ref m_ValueStack.Peek(0); DynValue btm = m_ValueStack.Peek(i.NumVal); - if (top.ReadOnly) - { - m_ValueStack.Pop(); - - if (top.ReadOnly) - top = top.CloneAsWritable(); - - m_ValueStack.Push(top); - } - - top.AssignNumber(top.Number + btm.Number); + top = DynValue.NewNumber(top.Number + btm.Number); } @@ -581,10 +652,11 @@ private void ExecNot(Instruction i) private void ExecBeginFn(Instruction i) { - CallStackItem cur = m_ExecutionStack.Peek(); + ref CallStackItem cur = ref m_ExecutionStack.Peek(); cur.Debug_Symbols = i.SymbolList; - cur.LocalScope = new DynValue[i.NumVal]; + cur.LocalCount = i.NumVal; + cur.LocalBase = m_ValueStack.Reserve(i.NumVal); ClearBlockData(i); } @@ -592,6 +664,8 @@ private void ExecBeginFn(Instruction i) private CallStackItem PopToBasePointer() { var csi = m_ExecutionStack.Pop(); + if (csi.OpenClosures != null) + foreach(var closure in csi.OpenClosures) closure.Close(); if (csi.BasePointer >= 0) m_ValueStack.CropAtCount(csi.BasePointer); return csi; @@ -608,7 +682,7 @@ private int PopExecStackAndCheckVStack(int vstackguard) private IList CreateArgsListForFunctionCall(int numargs, int offsFromTop) { - if (numargs == 0) return new DynValue[0]; + if (numargs == 0) return Array.Empty(); DynValue lastParam = m_ValueStack.Peek(offsFromTop); @@ -633,16 +707,16 @@ private IList CreateArgsListForFunctionCall(int numargs, int offsFromT private void ExecArgs(Instruction I) { - int numargs = (int)m_ValueStack.Peek(0).Number; - + int localCount = m_ExecutionStack.Peek().LocalCount; + int numargs = (int)m_ValueStack.Peek(localCount).Number; // unpacks last tuple arguments to simplify a lot of code down under - var argsList = CreateArgsListForFunctionCall(numargs, 1); + var argsList = CreateArgsListForFunctionCall(numargs, 1 + localCount); for (int i = 0; i < I.SymbolList.Length; i++) { if (i >= argsList.Count) { - this.AssignLocal(I.SymbolList[i], DynValue.NewNil()); + this.AssignLocal(I.SymbolList[i], DynValue.Nil); } else if ((i == I.SymbolList.Length - 1) && (I.SymbolList[i].i_Name == WellKnownSymbols.VARARGS)) { @@ -651,14 +725,14 @@ private void ExecArgs(Instruction I) for (int ii = 0; ii < len; ii++, i++) { - varargs[ii] = argsList[i].ToScalar().CloneAsWritable(); + varargs[ii] = argsList[i].ToScalar(); } this.AssignLocal(I.SymbolList[I.SymbolList.Length - 1], DynValue.NewTuple(Internal_AdjustTuple(varargs))); } else { - this.AssignLocal(I.SymbolList[i], argsList[i].ToScalar().CloneAsWritable()); + this.AssignLocal(I.SymbolList[i], argsList[i].ToScalar()); } } } @@ -666,8 +740,8 @@ private void ExecArgs(Instruction I) - private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunction handler = null, - CallbackFunction continuation = null, bool thisCall = false, string debugText = null, DynValue unwindHandler = null) + private int Internal_ExecCall(bool canAwait, int argsCount, int instructionPtr, CallbackFunction handler = null, + CallbackFunction continuation = null, bool thisCall = false, string debugText = null, DynValue unwindHandler = default) { DynValue fn = m_ValueStack.Peek(argsCount); CallStackItemFlags flags = (thisCall ? CallStackItemFlags.MethodCall : CallStackItemFlags.None); @@ -684,11 +758,11 @@ private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunctio // and we are followed *exactly* by a RET 1 if (I.OpCode == OpCode.Ret && I.NumVal == 1) { - CallStackItem csi = m_ExecutionStack.Peek(); + ref CallStackItem csi = ref m_ExecutionStack.Peek(); // if the current stack item has no "odd" things pending and neither has the new coming one.. if (csi.ClrFunction == null && csi.Continuation == null && csi.ErrorHandler == null - && csi.ErrorHandlerBeforeUnwind == null && continuation == null && unwindHandler == null && handler == null) + && csi.ErrorHandlerBeforeUnwind.IsNil() && continuation == null && unwindHandler.IsNil() && handler == null) { instructionPtr = PerformTCO(instructionPtr, argsCount); flags |= CallStackItemFlags.TailCall; @@ -722,13 +796,20 @@ private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunctio Flags = flags, }); - var ret = fn.Callback.Invoke(new ScriptExecutionContext(this, fn.Callback, sref), args, isMethodCall: thisCall); + var ret = fn.Callback.Invoke(new ScriptExecutionContext(this, fn.Callback, sref) { CanAwait = canAwait }, args, isMethodCall: thisCall); m_ValueStack.RemoveLast(argsCount + 1); + if (m_Script.Options.AutoAwait && + ret.Type == DataType.UserData && + ret.UserData?.Object is TaskWrapper tw) + { + ret = tw.@await( + new ScriptExecutionContext(this, fn.Callback, sref) {CanAwait = canAwait}, null); + } m_ValueStack.Push(ret); m_ExecutionStack.Pop(); - return Internal_CheckForTailRequests(null, instructionPtr); + return Internal_CheckForTailRequests(canAwait, instructionPtr); } else if (fn.Type == DataType.Function) { @@ -751,7 +832,7 @@ private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunctio // fallback to __call metamethod var m = GetMetamethod(fn, "__call"); - if (m != null && m.IsNotNil()) + if (m.IsNotNil()) { DynValue[] tmp = new DynValue[argsCount + 1]; for (int i = 0; i < argsCount + 1; i++) @@ -762,7 +843,7 @@ private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunctio for (int i = argsCount; i >= 0; i--) m_ValueStack.Push(tmp[i]); - return Internal_ExecCall(argsCount + 1, instructionPtr, handler, continuation); + return Internal_ExecCall(canAwait, argsCount + 1, instructionPtr, handler, continuation); } throw ScriptRuntimeException.AttemptToCallNonFunc(fn.Type, debugText); @@ -788,15 +869,36 @@ private int PerformTCO(int instructionPtr, int argsCount) return retpoint; } + + private int ExecNilCoalescingAssignment(Instruction i, int instructionPtr) + { + ref DynValue lhs = ref m_ValueStack.Peek(1); + if (lhs.IsNil()) + { + m_ValueStack.Set(1, m_ValueStack.Peek()); + } + + m_ValueStack.Pop(); + return instructionPtr; + } + + private int ExecNilCoalescingAssignmentInverse(Instruction i, int instructionPtr) + { + ref DynValue lhs = ref m_ValueStack.Peek(1); + if (lhs.IsNotNil()) + { + m_ValueStack.Set(1, m_ValueStack.Peek()); + } + + m_ValueStack.Pop(); + return instructionPtr; + } - - - - private int ExecRet(Instruction i) + private int ExecRet(Instruction i, int currentPtr) { CallStackItem csi; int retpoint = 0; - + if (i.NumVal == 0) { csi = PopToBasePointer(); @@ -813,7 +915,7 @@ private int ExecRet(Instruction i) var argscnt = (int)(m_ValueStack.Pop().Number); m_ValueStack.RemoveLast(argscnt + 1); m_ValueStack.Push(retval); - retpoint = Internal_CheckForTailRequests(i, retpoint); + retpoint = Internal_CheckForTailRequests(false, retpoint); } else { @@ -821,7 +923,7 @@ private int ExecRet(Instruction i) } if (csi.Continuation != null) - m_ValueStack.Push(csi.Continuation.Invoke(new ScriptExecutionContext(this, csi.Continuation, i.SourceCodeRef), + m_ValueStack.Push(csi.Continuation.Invoke(new ScriptExecutionContext(this, csi.Continuation, m_RootChunk.SourceRefs[currentPtr]), new DynValue[1] { m_ValueStack.Pop() })); return retpoint; @@ -829,7 +931,7 @@ private int ExecRet(Instruction i) - private int Internal_CheckForTailRequests(Instruction i, int instructionPtr) + private int Internal_CheckForTailRequests(bool canAwait, int instructionPtr) { DynValue tail = m_ValueStack.Peek(0); @@ -844,12 +946,19 @@ private int Internal_CheckForTailRequests(Instruction i, int instructionPtr) for (int ii = 0; ii < tcd.Args.Length; ii++) m_ValueStack.Push(tcd.Args[ii]); - return Internal_ExecCall(tcd.Args.Length, instructionPtr, tcd.ErrorHandler, tcd.Continuation, false, null, tcd.ErrorHandlerBeforeUnwind); + return Internal_ExecCall(canAwait, tcd.Args.Length, instructionPtr, tcd.ErrorHandler, tcd.Continuation, false, null, tcd.ErrorHandlerBeforeUnwind); } else if (tail.Type == DataType.YieldRequest) { m_SavedInstructionPtr = instructionPtr; return YIELD_SPECIAL_TRAP; + } else if (tail.Type == DataType.AwaitRequest) + { + if (!canAwait) + throw new ScriptRuntimeException( + "Await Request happened when it shouldn't have. Internal state corruption?"); + m_SavedInstructionPtr = instructionPtr; + return YIELD_SPECIAL_AWAIT; } @@ -884,44 +993,243 @@ private int ExecShortCircuitingOperator(Instruction i, int instructionPtr) return instructionPtr; } } + + private void ExecBNot(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var ln)) + { + m_ValueStack.Set(0, DynValue.NewNumber(~(int)ln)); + } + else + { + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l); + } + } + + private void ExecBAnd(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)ln & (int)rn)); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + + private void ExecBOr(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)ln | (int)rn)); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + + private void ExecBXor(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)ln ^ (int)rn)); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + + private void ExecBLShift(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)ln << (int)rn)); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + + private void ExecBRShiftA(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)ln >> (int)rn)); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + + private void ExecBRShiftL(Instruction i) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber((int)( + (uint)ln >> (int)rn + ))); + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } + private int ExecAdd(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - m_ValueStack.Push(DynValue.NewNumber(ln.Value + rn.Value)); + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(ln + rn)); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__add", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); } } - private int ExecSub(Instruction i, int instructionPtr) + bool ToConcatString(ref DynValue v, out string s, ref int metamethodCounter) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); + var sc = v.ToScalar(); + if (v.IsNil()) { + s = null; + return false; + } + if (v.Type == DataType.String) + { + s = v.String; + return true; + } + else if (v.Type == DataType.Boolean) + { + s = v.Boolean ? "true" : "false"; + return true; + } + else if (v.Type == DataType.Number) { + s = v.Number.ToString(); + return true; + } + + var m = GetMetamethod(v, "__tostring"); + if (!m.IsNil()) + { + if (metamethodCounter++ > 10) { + s = null; + return false; + } + var retval = Call(m, new[] {v}); + return ToConcatString(ref retval, out s, ref metamethodCounter); + } + else { + s = null; + return false; + } + } - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); + private void ExecStrFormat(Instruction i) + { + string[] formatValues = new string[i.NumVal]; + if (i.NumVal > 0) + { + for (int j = 0; j < i.NumVal; j++) + { + var off = (i.NumVal - j - 1); + int mCount = 0; + if (!ToConcatString(ref m_ValueStack.Peek(off), out formatValues[j], ref mCount)) + { + formatValues[j] = m_ValueStack.Peek(off).ToPrintString(); + } + } + } + m_ValueStack.RemoveLast(i.NumVal); + m_ValueStack.Set(0, DynValue.NewString(string.Format(m_ValueStack.Peek(0).String, formatValues))); + } + + private int ExecAddStr(Instruction i, int instructionPtr) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) + { + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(ln + rn)); + return instructionPtr; + } + else if (m_ValueStack.Peek(1).Type == DataType.String || + m_ValueStack.Peek().Type == DataType.String) + { + int c1 = 0, c2 = 0; + if (!ToConcatString(ref m_ValueStack.Peek(), out var rhs, ref c1) || + !ToConcatString(ref m_ValueStack.Peek(1), out var lhs, ref c2)) + { + var l = m_ValueStack.Pop().ToScalar(); + var r = m_ValueStack.Pop().ToScalar(); + throw ScriptRuntimeException.ConcatOnNonString(l, r); + } + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewString(lhs + rhs)); + return instructionPtr; + } + else + { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); + int ip = Internal_InvokeBinaryMetaMethod(l, r, "__add", instructionPtr); + if (ip >= 0) return ip; + else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); + } + } - if (ln.HasValue && rn.HasValue) + private int ExecSub(Instruction i, int instructionPtr) + { + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - m_ValueStack.Push(DynValue.NewNumber(ln.Value - rn.Value)); + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(ln - rn)); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__sub", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); @@ -931,19 +1239,17 @@ private int ExecSub(Instruction i, int instructionPtr) private int ExecMul(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - m_ValueStack.Push(DynValue.NewNumber(ln.Value * rn.Value)); + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(ln * rn)); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__mul", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); @@ -952,21 +1258,18 @@ private int ExecMul(Instruction i, int instructionPtr) private int ExecMod(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - double mod = Math.IEEERemainder(ln.Value, rn.Value); - if (mod < 0) mod += rn.Value; - m_ValueStack.Push(DynValue.NewNumber(mod)); + var mod = ln - Math.Floor(ln / rn) * rn; + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(mod)); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__mod", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); @@ -975,19 +1278,17 @@ private int ExecMod(Instruction i, int instructionPtr) private int ExecDiv(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - m_ValueStack.Push(DynValue.NewNumber(ln.Value / rn.Value)); + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(ln / rn)); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__div", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); @@ -995,19 +1296,17 @@ private int ExecDiv(Instruction i, int instructionPtr) } private int ExecPower(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn) && + m_ValueStack.Peek(1).TryCastToNumber(out var ln)) { - m_ValueStack.Push(DynValue.NewNumber(Math.Pow(ln.Value, rn.Value))); + m_ValueStack.Pop(); + m_ValueStack.Set(0, DynValue.NewNumber(Math.Pow(ln,rn))); return instructionPtr; } else { + var r = m_ValueStack.Pop().ToScalar(); + var l = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeBinaryMetaMethod(l, r, "__pow", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); @@ -1017,16 +1316,14 @@ private int ExecPower(Instruction i, int instructionPtr) private int ExecNeg(Instruction i, int instructionPtr) { - DynValue r = m_ValueStack.Pop().ToScalar(); - double? rn = r.CastToNumber(); - - if (rn.HasValue) + if (m_ValueStack.Peek().TryCastToNumber(out var rn)) { - m_ValueStack.Push(DynValue.NewNumber(-rn.Value)); + m_ValueStack.Set(0, DynValue.NewNumber(-rn)); return instructionPtr; } else { + DynValue r = m_ValueStack.Pop().ToScalar(); int ip = Internal_InvokeUnaryMetaMethod(r, "__unm", instructionPtr); if (ip >= 0) return ip; else throw ScriptRuntimeException.ArithmeticOnNonNumber(r); @@ -1213,11 +1510,15 @@ private int ExecIndexSet(Instruction i, int instructionPtr) bool isNameIndex = i.OpCode == OpCode.IndexSetN; bool isMultiIndex = (i.OpCode == OpCode.IndexSetL); - DynValue originalIdx = i.Value ?? m_ValueStack.Pop(); + DynValue originalIdx; + if (i.String != null) + originalIdx = DynValue.NewString(i.String); + else + originalIdx = m_ValueStack.Pop(); DynValue idx = originalIdx.ToScalar(); DynValue obj = m_ValueStack.Pop().ToScalar(); var value = GetStoreValue(i); - DynValue h = null; + DynValue h = DynValue.Nil; while (nestedMetaOps > 0) @@ -1228,7 +1529,8 @@ private int ExecIndexSet(Instruction i, int instructionPtr) { if (!isMultiIndex) { - if (!obj.Table.Get(idx).IsNil()) + //Don't do check for __newindex if there is no metatable to begin with + if (obj.Table.MetaTable == null || !obj.Table.Get(idx).IsNil()) { obj.Table.Set(idx, value); return instructionPtr; @@ -1237,7 +1539,7 @@ private int ExecIndexSet(Instruction i, int instructionPtr) h = GetMetamethodRaw(obj, "__newindex"); - if (h == null || h.IsNil()) + if (h.IsNil()) { if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index a table. userdata expected"); @@ -1260,7 +1562,7 @@ private int ExecIndexSet(Instruction i, int instructionPtr) { h = GetMetamethodRaw(obj, "__newindex"); - if (h == null || h.IsNil()) + if (h.IsNil()) throw ScriptRuntimeException.IndexType(obj); } @@ -1273,12 +1575,12 @@ private int ExecIndexSet(Instruction i, int instructionPtr) m_ValueStack.Push(obj); m_ValueStack.Push(idx); m_ValueStack.Push(value); - return Internal_ExecCall(3, instructionPtr); + return Internal_ExecCall(false, 3, instructionPtr); } else { obj = h; - h = null; + h = DynValue.Nil; } } throw ScriptRuntimeException.LoopInNewIndex(); @@ -1293,11 +1595,15 @@ private int ExecIndex(Instruction i, int instructionPtr) bool isMultiIndex = (i.OpCode == OpCode.IndexL); - DynValue originalIdx = i.Value ?? m_ValueStack.Pop(); + DynValue originalIdx; + if (i.String != null) + originalIdx = DynValue.NewString(i.String); + else + originalIdx = m_ValueStack.Pop(); DynValue idx = originalIdx.ToScalar(); DynValue obj = m_ValueStack.Pop().ToScalar(); - DynValue h = null; + DynValue h = DynValue.Nil; while (nestedMetaOps > 0) @@ -1312,14 +1618,14 @@ private int ExecIndex(Instruction i, int instructionPtr) if (!v.IsNil()) { - m_ValueStack.Push(v.AsReadOnly()); + m_ValueStack.Push(v); return instructionPtr; } } h = GetMetamethodRaw(obj, "__index"); - if (h == null || h.IsNil()) + if (h.IsNil()) { if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index a table. userdata expected"); @@ -1333,19 +1639,19 @@ private int ExecIndex(Instruction i, int instructionPtr) var v = ud.Descriptor.Index(this.GetScript(), ud.Object, originalIdx, isNameIndex); - if (v == null) + if (v.IsVoid()) { throw ScriptRuntimeException.UserDataMissingField(ud.Descriptor.Name, idx.String); } - m_ValueStack.Push(v.AsReadOnly()); + m_ValueStack.Push(v); return instructionPtr; } else { h = GetMetamethodRaw(obj, "__index"); - if (h == null || h.IsNil()) + if (h.IsNil()) throw ScriptRuntimeException.IndexType(obj); } @@ -1355,12 +1661,12 @@ private int ExecIndex(Instruction i, int instructionPtr) m_ValueStack.Push(h); m_ValueStack.Push(obj); m_ValueStack.Push(idx); - return Internal_ExecCall(2, instructionPtr); + return Internal_ExecCall(false, 2, instructionPtr); } else { obj = h; - h = null; + h = DynValue.Nil; } } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Scope.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Scope.cs index f08ccff4..3e2c0dcb 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Scope.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Scope.cs @@ -4,16 +4,30 @@ namespace MoonSharp.Interpreter.Execution.VM { sealed partial class Processor { + private CallStackItem Nil = new CallStackItem(); + private void ClearBlockData(Instruction I) { - int from = I.NumVal; - int to = I.NumVal2; - - var array = this.m_ExecutionStack.Peek().LocalScope; + ref var exStack = ref m_ExecutionStack.Peek(); + int from = exStack.LocalBase + I.NumVal; + int to = exStack.LocalBase + I.NumVal2; + int length = to - from + 1; + if (to >= 0 && from >= 0 && to >= from) { - Array.Clear(array, from, to - from + 1); + if (exStack.OpenClosures != null) + { + for (int i = exStack.OpenClosures.Count - 1; i >= 0; i--) + { + if (exStack.OpenClosures[i].Index >= from && exStack.OpenClosures[i].Index <= to) { + exStack.OpenClosures[i].Close(); + exStack.OpenClosures.RemoveAt(i); + } + } + } + + m_ValueStack.ClearSection(from, length); } } @@ -27,9 +41,9 @@ public DynValue GetGenericSymbol(SymbolRef symref) case SymbolRefType.Global: return GetGlobalSymbol(GetGenericSymbol(symref.i_Env), symref.i_Name); case SymbolRefType.Local: - return GetTopNonClrFunction().LocalScope[symref.i_Index]; + return m_ValueStack[GetTopNonClrFunction().LocalBase + symref.i_Index]; case SymbolRefType.Upvalue: - return GetTopNonClrFunction().ClosureScope[symref.i_Index]; + return GetTopNonClrFunction().ClosureScope[symref.i_Index].Value(); default: throw new InternalErrorException("Unexpected {0} LRef at resolution: {1}", symref.i_Type, symref.i_Name); } @@ -48,7 +62,7 @@ private void SetGlobalSymbol(DynValue dynValue, string name, DynValue value) if (dynValue.Type != DataType.Table) throw new InvalidOperationException(string.Format("_ENV is not a table but a {0}", dynValue.Type)); - dynValue.Table.Set(name, value ?? DynValue.Nil); + dynValue.Table.Set(name, value); } @@ -61,24 +75,17 @@ public void AssignGenericSymbol(SymbolRef symref, DynValue value) break; case SymbolRefType.Local: { - var stackframe = GetTopNonClrFunction(); - - DynValue v = stackframe.LocalScope[symref.i_Index]; - if (v == null) - stackframe.LocalScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); + ref var stackframe = ref GetTopNonClrFunction(); + m_ValueStack[stackframe.BasePointer + symref.i_Index] = value; } break; case SymbolRefType.Upvalue: { - var stackframe = GetTopNonClrFunction(); - - DynValue v = stackframe.ClosureScope[symref.i_Index]; - if (v == null) - stackframe.ClosureScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); + ref var stackframe = ref GetTopNonClrFunction(); + if(stackframe.ClosureScope[symref.i_Index] == null) + stackframe.ClosureScope[symref.i_Index] = Upvalue.NewNil(); + + stackframe.ClosureScope[symref.i_Index].Value() = value; } break; case SymbolRefType.DefaultEnv: @@ -90,19 +97,17 @@ public void AssignGenericSymbol(SymbolRef symref, DynValue value) } } - CallStackItem GetTopNonClrFunction() + ref CallStackItem GetTopNonClrFunction() { - CallStackItem stackframe = null; - for (int i = 0; i < m_ExecutionStack.Count; i++) { - stackframe = m_ExecutionStack.Peek(i); - + ref CallStackItem stackframe = ref m_ExecutionStack.Peek(i); + if (stackframe.ClrFunction == null) - break; + return ref stackframe; } - return stackframe; + return ref Nil; } @@ -110,9 +115,9 @@ public SymbolRef FindSymbolByName(string name) { if (m_ExecutionStack.Count > 0) { - CallStackItem stackframe = GetTopNonClrFunction(); + ref CallStackItem stackframe = ref GetTopNonClrFunction(); - if (stackframe != null) + if (!stackframe.IsNil) { if (stackframe.Debug_Symbols != null) { @@ -120,7 +125,7 @@ public SymbolRef FindSymbolByName(string name) { var l = stackframe.Debug_Symbols[i]; - if (l.i_Name == name && stackframe.LocalScope[i] != null) + if (l.i_Name == name /*&& stackframe.LocalScope[i] != null*/) //should a local scope ever not be inited? return l; } } diff --git a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_UtilityFunctions.cs b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_UtilityFunctions.cs index 3ad7253d..880a8b58 100644 --- a/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_UtilityFunctions.cs +++ b/src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_UtilityFunctions.cs @@ -46,49 +46,49 @@ private DynValue[] Internal_AdjustTuple(IList values) private int Internal_InvokeUnaryMetaMethod(DynValue op1, string eventName, int instructionPtr) { - DynValue m = null; + DynValue m = DynValue.Nil; if (op1.Type == DataType.UserData) { m = op1.UserData.Descriptor.MetaIndex(m_Script, op1.UserData.Object, eventName); } - if (m == null) + if (m.IsNil()) { var op1_MetaTable = GetMetatable(op1); if (op1_MetaTable != null) { DynValue meta1 = op1_MetaTable.RawGet(eventName); - if (meta1 != null && meta1.IsNotNil()) + if (meta1.IsNotNil()) m = meta1; } } - if (m != null) + if (m.IsNotNil()) { m_ValueStack.Push(m); m_ValueStack.Push(op1); - return Internal_ExecCall(1, instructionPtr); + return Internal_ExecCall(false, 1, instructionPtr); } else { return -1; } } - private int Internal_InvokeBinaryMetaMethod(DynValue l, DynValue r, string eventName, int instructionPtr, DynValue extraPush = null) + private int Internal_InvokeBinaryMetaMethod(DynValue l, DynValue r, string eventName, int instructionPtr, DynValue extraPush = default) { var m = GetBinaryMetamethod(l, r, eventName); - if (m != null) + if (m.IsNotNil()) { - if (extraPush != null) + if (extraPush.IsNotNil()) m_ValueStack.Push(extraPush); m_ValueStack.Push(m); m_ValueStack.Push(l); m_ValueStack.Push(r); - return Internal_ExecCall(2, instructionPtr); + return Internal_ExecCall(false, 2, instructionPtr); } else { diff --git a/src/MoonSharp.Interpreter/IAnnotationPolicy.cs b/src/MoonSharp.Interpreter/IAnnotationPolicy.cs new file mode 100644 index 00000000..d01fddbb --- /dev/null +++ b/src/MoonSharp.Interpreter/IAnnotationPolicy.cs @@ -0,0 +1,103 @@ +namespace MoonSharp.Interpreter +{ + public enum AnnotationValueParsingPolicy + { + /// + /// Annotations are parsed as string @MyAnnotation("strValue") or as a table @MyAnnotation({"key1", "key2"}) + /// + StringOrTable, + /// + /// Annotations are always parsed as a table and curly brackes enclosing the table are relaxed. + /// In this mode @MyAnnotation("key1", "key2") is equivalent to @MyAnnotation({"key1", "key2"}) + /// + ForceTable + } + + public enum AnnotationAction + { + Allow, + Ignore, + Error + } + + public interface IAnnotationPolicy + { + AnnotationAction OnChunkAnnotation(string name, DynValue value); + AnnotationAction OnFunctionAnnotation(string name, DynValue value); + AnnotationValueParsingPolicy AnnotationParsingPolicy { get; set; } + } + + public class CustomPolicy : IAnnotationPolicy + { + public CustomPolicy(AnnotationValueParsingPolicy parsingPolicy) + { + AnnotationParsingPolicy = parsingPolicy; + } + + public AnnotationAction OnChunkAnnotation(string name, DynValue value) + { + return AnnotationAction.Allow; + } + + public AnnotationAction OnFunctionAnnotation(string name, DynValue value) + { + return AnnotationAction.Allow; + } + + public AnnotationValueParsingPolicy AnnotationParsingPolicy { get; set; } + } + + public static class AnnotationPolicies + { + public static IAnnotationPolicy Allow { get; } = new AllowPolicy(); + + public static IAnnotationPolicy Ignore { get; } = new IgnorePolicy(); + + public static IAnnotationPolicy Error { get; } = new ErrorPolicy(); + + class AllowPolicy : IAnnotationPolicy + { + public AnnotationAction OnChunkAnnotation(string name, DynValue value) + { + return AnnotationAction.Allow; + } + + public AnnotationAction OnFunctionAnnotation(string name, DynValue value) + { + return AnnotationAction.Allow; + } + + public AnnotationValueParsingPolicy AnnotationParsingPolicy { get; set; } = AnnotationValueParsingPolicy.StringOrTable; + } + + class IgnorePolicy : IAnnotationPolicy + { + public AnnotationAction OnChunkAnnotation(string name, DynValue value) + { + return AnnotationAction.Ignore; + } + + public AnnotationAction OnFunctionAnnotation(string name, DynValue value) + { + return AnnotationAction.Ignore; + } + + public AnnotationValueParsingPolicy AnnotationParsingPolicy { get; set; } = AnnotationValueParsingPolicy.StringOrTable; + } + + class ErrorPolicy : IAnnotationPolicy + { + public AnnotationAction OnChunkAnnotation(string name, DynValue value) + { + return AnnotationAction.Error; + } + + public AnnotationAction OnFunctionAnnotation(string name, DynValue value) + { + return AnnotationAction.Error; + } + + public AnnotationValueParsingPolicy AnnotationParsingPolicy { get; set; } = AnnotationValueParsingPolicy.StringOrTable; + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/IO/BinDumpBinaryReader.cs b/src/MoonSharp.Interpreter/IO/BinDumpBinaryReader.cs deleted file mode 100755 index f10b98d4..00000000 --- a/src/MoonSharp.Interpreter/IO/BinDumpBinaryReader.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// "Optimized" BinaryReader which shares strings and use a dumb compression for integers - /// - public class BinDumpBinaryReader : BinaryReader - { - public BinDumpBinaryReader(Stream s) : base(s) { } - public BinDumpBinaryReader(Stream s, Encoding e) : base(s, e) { } - - List m_Strings = new List(); - - public override int ReadInt32() - { - sbyte b = base.ReadSByte(); - - if (b == 0x7F) - return (int)base.ReadInt16(); - else if (b == 0x7E) - return (int)base.ReadInt32(); - else - return (int)b; - } - - public override uint ReadUInt32() - { - byte b = base.ReadByte(); - - if (b == 0x7F) - return (uint)base.ReadUInt16(); - else if (b == 0x7E) - return (uint)base.ReadUInt32(); - else - return (uint)b; - } - - public override string ReadString() - { - int pos = ReadInt32(); - - if (pos < m_Strings.Count) - { - return m_Strings[pos]; - } - else if (pos == m_Strings.Count) - { - string str = base.ReadString(); - m_Strings.Add(str); - return str; - } - else - { - throw new IOException("string map failure"); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/IO/BinDumpBinaryWriter.cs b/src/MoonSharp.Interpreter/IO/BinDumpBinaryWriter.cs deleted file mode 100755 index bd360fd6..00000000 --- a/src/MoonSharp.Interpreter/IO/BinDumpBinaryWriter.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// "Optimized" BinaryWriter which shares strings and use a dumb compression for integers - /// - public class BinDumpBinaryWriter : BinaryWriter - { - Dictionary m_StringMap = new Dictionary(); - - public BinDumpBinaryWriter(Stream s) : base(s) { } - public BinDumpBinaryWriter(Stream s, Encoding e) : base(s, e) { } - - public override void Write(uint value) - { - byte v8 = (byte)value; - - if ((uint)v8 == value && (v8 != 0x7F) && (v8 != 0x7E)) - { - base.Write(v8); - } - else - { - ushort v16 = (ushort)value; - - if ((uint)v16 == value) - { - base.Write((byte)0x7F); - base.Write(v16); - } - else - { - base.Write((byte)0x7E); - base.Write(value); - } - } - } - - public override void Write(int value) - { - sbyte vsbyte = (sbyte)value; - - if ((int)vsbyte == value && (vsbyte != 0x7F) && (vsbyte != 0x7E)) - { - base.Write(vsbyte); - } - else - { - short vshort = (short)value; - - if ((int)vshort == value) - { - base.Write((sbyte)0x7F); - base.Write(vshort); - } - else - { - base.Write((sbyte)0x7E); - base.Write(value); - } - } - } - - public override void Write(string value) - { - int pos; - - if (m_StringMap.TryGetValue(value, out pos)) - { - this.Write(m_StringMap[value]); - } - else - { - pos = m_StringMap.Count; - m_StringMap[value] = pos; - - this.Write(pos); - base.Write(value); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/IO/BinDumpReader.cs b/src/MoonSharp.Interpreter/IO/BinDumpReader.cs new file mode 100755 index 00000000..dfa70135 --- /dev/null +++ b/src/MoonSharp.Interpreter/IO/BinDumpReader.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace MoonSharp.Interpreter.IO +{ + /// + /// "Optimized" BinaryReader which shares strings and use a dumb compression for integers + /// + public class BinDumpReader + { + private Stream stream; + public BinDumpReader(Stream s) + { + this.stream = s; + } + + + List m_Strings = new List(); + + public byte ReadByte() + { + int a = stream.ReadByte(); + if (a == -1) throw new EndOfStreamException(); + return (byte)a; + } + + public bool ReadBoolean() + { + return ReadByte() != 0; + } + + public ulong ReadUInt64() + { + var buf = new byte[8]; + if (stream.Read(buf, 0, 8) != 8) throw new EndOfStreamException(); + return BitConverter.ToUInt64(buf, 0); + } + + public double ReadDouble() + { + var buf = new byte[8]; + if (stream.Read(buf, 0, 8) != 8) throw new EndOfStreamException(); + return BitConverter.ToDouble(buf, 0); + } + + public uint ReadVarUInt32() + { + uint a = 0; + int b = stream.ReadByte(); + if (b == -1) throw new EndOfStreamException(); + a = (uint) (b & 0x7f); + int extraCount = 0; + //first extra + if ((b & 0x80) == 0x80) { + b = stream.ReadByte(); + if (b == -1) throw new EndOfStreamException(); + a |= (uint) ((b & 0x7f) << 7); + extraCount++; + } + //second extra + if ((b & 0x80) == 0x80) { + b = stream.ReadByte(); + if (b == -1) throw new EndOfStreamException(); + a |= (uint) ((b & 0x7f) << 14); + extraCount++; + } + //third extra + if ((b & 0x80) == 0x80) { + b = stream.ReadByte(); + if (b == -1) throw new EndOfStreamException(); + a |= (uint) ((b & 0x7f) << 21); + extraCount++; + } + //fourth extra + if ((b & 0x80) == 0x80) { + b = stream.ReadByte(); + if (b == -1) throw new EndOfStreamException(); + a |= (uint) ((b & 0xf) << 28); + extraCount++; + } + switch (extraCount) { + case 1: a += 128; break; + case 2: a += 16512; break; + case 3: a += 2113663; break; + } + return a; + } + + public int ReadVarInt32() + { + var i = (int)ReadVarUInt32(); + return ((i >> 1) ^ -(i & 1)); + } + + public string ReadString() + { + var pos = ReadVarUInt32(); + if (pos == 0) return null; + if (pos == 1) return string.Empty; + pos -= 2; + if (pos < m_Strings.Count) + { + return m_Strings[(int)pos]; + } + else if (pos == m_Strings.Count) + { + var len = ReadVarUInt32(); + var bytes = new byte[len]; + if (stream.Read(bytes,0,(int)len) < len) throw new EndOfStreamException(); + var str = Encoding.UTF8.GetString(bytes); + m_Strings.Add(str); + return str; + } + else + { + throw new IOException("string map failure"); + } + } + } +} diff --git a/src/MoonSharp.Interpreter/IO/BinDumpWriter.cs b/src/MoonSharp.Interpreter/IO/BinDumpWriter.cs new file mode 100755 index 00000000..f1e36fa7 --- /dev/null +++ b/src/MoonSharp.Interpreter/IO/BinDumpWriter.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace MoonSharp.Interpreter.IO +{ + /// + /// "Optimized" BinaryWriter which shares strings and use a dumb compression for integers + /// + public class BinDumpWriter + { + private uint m_stringCount = 2; + private Dictionary m_stringMap = new Dictionary(); + + private Stream stream; + + public BinDumpWriter(Stream s) + { + stream = s; + } + + public void WriteByte(byte b) + { + stream.WriteByte(b); + } + + public void WriteBoolean(bool b) + { + stream.WriteByte(b ? (byte)1 : (byte)0); + } + + public void WriteUInt64(ulong u) + { + var bytes = BitConverter.GetBytes(u); + stream.Write(bytes, 0, bytes.Length); + } + + public void WriteDouble(double d) + { + var bytes = BitConverter.GetBytes(d); + stream.Write(bytes, 0, bytes.Length); + } + + public void WriteVarUInt32(uint u) + { + if (u <= 127) + { + stream.WriteByte((byte)u); + } + else if (u <= 16511) + { + u -= 128; + stream.WriteByte((byte)((u & 0x7f) | 0x80)); + stream.WriteByte((byte)((u >> 7) & 0x7f)); + } + else if (u <= 2113662) + { + u -= 16512; + stream.WriteByte((byte)((u & 0x7f) | 0x80)); + stream.WriteByte((byte) (((u >> 7) & 0x7f) | 0x80)); + stream.WriteByte((byte)((u >> 14) & 0x7f)); + } + else if (u <= 270549118) + { + u -= 2113663; + stream.WriteByte((byte)((u & 0x7f) | 0x80)); + stream.WriteByte((byte)(((u >> 7) & 0x7f) | 0x80)); + stream.WriteByte((byte)(((u >> 14) & 0x7f) | 0x80)); + stream.WriteByte((byte)((u >> 21) & 0x7f)); + } + else + { + stream.WriteByte((byte)((u & 0x7f) | 0x80)); + stream.WriteByte((byte)(((u >> 7) & 0x7f) | 0x80)); + stream.WriteByte((byte)(((u >> 14) & 0x7f) | 0x80)); + stream.WriteByte((byte)(((u >> 21) & 0x7f) | 0x80)); + stream.WriteByte((byte)((u >> 28) & 0x7f)); + } + } + + public void WriteVarInt32(int i) + { + WriteVarUInt32((uint)((i >> 31) ^ (i << 1))); + } + + public void WriteString(string s) + { + if (s == null) + { + WriteVarUInt32(0); + } + else if (s == string.Empty) + { + WriteVarUInt32(1); + } + else if (m_stringMap.TryGetValue(s, out uint index)) + { + WriteVarUInt32(index); + } + else + { + WriteVarUInt32(m_stringCount); + m_stringMap[s] = m_stringCount; + m_stringCount++; + var bytes = Encoding.UTF8.GetBytes(s); + WriteVarUInt32((uint)bytes.Length); + stream.Write(bytes, 0, bytes.Length); + } + } + } +} diff --git a/src/MoonSharp.Interpreter/IO/UndisposableStream.cs b/src/MoonSharp.Interpreter/IO/UndisposableStream.cs deleted file mode 100755 index 622b929b..00000000 --- a/src/MoonSharp.Interpreter/IO/UndisposableStream.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.IO; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// An adapter over Stream which bypasses the Dispose and Close methods. - /// Used to work around the pesky wrappers .NET has over Stream (BinaryReader, StreamWriter, etc.) which think they - /// own the Stream and close them when they shouldn't. Damn. - /// - public class UndisposableStream : Stream - { - Stream m_Stream; - - public UndisposableStream(Stream stream) - { - m_Stream = stream; - } - - protected override void Dispose(bool disposing) - { - } - -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) - public override void Close() - { - } -#endif - - - public override bool CanRead - { - get { return m_Stream.CanRead; } - } - - public override bool CanSeek - { - get { return m_Stream.CanSeek; } - } - - public override bool CanWrite - { - get { return m_Stream.CanWrite; } - } - - public override void Flush() - { - m_Stream.Flush(); - } - - public override long Length - { - get { return m_Stream.Length; } - } - - public override long Position - { - get { return m_Stream.Position; } - set { m_Stream.Position = value; } - } - - public override int Read(byte[] buffer, int offset, int count) - { - return m_Stream.Read(buffer, offset, count); - } - - public override long Seek(long offset, SeekOrigin origin) - { - return m_Stream.Seek(offset, origin); - } - - public override void SetLength(long value) - { - m_Stream.SetLength(value); - } - - public override void Write(byte[] buffer, int offset, int count) - { - m_Stream.Write(buffer, offset, count); - } - -#if (!(NETFX_CORE)) - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return m_Stream.BeginRead(buffer, offset, count, callback, state); - } - - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return m_Stream.BeginWrite(buffer, offset, count, callback, state); - } - - public override void EndWrite(IAsyncResult asyncResult) - { - m_Stream.EndWrite(asyncResult); - } - - public override int EndRead(IAsyncResult asyncResult) - { - return m_Stream.EndRead(asyncResult); - } -#endif - public override bool CanTimeout - { - get { return m_Stream.CanTimeout; } - } - - - public override bool Equals(object obj) - { - return m_Stream.Equals(obj); - } - - public override int GetHashCode() - { - return m_Stream.GetHashCode(); - } - - - public override int ReadByte() - { - return m_Stream.ReadByte(); - } - - public override int ReadTimeout - { - get - { - return m_Stream.ReadTimeout; - } - set - { - m_Stream.ReadTimeout = value; - } - } - - public override string ToString() - { - return m_Stream.ToString(); - } - - public override void WriteByte(byte value) - { - m_Stream.WriteByte(value); - } - - public override int WriteTimeout - { - get - { - return m_Stream.WriteTimeout; - } - set - { - m_Stream.WriteTimeout = value; - } - } - - - } -} diff --git a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs index 8867be86..85cb81f3 100644 --- a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.Converters; namespace MoonSharp.Interpreter.Interop.BasicDescriptors @@ -224,27 +223,27 @@ public virtual DynValue Index(Script script, object obj, DynValue index, bool is .WithAccessOrNull(MemberDescriptorAccess.CanExecute); if (mdesc != null) - return ExecuteIndexer(mdesc, script, obj, index, null); + return ExecuteIndexer(mdesc, script, obj, index, DynValue.Nil); } index = index.ToScalar(); if (index.Type != DataType.String) - return null; + return DynValue.Nil; DynValue v = TryIndex(script, obj, index.String); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndex(script, obj, UpperFirstLetter(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndex(script, obj, Camelify(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndex(script, obj, UpperFirstLetter(Camelify(index.String))); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndex(script, obj, UpperFirstLetter(index.String)); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndex(script, obj, Camelify(index.String)); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndex(script, obj, UpperFirstLetter(Camelify(index.String))); - if (v == null && m_ExtMethodsVersion < UserData.GetExtensionMethodsChangeVersion()) + if (v.IsNil() && m_ExtMethodsVersion < UserData.GetExtensionMethodsChangeVersion()) { m_ExtMethodsVersion = UserData.GetExtensionMethodsChangeVersion(); v = TryIndexOnExtMethod(script, obj, index.String); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndexOnExtMethod(script, obj, Camelify(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(Camelify(index.String))); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(index.String)); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndexOnExtMethod(script, obj, Camelify(index.String)); + if (v.IsNil() && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(Camelify(index.String))); } return v; @@ -271,7 +270,7 @@ private DynValue TryIndexOnExtMethod(Script script, object obj, string indexName return DynValue.NewCallback(ext.GetCallback(script, obj)); } - return null; + return DynValue.Nil; } /// @@ -311,7 +310,7 @@ protected virtual DynValue TryIndex(Script script, object obj, string indexName) return desc.GetValue(script, obj); } - return null; + return DynValue.Nil; } /// @@ -433,7 +432,7 @@ protected virtual DynValue ExecuteIndexer(IMemberDescriptor mdesc, Script script if (index.Type == DataType.Tuple) { - if (value == null) + if (value.IsNil()) { values = index.Tuple; } @@ -445,7 +444,7 @@ protected virtual DynValue ExecuteIndexer(IMemberDescriptor mdesc, Script script } else { - if (value == null) + if (value.IsNil()) { values = new DynValue[] { index }; } @@ -528,7 +527,7 @@ public virtual DynValue MetaIndex(Script script, object obj, string metaname) case "__iterator": return ClrToScriptConversions.EnumerationToDynValue(script, obj); default: - return null; + return DynValue.Nil; } } @@ -561,7 +560,7 @@ private DynValue MultiDispatchLessThanOrEqual(Script script, object obj) DynValue.NewBoolean(PerformComparison(obj, args[0].ToObject(), args[1].ToObject()) <= 0)); } - return null; + return DynValue.Nil; } private DynValue MultiDispatchLessThan(Script script, object obj) @@ -574,12 +573,12 @@ private DynValue MultiDispatchLessThan(Script script, object obj) DynValue.NewBoolean(PerformComparison(obj, args[0].ToObject(), args[1].ToObject()) < 0)); } - return null; + return DynValue.Nil; } private DynValue TryDispatchLength(Script script, object obj) { - if (obj == null) return null; + if (obj == null) return DynValue.Nil; var lenprop = m_Members.GetOrDefault("Length"); if (lenprop != null && lenprop.CanRead() && !lenprop.CanExecute()) return lenprop.GetGetterCallbackAsDynValue(script, obj); @@ -587,7 +586,7 @@ private DynValue TryDispatchLength(Script script, object obj) var countprop = m_Members.GetOrDefault("Count"); if (countprop != null && countprop.CanRead() && !countprop.CanExecute()) return countprop.GetGetterCallbackAsDynValue(script, obj); - return null; + return DynValue.Nil; } @@ -622,7 +621,7 @@ private DynValue DispatchMetaOnMethod(Script script, object obj, string methodNa return desc.GetValue(script, obj); } else - return null; + return DynValue.Nil; } @@ -632,9 +631,9 @@ private DynValue TryDispatchToNumber(Script script, object obj) { var name = t.GetConversionMethodName(); var v = DispatchMetaOnMethod(script, obj, name); - if (v != null) return v; + if (v.IsNotNil()) return v; } - return null; + return DynValue.Nil; } @@ -642,7 +641,7 @@ private DynValue TryDispatchToBool(Script script, object obj) { var name = typeof(bool).GetConversionMethodName(); var v = DispatchMetaOnMethod(script, obj, name); - if (v != null) return v; + if (v.IsNotNil()) return v; return DispatchMetaOnMethod(script, obj, "op_True"); } @@ -659,7 +658,7 @@ private DynValue TryDispatchToBool(Script script, object obj) /// public virtual bool IsTypeCompatible(Type type, object obj) { - return Framework.Do.IsInstanceOfType(type, obj); + return type.IsInstanceOfType(obj); } } } diff --git a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs index 547fe66c..66f00500 100755 --- a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop.BasicDescriptors { @@ -112,7 +111,7 @@ public ParameterDescriptor(ParameterInfo pi) { Name = pi.Name; Type = pi.ParameterType; - HasDefaultValue = !(Framework.Do.IsDbNull(pi.DefaultValue)); + HasDefaultValue = !(Convert.IsDBNull(pi.DefaultValue)); DefaultValue = pi.DefaultValue; IsOut = pi.IsOut; IsRef = pi.ParameterType.IsByRef; @@ -147,7 +146,7 @@ public void RestrictType(Type type) if (IsOut || IsRef || IsVarArgs) throw new InvalidOperationException("Cannot restrict a ref/out or varargs param"); - if (!Framework.Do.IsAssignableFrom(Type, type)) + if (!Type.IsAssignableFrom(type)) throw new InvalidOperationException("Specified operation is not a restriction"); m_OriginalType = Type; diff --git a/src/MoonSharp.Interpreter/Interop/Converters/ClrToScriptConversions.cs b/src/MoonSharp.Interpreter/Interop/Converters/ClrToScriptConversions.cs index 7576ffdb..6e279105 100755 --- a/src/MoonSharp.Interpreter/Interop/Converters/ClrToScriptConversions.cs +++ b/src/MoonSharp.Interpreter/Interop/Converters/ClrToScriptConversions.cs @@ -1,6 +1,7 @@ using System; using System.Reflection; using System.Text; +using System.Threading.Tasks; using MoonSharp.Interpreter.Interop.RegistrationPolicies; namespace MoonSharp.Interpreter.Interop.Converters @@ -34,7 +35,7 @@ internal static DynValue TryObjectToTrivialDynValue(Script script, object obj) if (obj is Table) return DynValue.NewTable((Table)obj); - return null; + return DynValue.Nil; } @@ -55,7 +56,7 @@ internal static DynValue TryObjectToSimpleDynValue(Script script, object obj) if (converter != null) { var v = converter(script, obj); - if (v != null) + if (v.IsNotNil()) return v; } @@ -82,19 +83,15 @@ internal static DynValue TryObjectToSimpleDynValue(Script script, object obj) if (obj is Delegate) { Delegate d = (Delegate)obj; - - -#if NETFX_CORE - MethodInfo mi = d.GetMethodInfo(); -#else + MethodInfo mi = d.Method; -#endif + if (CallbackFunction.CheckCallbackSignature(mi, false)) return DynValue.NewCallback((Func)d); } - return null; + return DynValue.Nil; } @@ -103,12 +100,16 @@ internal static DynValue TryObjectToSimpleDynValue(Script script, object obj) /// internal static DynValue ObjectToDynValue(Script script, object obj) { + if(obj == null) return DynValue.Nil; + if (obj is DynValue _dyn) return _dyn; + if (obj is Task task) return ObjectToDynValue(script, new TaskWrapper(task)); + DynValue v = TryObjectToSimpleDynValue(script, obj); - if (v != null) return v; + if (v.IsNotNil()) return v; v = UserData.Create(obj); - if (v != null) return v; + if (v.IsNotNil()) return v; if (obj is Type) v = UserData.CreateStatic(obj as Type); @@ -117,7 +118,7 @@ internal static DynValue ObjectToDynValue(Script script, object obj) if (obj is Enum) return DynValue.NewNumber(NumericConversions.TypeToDouble(Enum.GetUnderlyingType(obj.GetType()), obj)); - if (v != null) return v; + if (v.IsNotNil()) return v; if (obj is Delegate) return DynValue.NewCallback(CallbackFunction.FromDelegate(script, (Delegate)obj)); @@ -145,7 +146,7 @@ internal static DynValue ObjectToDynValue(Script script, object obj) } var enumerator = EnumerationToDynValue(script, obj); - if (enumerator != null) return enumerator; + if (enumerator.IsNotNil()) return enumerator; throw ScriptRuntimeException.ConvertObjectFailed(obj); @@ -171,7 +172,7 @@ public static DynValue EnumerationToDynValue(Script script, object obj) return EnumerableWrapper.ConvertIterator(script, enumer); } - return null; + return DynValue.Nil; } diff --git a/src/MoonSharp.Interpreter/Interop/Converters/ScriptToClrConversions.cs b/src/MoonSharp.Interpreter/Interop/Converters/ScriptToClrConversions.cs index b548624a..0cd0d3f3 100755 --- a/src/MoonSharp.Interpreter/Interop/Converters/ScriptToClrConversions.cs +++ b/src/MoonSharp.Interpreter/Interop/Converters/ScriptToClrConversions.cs @@ -1,5 +1,4 @@ using System; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop.Converters { @@ -111,11 +110,11 @@ internal static object DynValueToObjectOfType(DynValue value, Type desiredType, case DataType.Void: if (isOptional) return defaultValue; - else if ((!Framework.Do.IsValueType(desiredType)) || (nullableType != null)) + else if (!desiredType.IsValueType || (nullableType != null)) return null; break; case DataType.Nil: - if (Framework.Do.IsValueType(desiredType)) + if (desiredType.IsValueType) { if (nullableType != null) return null; @@ -135,7 +134,7 @@ internal static object DynValueToObjectOfType(DynValue value, Type desiredType, str = value.Boolean.ToString(); break; case DataType.Number: - if (Framework.Do.IsEnum(desiredType)) + if (desiredType.IsEnum) { // number to enum conv Type underType = Enum.GetUnderlyingType(desiredType); return NumericConversions.DoubleToType(underType, value.Number); @@ -176,7 +175,7 @@ internal static object DynValueToObjectOfType(DynValue value, Type desiredType, } break; case DataType.Table: - if (desiredType == typeof(Table) || Framework.Do.IsAssignableFrom(desiredType, typeof(Table))) + if (desiredType == typeof(Table) || desiredType.IsAssignableFrom(typeof(Table))) return value.Table; else { @@ -231,11 +230,11 @@ internal static int DynValueToObjectOfTypeWeight(DynValue value, Type desiredTyp case DataType.Void: if (isOptional) return WEIGHT_VOID_WITH_DEFAULT; - else if ((!Framework.Do.IsValueType(desiredType)) || (nullableType != null)) + else if (desiredType.IsValueType || (nullableType != null)) return WEIGHT_VOID_WITHOUT_DEFAULT; break; case DataType.Nil: - if (Framework.Do.IsValueType(desiredType)) + if (desiredType.IsValueType) { if (nullableType != null) return WEIGHT_NIL_TO_NULLABLE; @@ -255,7 +254,7 @@ internal static int DynValueToObjectOfTypeWeight(DynValue value, Type desiredTyp return WEIGHT_BOOL_TO_STRING; break; case DataType.Number: - if (Framework.Do.IsEnum(desiredType)) + if (desiredType.IsEnum) { // number to enum conv return WEIGHT_NUMBER_TO_ENUM; } @@ -294,7 +293,7 @@ internal static int DynValueToObjectOfTypeWeight(DynValue value, Type desiredTyp } break; case DataType.Table: - if (desiredType == typeof(Table) || Framework.Do.IsAssignableFrom(desiredType, typeof(Table))) + if (desiredType == typeof(Table) || desiredType.IsAssignableFrom(typeof(Table))) return WEIGHT_EXACT_MATCH; else if (TableConversions.CanConvertTableToType(value.Table, desiredType)) return WEIGHT_TABLE_CONVERSION; diff --git a/src/MoonSharp.Interpreter/Interop/Converters/TableConversions.cs b/src/MoonSharp.Interpreter/Interop/Converters/TableConversions.cs index 0f744f45..bf8e1121 100644 --- a/src/MoonSharp.Interpreter/Interop/Converters/TableConversions.cs +++ b/src/MoonSharp.Interpreter/Interop/Converters/TableConversions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop.Converters { @@ -44,20 +43,20 @@ internal static Table ConvertIDictionaryToTable(Script script, System.Collection /// internal static bool CanConvertTableToType(Table table, Type t) { - if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) + if (t.IsAssignableFrom(typeof(Dictionary))) return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) + else if (t.IsAssignableFrom(typeof(Dictionary))) return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) + else if (t.IsAssignableFrom(typeof(List))) return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) + else if (t.IsAssignableFrom(typeof(List))) return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(object[]))) + else if (t.IsAssignableFrom(typeof(object[]))) return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(DynValue[]))) + else if (t.IsAssignableFrom(typeof(DynValue[]))) return true; - if (Framework.Do.IsGenericType(t)) + if (t.IsGenericType) { Type generic = t.GetGenericTypeDefinition(); @@ -88,20 +87,20 @@ internal static bool CanConvertTableToType(Table table, Type t) /// internal static object ConvertTableToType(Table table, Type t) { - if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) + if (t.IsAssignableFrom(typeof(Dictionary))) return TableToDictionary(table, v => v.ToObject(), v => v.ToObject()); - else if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) + else if (t.IsAssignableFrom(typeof(Dictionary))) return TableToDictionary(table, v => v, v => v); - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) + else if (t.IsAssignableFrom(typeof(List))) return TableToList(table, v => v.ToObject()); - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) + else if (t.IsAssignableFrom(typeof(List))) return TableToList(table, v => v); - else if (Framework.Do.IsAssignableFrom(t, typeof(object[]))) + else if (t.IsAssignableFrom(typeof(object[]))) return TableToList(table, v => v.ToObject()).ToArray(); - else if (Framework.Do.IsAssignableFrom(t, typeof(DynValue[]))) + else if (t.IsAssignableFrom(typeof(DynValue[]))) return TableToList(table, v => v).ToArray(); - if (Framework.Do.IsGenericType(t)) + if (t.IsGenericType) { Type generic = t.GetGenericTypeDefinition(); @@ -110,12 +109,12 @@ internal static object ConvertTableToType(Table table, Type t) || (generic == typeof(ICollection<>)) || (generic == typeof(IEnumerable<>))) { - return ConvertTableToListOfGenericType(t, Framework.Do.GetGenericArguments(t)[0], table); + return ConvertTableToListOfGenericType(t, t.GetGenericArguments()[0], table); } else if ((generic == typeof(Dictionary<,>)) || (generic == typeof(IDictionary<,>))) { - return ConvertTableToDictionaryOfGenericType(t, Framework.Do.GetGenericArguments(t)[0], Framework.Do.GetGenericArguments(t)[1], table); + return ConvertTableToDictionaryOfGenericType(t, t.GetGenericArguments()[0], t.GetGenericArguments()[1], table); } } diff --git a/src/MoonSharp.Interpreter/Interop/DescriptorHelpers.cs b/src/MoonSharp.Interpreter/Interop/DescriptorHelpers.cs index 9bf7c402..07f9f494 100755 --- a/src/MoonSharp.Interpreter/Interop/DescriptorHelpers.cs +++ b/src/MoonSharp.Interpreter/Interop/DescriptorHelpers.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Reflection; using System.Text; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop { @@ -44,7 +43,7 @@ public static class DescriptorHelpers public static bool IsDelegateType(this Type t) { - return Framework.Do.IsAssignableFrom(typeof(Delegate), t); + return typeof(Delegate).IsAssignableFrom(t); } /// @@ -52,11 +51,7 @@ public static bool IsDelegateType(this Type t) /// public static string GetClrVisibility(this Type type) { -#if NETFX_CORE - var t = type.GetTypeInfo(); -#else Type t = type; -#endif if (t.IsPublic || t.IsNestedPublic) return "public"; if ((t.IsNotPublic && (!t.IsNested)) || (t.IsNestedAssembly)) @@ -94,8 +89,8 @@ public static string GetClrVisibility(this FieldInfo info) /// public static string GetClrVisibility(this PropertyInfo info) { - MethodInfo gm = Framework.Do.GetGetMethod(info); - MethodInfo sm = Framework.Do.GetSetMethod(info); + MethodInfo gm = info.GetGetMethod(true); + MethodInfo sm = info.GetSetMethod(true); string gv = (gm != null) ? GetClrVisibility(gm) : "private"; string sv = (sm != null) ? GetClrVisibility(sm) : "private"; @@ -137,8 +132,8 @@ public static string GetClrVisibility(this MethodBase info) /// public static bool IsPropertyInfoPublic(this PropertyInfo pi) { - MethodInfo getter = Framework.Do.GetGetMethod(pi); - MethodInfo setter = Framework.Do.GetSetMethod(pi); + MethodInfo getter = pi.GetGetMethod(true); + MethodInfo setter = pi.GetSetMethod(true); return (getter != null && getter.IsPublic) || (setter != null && setter.IsPublic); } @@ -166,7 +161,7 @@ public static Type[] SafeGetTypes(this Assembly asm) { try { - return Framework.Do.GetAssemblyTypes(asm); + return asm.GetTypes(); } catch (ReflectionTypeLoadException) { @@ -200,10 +195,12 @@ public static string GetConversionMethodName(this Type type) /// public static IEnumerable GetAllImplementedTypes(this Type t) { - for (Type ot = t; ot != null; ot = Framework.Do.GetBaseType(ot)) + for (Type ot = t; ot != null; ot = t.BaseType) { yield return ot; + if (ot == typeof(object)) break; + } - foreach (Type it in Framework.Do.GetInterfaces(t)) + foreach (Type it in t.GetInterfaces()) yield return it; } diff --git a/src/MoonSharp.Interpreter/Interop/LuaStateInterop/LuaBase.cs b/src/MoonSharp.Interpreter/Interop/LuaStateInterop/LuaBase.cs index e62ff92b..1bc2bb2a 100644 --- a/src/MoonSharp.Interpreter/Interop/LuaStateInterop/LuaBase.cs +++ b/src/MoonSharp.Interpreter/Interop/LuaStateInterop/LuaBase.cs @@ -76,10 +76,10 @@ protected static lua_Integer LuaType(LuaState L, lua_Integer p) } } - protected static string LuaLCheckLString(LuaState L, lua_Integer argNum, out uint l) + protected static string LuaLCheckLString(LuaState L, lua_Integer argNum, out uint l, bool allowNil = false) { - string str = ArgAsType(L, argNum, DataType.String, false).String; - l = (uint)str.Length; + string str = ArgAsType(L, argNum, DataType.String, allowNil).String; + l = (uint)(str?.Length ?? 0); return str; } diff --git a/src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs b/src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs index 4a9b36fd..2bef6ad4 100755 --- a/src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs +++ b/src/MoonSharp.Interpreter/Interop/LuaStateInterop/Tools.cs @@ -566,11 +566,7 @@ public static string sprintf(string Format, params object[] Parameters) #region p - pointer case 'p': // pointer if (o is IntPtr) -#if PCL || ENABLE_DOTNET - w = ( (IntPtr)o ).ToString(); -#else w = "0x" + ((IntPtr)o).ToString("x"); -#endif defaultParamIx++; break; #endregion diff --git a/src/MoonSharp.Interpreter/Interop/PredefinedUserData/EnumerableWrapper.cs b/src/MoonSharp.Interpreter/Interop/PredefinedUserData/EnumerableWrapper.cs index 6accf2ad..2d8e18d4 100644 --- a/src/MoonSharp.Interpreter/Interop/PredefinedUserData/EnumerableWrapper.cs +++ b/src/MoonSharp.Interpreter/Interop/PredefinedUserData/EnumerableWrapper.cs @@ -57,7 +57,7 @@ internal static DynValue ConvertIterator(Script script, IEnumerator enumerator) internal static DynValue ConvertTable(Table table) { - return ConvertIterator(table.OwnerScript, table.Values.GetEnumerator()); + return ConvertIterator(table.OwnerScript, table.ReversePair.GetEnumerator()); } @@ -80,7 +80,7 @@ public DynValue Index(Script script, DynValue index, bool isDirectIndexing) return DynValue.NewCallback((ctx, args) => { Reset(); return DynValue.Nil; }); } } - return null; + return DynValue.Nil; } public bool SetIndex(Script script, DynValue index, DynValue value, bool isDirectIndexing) @@ -93,7 +93,7 @@ public DynValue MetaIndex(Script script, string metaname) if (metaname == "__call") return DynValue.NewCallback(LuaIteratorCallback); else - return null; + return DynValue.Nil; } } } diff --git a/src/MoonSharp.Interpreter/Interop/PredefinedUserData/TaskWrapper.cs b/src/MoonSharp.Interpreter/Interop/PredefinedUserData/TaskWrapper.cs new file mode 100644 index 00000000..eb8d13f6 --- /dev/null +++ b/src/MoonSharp.Interpreter/Interop/PredefinedUserData/TaskWrapper.cs @@ -0,0 +1,51 @@ +using System; +using System.Reflection; +using System.Threading.Tasks; +using MoonSharp.Interpreter.Interop.Converters; + +namespace MoonSharp.Interpreter.Interop +{ + internal class TaskWrapper + { + internal Task Task; + private bool waited = false; + + public TaskWrapper(Task task) + { + Task = task; + } + + public static DynValue TaskResultToDynValue(Script script, Task task) + { + var voidTaskType = typeof (Task<>).MakeGenericType(Type.GetType("System.Threading.Tasks.VoidTaskResult")); + if (voidTaskType.IsAssignableFrom(task.GetType())) + { + return DynValue.Nil; //no return type + } + var property = task.GetType().GetProperty("Result", BindingFlags.Public | BindingFlags.Instance); + if (property == null) + return DynValue.Nil; + return ClrToScriptConversions.ObjectToDynValue(script, property.GetValue(task)); + } + + public DynValue isblocking(ScriptExecutionContext executionContext, CallbackArguments args) + { + return DynValue.NewBoolean(!executionContext.CanAwait); + } + + public DynValue await(ScriptExecutionContext executionContext, CallbackArguments args) + { + if (!waited) { + waited = true; + if (executionContext.CanAwait) { + return DynValue.NewAwaitReq(Task); + } + else { + Task.Wait(); + } + } + if (Task.Exception != null) throw Task.Exception; + return TaskResultToDynValue(executionContext.OwnerScript, Task); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Interop/PropertyTableAssigner.cs b/src/MoonSharp.Interpreter/Interop/PropertyTableAssigner.cs index bf87b3d6..05db78ba 100644 --- a/src/MoonSharp.Interpreter/Interop/PropertyTableAssigner.cs +++ b/src/MoonSharp.Interpreter/Interop/PropertyTableAssigner.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; +using System.Runtime; namespace MoonSharp.Interpreter.Interop { @@ -111,7 +111,7 @@ public PropertyTableAssigner(Type type, params string[] expectedMissingPropertie { m_Type = type; - if (Framework.Do.IsValueType(m_Type)) + if (m_Type.IsValueType) throw new ArgumentException("Type cannot be a value type."); foreach(string property in expectedMissingProperties) @@ -119,7 +119,7 @@ public PropertyTableAssigner(Type type, params string[] expectedMissingPropertie m_PropertyMap.Add(property, null); } - foreach (PropertyInfo pi in Framework.Do.GetProperties(m_Type)) + foreach (PropertyInfo pi in m_Type.GetAllProperties()) { foreach (MoonSharpPropertyAttribute attr in pi.GetCustomAttributes(true).OfType()) { @@ -170,7 +170,7 @@ private bool TryAssignProperty(object obj, string name, DynValue value) pi.PropertyType, null, false); } - Framework.Do.GetSetMethod(pi).Invoke(obj, new object[] { o }); + pi.GetSetMethod(true).Invoke(obj, new object[] { o }); } return true; @@ -202,7 +202,7 @@ public void AssignObject(object obj, Table data) if (obj == null) throw new ArgumentNullException("Object is null"); - if (!Framework.Do.IsInstanceOfType(m_Type, obj)) + if (!m_Type.IsInstanceOfType(obj)) throw new ArgumentException(string.Format("Invalid type of object : got '{0}', expected {1}", obj.GetType().FullName, m_Type.FullName)); foreach (var pair in data.Pairs) @@ -223,10 +223,10 @@ public void AssignObject(object obj, Table data) /// The property assigner. public void SetSubassignerForType(Type propertyType, IPropertyTableAssigner assigner) { - if ( Framework.Do.IsAbstract(propertyType) - || Framework.Do.IsGenericType(propertyType) - || Framework.Do.IsInterface(propertyType) - || Framework.Do.IsValueType(propertyType)) + if ( propertyType.IsAbstract + || propertyType.IsGenericType + || propertyType.IsInterface + || propertyType.IsValueType) { throw new ArgumentException("propertyType must be a concrete, reference type"); } diff --git a/src/MoonSharp.Interpreter/Interop/ReflectionExtensions.cs b/src/MoonSharp.Interpreter/Interop/ReflectionExtensions.cs new file mode 100644 index 00000000..daca3d65 --- /dev/null +++ b/src/MoonSharp.Interpreter/Interop/ReflectionExtensions.cs @@ -0,0 +1,35 @@ +using System; +using System.Reflection; + +namespace MoonSharp.Interpreter.Interop +{ + static class ReflectionExtensions + { + const BindingFlags BINDINGFLAGS_MEMBER = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; + + public static ConstructorInfo[] GetAllConstructors(this Type type) + { + return type.GetConstructors(BINDINGFLAGS_MEMBER); + } + + public static EventInfo[] GetAllEvents(this Type type) + { + return type.GetEvents(BINDINGFLAGS_MEMBER); + } + + public static FieldInfo[] GetAllFields(this Type type) + { + return type.GetFields(BINDINGFLAGS_MEMBER); + } + + public static MethodInfo[] GetAllMethods(this Type type) + { + return type.GetMethods(BINDINGFLAGS_MEMBER); + } + + public static PropertyInfo[] GetAllProperties(this Type type) + { + return type.GetProperties(BINDINGFLAGS_MEMBER); + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs index c9392485..2d282434 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs @@ -1,5 +1,4 @@ using System; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop; namespace MoonSharp.Interpreter @@ -7,7 +6,7 @@ namespace MoonSharp.Interpreter /// /// Descriptor which acts as a non-containing adapter from IUserDataType to IUserDataDescriptor /// - internal class AutoDescribingUserDataDescriptor : IUserDataDescriptor + public class AutoDescribingUserDataDescriptor : IUserDataDescriptor { private string m_FriendlyName; private Type m_Type; @@ -54,7 +53,7 @@ public DynValue Index(Script script, object obj, DynValue index, bool isDirectIn if (u != null) return u.Index(script, index, isDirectIndexing); - return null; + return DynValue.Nil; } /// @@ -110,7 +109,7 @@ public DynValue MetaIndex(Script script, object obj, string metaname) if (u != null) return u.MetaIndex(script, metaname); - return null; + return DynValue.Nil; } @@ -124,7 +123,7 @@ public DynValue MetaIndex(Script script, object obj, string metaname) /// public bool IsTypeCompatible(Type type, object obj) { - return Framework.Do.IsInstanceOfType(type, obj); + return type.IsInstanceOfType(obj); } } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs index a7e1a528..26c9f41b 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop { @@ -66,10 +65,10 @@ public DynValue Index(Script script, object obj, DynValue index, bool isNameInde { DynValue v = dd.Index(script, obj, index, isNameIndex); - if (v != null) + if (v.IsNotNil()) return v; } - return null; + return DynValue.Nil; } /// @@ -122,10 +121,10 @@ public DynValue MetaIndex(Script script, object obj, string metaname) { DynValue v = dd.MetaIndex(script, obj, metaname); - if (v != null) + if (v.IsNotNil()) return v; } - return null; + return DynValue.Nil; } @@ -139,7 +138,7 @@ public DynValue MetaIndex(Script script, object obj, string metaname) /// public bool IsTypeCompatible(Type type, object obj) { - return Framework.Do.IsInstanceOfType(type, obj); + return type.IsInstanceOfType(obj); } } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/EventFacade.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/EventFacade.cs index 6b9d98b8..6c19c417 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/EventFacade.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/EventFacade.cs @@ -45,7 +45,7 @@ public bool SetIndex(Script script, DynValue index, DynValue value, bool isDirec public DynValue MetaIndex(Script script, string metaname) { - return null; + return DynValue.Nil; } } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs index a12f7fd0..eede96e8 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs @@ -32,7 +32,7 @@ protected DynValueMemberDescriptor(string name, string serializedTableValue) protected DynValueMemberDescriptor(string name) { MemberAccess = MemberDescriptorAccess.CanRead; - m_Value = null; + m_Value = DynValue.Nil; Name = name; } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs index 74af1b11..6c1b5753 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -180,7 +179,7 @@ protected virtual object[] BuildArgumentList(Script script, object obj, ScriptEx { DynValue arg = args.RawGet(j, false); j += 1; - if (arg != null) + if (arg.IsNotNil()) extraArgs.Add(arg); else break; @@ -195,7 +194,7 @@ protected virtual object[] BuildArgumentList(Script script, object obj, ScriptEx if (arg.Type == DataType.UserData && arg.UserData.Object != null) { - if (Framework.Do.IsAssignableFrom(VarArgsArrayType, arg.UserData.Object.GetType())) + if (VarArgsArrayType.IsAssignableFrom(arg.UserData.Object.GetType())) { pars[i] = arg.UserData.Object; continue; @@ -218,7 +217,7 @@ protected virtual object[] BuildArgumentList(Script script, object obj, ScriptEx // else, convert it else { - var arg = args.RawGet(j, false) ?? DynValue.Void; + var arg = args.RawGet(j, false); pars[i] = ScriptToClrConversions.DynValueToObjectOfType(arg, parameters[i].Type, parameters[i].DefaultValue, parameters[i].HasDefaultValue); j += 1; diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs index 8485bc60..649a8f91 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs @@ -1,5 +1,4 @@ using System; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop { @@ -119,7 +118,7 @@ public DynValue MetaIndex(Script script, object obj, string metaname) /// public bool IsTypeCompatible(Type type, object obj) { - return Framework.Do.IsInstanceOfType(type, obj); + return type.IsInstanceOfType(obj); } } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs index 3a19cbe5..6343d188 100755 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.StandardDescriptors; @@ -37,8 +36,8 @@ public static EventMemberDescriptor TryCreateIfVisible(EventInfo ei, InteropAcce if (!CheckEventIsCompatible(ei, false)) return null; - MethodInfo addm = Framework.Do.GetAddMethod(ei); - MethodInfo remm = Framework.Do.GetRemoveMethod(ei); + MethodInfo addm = ei.GetAddMethod(); + MethodInfo remm = ei.GetRemoveMethod(); if (ei.GetVisibilityFromAttributes() ?? ((remm != null && remm.IsPublic) && (addm != null && addm.IsPublic))) return new EventMemberDescriptor(ei, accessMode); @@ -71,19 +70,19 @@ public static EventMemberDescriptor TryCreateIfVisible(EventInfo ei, InteropAcce /// public static bool CheckEventIsCompatible(EventInfo ei, bool throwException) { - if (Framework.Do.IsValueType(ei.DeclaringType)) + if (ei.DeclaringType.IsValueType) { if (throwException) throw new ArgumentException("Events are not supported on value types"); return false; } - if ((Framework.Do.GetAddMethod(ei) == null) || (Framework.Do.GetRemoveMethod(ei) == null)) + if ((ei.GetAddMethod() == null) || (ei.GetRemoveMethod() == null)) { if (throwException) throw new ArgumentException("Event must have add and remove methods"); return false; } - MethodInfo invoke = Framework.Do.GetMethod(ei.EventHandlerType, "Invoke"); + MethodInfo invoke = ei.EventHandlerType.GetMethod("Invoke"); if (invoke == null) { @@ -110,7 +109,7 @@ public static bool CheckEventIsCompatible(EventInfo ei, bool throwException) foreach (ParameterInfo pi in pars) { - if (Framework.Do.IsValueType(pi.ParameterType)) + if (pi.ParameterType.IsValueType) { if (throwException) throw new ArgumentException("Event handler cannot have value type parameters"); return false; @@ -135,8 +134,8 @@ public EventMemberDescriptor(EventInfo ei, InteropAccessMode accessMode = Intero { CheckEventIsCompatible(ei, true); EventInfo = ei; - m_Add = Framework.Do.GetAddMethod(ei); - m_Remove = Framework.Do.GetRemoveMethod(ei); + m_Add = ei.GetAddMethod(); + m_Remove = ei.GetRemoveMethod(); IsStatic = m_Add.IsStatic; } @@ -203,11 +202,7 @@ private void RegisterCallback(object o) m_Delegates.GetOrCreate(o, () => { Delegate d = CreateDelegate(o); -#if NETFX_CORE - Delegate handler = d.GetMethodInfo().CreateDelegate(EventInfo.EventHandlerType, d.Target); -#else Delegate handler = Delegate.CreateDelegate(EventInfo.EventHandlerType, d.Target, d.Method); -#endif m_Add.Invoke(o, new object[] { handler }); return handler; }); @@ -227,7 +222,7 @@ private void UnregisterCallback(object o) private Delegate CreateDelegate(object sender) { - switch (Framework.Do.GetMethod(EventInfo.EventHandlerType, "Invoke").GetParameters().Length) + switch (EventInfo.EventHandlerType.GetMethod("Invoke").GetParameters().Length) { case 0: return (EventWrapper00)(() => DispatchEvent(sender)); diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs index 9b08de21..cec0f656 100755 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs @@ -2,7 +2,6 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -179,12 +178,10 @@ public void SetValue(Script script, object obj, DynValue v) // optimized setters fall here throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType); } -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) catch (FieldAccessException ex) { throw new ScriptRuntimeException(ex); } -#endif } @@ -223,7 +220,7 @@ public void PrepareForWiring(Table t) t.Set("const", DynValue.NewBoolean(this.IsConst)); t.Set("readonly", DynValue.NewBoolean(this.IsReadonly)); t.Set("decltype", DynValue.NewString(this.FieldInfo.DeclaringType.FullName)); - t.Set("declvtype", DynValue.NewBoolean(Framework.Do.IsValueType(this.FieldInfo.DeclaringType))); + t.Set("declvtype", DynValue.NewBoolean(this.FieldInfo.DeclaringType.IsValueType)); t.Set("type", DynValue.NewString(this.FieldInfo.FieldType.FullName)); t.Set("read", DynValue.NewBoolean(true)); t.Set("write", DynValue.NewBoolean(!(this.IsConst || this.IsReadonly))); diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs index f9280ba7..9901da74 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs @@ -5,7 +5,6 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; @@ -156,7 +155,7 @@ public static bool CheckMethodIsCompatible(MethodBase methodBase, bool throwExce return false; } - if (Framework.Do.IsGenericTypeDefinition(mi.ReturnType)) + if (mi.ReturnType.IsGenericTypeDefinition) { if (throwException) throw new ArgumentException("Method cannot have an unresolved generic return type"); return false; diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs index c1ad734c..2a4f7eb7 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -325,16 +324,16 @@ private int CalcScoreForOverload(ScriptExecutionContext context, CallbackArgumen if (i == method.Parameters.Length - 1 && method.VarArgsArrayType != null) { int varargCnt = 0; - DynValue firstArg = null; + DynValue firstArg = DynValue.Nil; int scoreBeforeVargars = totalScore; // update score for varargs while (true) { var arg = args.RawGet(argsCnt, false); - if (arg == null) break; + if (arg.IsNil()) break; - if (firstArg == null) firstArg = arg; + if (firstArg.IsNil()) firstArg = arg; argsCnt += 1; @@ -349,7 +348,7 @@ private int CalcScoreForOverload(ScriptExecutionContext context, CallbackArgumen { if (firstArg.Type == DataType.UserData && firstArg.UserData.Object != null) { - if (Framework.Do.IsAssignableFrom(method.VarArgsArrayType, firstArg.UserData.Object.GetType())) + if (method.VarArgsArrayType.IsAssignableFrom(firstArg.UserData.Object.GetType())) { totalScore = scoreBeforeVargars; continue; @@ -365,7 +364,7 @@ private int CalcScoreForOverload(ScriptExecutionContext context, CallbackArgumen } else { - var arg = args.RawGet(argsCnt, false) ?? DynValue.Void; + var arg = args.RawGet(argsCnt, false); int score = CalcScoreForSingleArgument(method.Parameters[i], parameterType, arg, method.Parameters[i].HasDefaultValue); diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs index 618ee3cc..3477cdb4 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs @@ -2,7 +2,6 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -61,8 +60,8 @@ public class PropertyMemberDescriptor : IMemberDescriptor, IOptimizableDescripto /// A new StandardUserDataPropertyDescriptor or null. public static PropertyMemberDescriptor TryCreateIfVisible(PropertyInfo pi, InteropAccessMode accessMode) { - MethodInfo getter = Framework.Do.GetGetMethod(pi); - MethodInfo setter = Framework.Do.GetSetMethod(pi); + MethodInfo getter = pi.GetGetMethod(true); + MethodInfo setter = pi.GetSetMethod(true); bool? pvisible = pi.GetVisibilityFromAttributes(); bool? gvisible = getter.GetVisibilityFromAttributes(); @@ -99,7 +98,7 @@ private static PropertyMemberDescriptor TryCreate(PropertyInfo pi, InteropAccess /// The pi. /// The access mode. public PropertyMemberDescriptor(PropertyInfo pi, InteropAccessMode accessMode) - : this(pi, accessMode, Framework.Do.GetGetMethod(pi), Framework.Do.GetSetMethod(pi)) + : this(pi, accessMode, pi.GetGetMethod(true), pi.GetSetMethod(true)) { } @@ -192,9 +191,9 @@ internal void OptimizeSetter() { using (PerformanceStatistics.StartGlobalStopwatch(PerformanceCounter.AdaptersCompilation)) { - if (m_Setter != null && !(Framework.Do.IsValueType(PropertyInfo.DeclaringType))) + if (m_Setter != null && !PropertyInfo.DeclaringType.IsValueType) { - MethodInfo setterMethod = Framework.Do.GetSetMethod(PropertyInfo); + MethodInfo setterMethod = PropertyInfo.GetSetMethod(true); if (IsStatic) { @@ -303,7 +302,7 @@ public void PrepareForWiring(Table t) t.Set("read", DynValue.NewBoolean(this.CanRead)); t.Set("write", DynValue.NewBoolean(this.CanWrite)); t.Set("decltype", DynValue.NewString(this.PropertyInfo.DeclaringType.FullName)); - t.Set("declvtype", DynValue.NewBoolean(Framework.Do.IsValueType(this.PropertyInfo.DeclaringType))); + t.Set("declvtype", DynValue.NewBoolean(this.PropertyInfo.DeclaringType.IsValueType)); t.Set("type", DynValue.NewString(this.PropertyInfo.PropertyType.FullName)); } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs index 7001eac6..4bcf2017 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs @@ -1,5 +1,4 @@ using System; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -66,7 +65,7 @@ public Type VarArgsElementType /// valueType is not a value type public ValueTypeDefaultCtorMemberDescriptor(Type valueType) { - if (!Framework.Do.IsValueType(valueType)) + if (!valueType.IsValueType) throw new ArgumentException("valueType is not a value type"); this.Name = "__new"; diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs index 9f8c2e20..c7b4c2f9 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; namespace MoonSharp.Interpreter.Interop @@ -38,7 +37,7 @@ public StandardEnumUserDataDescriptor(Type enumType, string friendlyName = null, string[] names = null, object[] values = null, Type underlyingType = null) : base(enumType, friendlyName) { - if (!Framework.Do.IsEnum(enumType)) + if (!enumType.IsEnum) throw new ArgumentException("enumType must be an enum!"); UnderlyingType = underlyingType ?? Enum.GetUnderlyingType(enumType); @@ -65,7 +64,7 @@ private void FillMemberList(string[] names, object[] values) base.AddDynValue(name, cvalue); } - var attrs = Framework.Do.GetCustomAttributes(this.Type, typeof(FlagsAttribute), true); + var attrs = this.Type.GetCustomAttributes(typeof(FlagsAttribute), true); if (attrs != null && attrs.Length > 0) { @@ -335,7 +334,7 @@ public override DynValue MetaIndex(Script script, object obj, string metaname) if (metaname == "__concat" && IsFlags) return DynValue.NewCallback(Callback_Or); - return null; + return DynValue.Nil; } } } diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs index 112e406c..fd5983a2 100644 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs @@ -1,5 +1,4 @@ using System; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Interop { @@ -39,7 +38,7 @@ public StandardGenericsUserDataDescriptor(Type type, InteropAccessMode accessMod /// public DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing) { - return null; + return DynValue.Nil; } /// @@ -57,13 +56,13 @@ public string AsString(object obj) /// public DynValue MetaIndex(Script script, object obj, string metaname) { - return null; + return DynValue.Nil; } /// public bool IsTypeCompatible(Type type, object obj) { - return Framework.Do.IsInstanceOfType(type, obj); + return type.IsInstanceOfType(obj); } /// @@ -72,7 +71,7 @@ public IUserDataDescriptor Generate(Type type) if (UserData.IsTypeRegistered(type)) return null; - if (Framework.Do.IsGenericTypeDefinition(type)) + if (type.IsGenericTypeDefinition) return null; return UserData.RegisterType(type, AccessMode); diff --git a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs index 6eece605..9ede8fbe 100755 --- a/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; namespace MoonSharp.Interpreter.Interop @@ -46,7 +45,7 @@ public StandardUserDataDescriptor(Type type, InteropAccessMode accessMode, strin private void FillMemberList() { HashSet membersToIgnore = new HashSet( - Framework.Do.GetCustomAttributes(this.Type, typeof(MoonSharpHideMemberAttribute), true) + this.Type.GetCustomAttributes( typeof(MoonSharpHideMemberAttribute), true) .OfType() .Select(a => a.MemberName) ); @@ -59,7 +58,7 @@ private void FillMemberList() if (!type.IsDelegateType()) { // add declared constructors - foreach (ConstructorInfo ci in Framework.Do.GetConstructors(type)) + foreach (ConstructorInfo ci in type.GetAllConstructors()) { if (membersToIgnore.Contains("__new")) continue; @@ -68,13 +67,13 @@ private void FillMemberList() } // valuetypes don't reflect their empty ctor.. actually empty ctors are a perversion, we don't care and implement ours - if (Framework.Do.IsValueType(type) && !membersToIgnore.Contains("__new")) + if (type.IsValueType && !membersToIgnore.Contains("__new")) AddMember("__new", new ValueTypeDefaultCtorMemberDescriptor(type)); } // add methods to method list and metamethods - foreach (MethodInfo mi in Framework.Do.GetMethods(type)) + foreach (MethodInfo mi in type.GetAllMethods()) { if (membersToIgnore.Contains(mi.Name)) continue; @@ -102,7 +101,7 @@ private void FillMemberList() } // get properties - foreach (PropertyInfo pi in Framework.Do.GetProperties(type)) + foreach (PropertyInfo pi in type.GetAllProperties()) { if (pi.IsSpecialName || pi.GetIndexParameters().Any() || membersToIgnore.Contains(pi.Name)) continue; @@ -111,7 +110,7 @@ private void FillMemberList() } // get fields - foreach (FieldInfo fi in Framework.Do.GetFields(type)) + foreach (FieldInfo fi in type.GetAllFields()) { if (fi.IsSpecialName || membersToIgnore.Contains(fi.Name)) continue; @@ -120,7 +119,7 @@ private void FillMemberList() } // get events - foreach (EventInfo ei in Framework.Do.GetEvents(type)) + foreach (EventInfo ei in type.GetAllEvents()) { if (ei.IsSpecialName || membersToIgnore.Contains(ei.Name)) continue; @@ -129,14 +128,14 @@ private void FillMemberList() } // get nested types and create statics - foreach (Type nestedType in Framework.Do.GetNestedTypes(type)) + foreach (Type nestedType in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)) { if (membersToIgnore.Contains(nestedType.Name)) continue; - if (!Framework.Do.IsGenericTypeDefinition(nestedType)) + if (!nestedType.IsGenericTypeDefinition) { - if (Framework.Do.IsNestedPublic(nestedType) || Framework.Do.GetCustomAttributes(nestedType, typeof(MoonSharpUserDataAttribute), true).Length > 0) + if (nestedType.IsNestedPublic || nestedType.GetCustomAttributes(typeof(MoonSharpUserDataAttribute), true).Length > 0) { var descr = UserData.RegisterType(nestedType, this.AccessMode); @@ -176,7 +175,7 @@ private void FillMemberList() public void PrepareForWiring(Table t) { - if (AccessMode == InteropAccessMode.HideMembers || Framework.Do.GetAssembly(Type) == Framework.Do.GetAssembly(this.GetType())) + if (AccessMode == InteropAccessMode.HideMembers || Type.Assembly == this.GetType().Assembly) { t.Set("skip", DynValue.NewBoolean(true)); } diff --git a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs index 24faf665..03c43825 100755 --- a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs +++ b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Interop.BasicDescriptors; @@ -43,7 +42,7 @@ public static void RegisterExtensionType(Type type, InteropAccessMode mode = Int { bool changesDone = false; - foreach (MethodInfo mi in Framework.Do.GetMethods(type).Where(_mi => _mi.IsStatic)) + foreach (MethodInfo mi in type.GetAllMethods().Where(_mi => _mi.IsStatic)) { if (mi.GetCustomAttributes(typeof(ExtensionAttribute), false).Count() == 0) continue; @@ -68,11 +67,7 @@ public static void RegisterExtensionType(Type type, InteropAccessMode mode = Int ++s_ExtensionMethodChangeVersion; } } - - private static object FrameworkGetMethods() - { - throw new NotImplementedException(); - } + /// /// Gets all the extension methods which can match a given name @@ -139,14 +134,14 @@ public static List GetExtensionMethodsByNameAndTy } return s_Registry.Find(name) - .Where(d => d.ExtensionMethodType != null && Framework.Do.IsAssignableFrom(d.ExtensionMethodType, extendedType)) + .Where(d => d.ExtensionMethodType != null && d.ExtensionMethodType.IsAssignableFrom(extendedType)) .ToList(); } private static MethodInfo InstantiateMethodInfo(MethodInfo mi, Type extensionType, Type genericType, Type extendedType) { Type[] defs = mi.GetGenericArguments(); - Type[] tdefs = Framework.Do.GetGenericArguments(genericType); + Type[] tdefs = genericType.GetGenericArguments(); if (tdefs.Length == defs.Length) { @@ -164,7 +159,7 @@ private static Type GetGenericMatch(Type extensionType, Type extendedType) foreach (Type t in extendedType.GetAllImplementedTypes()) { - if (Framework.Do.IsGenericType(t) && t.GetGenericTypeDefinition() == extensionType) + if (t.IsGenericType && t.GetGenericTypeDefinition() == extensionType) { return t; } diff --git a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs index 945fbc88..9ec93738 100755 --- a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs +++ b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs @@ -4,7 +4,6 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.RegistrationPolicies; @@ -29,17 +28,13 @@ internal static void RegisterAssembly(Assembly asm = null, bool includeExtension { if (asm == null) { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif + asm = Assembly.GetCallingAssembly(); } if (includeExtensionTypes) { var extensionTypes = from t in asm.SafeGetTypes() - let attributes = Framework.Do.GetCustomAttributes(t, typeof(ExtensionAttribute), true) + let attributes = t.GetCustomAttributes(typeof(ExtensionAttribute), true) where attributes != null && attributes.Length > 0 select new { Attributes = attributes, DataType = t }; @@ -51,7 +46,7 @@ internal static void RegisterAssembly(Assembly asm = null, bool includeExtension var userDataTypes = from t in asm.SafeGetTypes() - let attributes = Framework.Do.GetCustomAttributes(t, typeof(MoonSharpUserDataAttribute), true) + let attributes = t.GetCustomAttributes(typeof(MoonSharpUserDataAttribute), true) where attributes != null && attributes.Length > 0 select new { Attributes = attributes, DataType = t }; @@ -152,17 +147,17 @@ internal static IUserDataDescriptor RegisterType_Impl(Type type, InteropAccessMo if (IsTypeBlacklisted(type)) return null; - if (Framework.Do.GetInterfaces(type).Any(ii => ii == typeof(IUserDataType))) + if (type.GetInterfaces().Any(ii => ii == typeof(IUserDataType))) { AutoDescribingUserDataDescriptor audd = new AutoDescribingUserDataDescriptor(type, friendlyName); return PerformRegistration(type, audd, oldDescriptor); } - else if (Framework.Do.IsGenericTypeDefinition(type)) + else if (type.IsGenericTypeDefinition) { StandardGenericsUserDataDescriptor typeGen = new StandardGenericsUserDataDescriptor(type, accessMode); return PerformRegistration(type, typeGen, oldDescriptor); } - else if (Framework.Do.IsEnum(type)) + else if (type.IsEnum) { var enumDescr = new StandardEnumUserDataDescriptor(type, friendlyName); return PerformRegistration(type, enumDescr, oldDescriptor); @@ -173,11 +168,7 @@ internal static IUserDataDescriptor RegisterType_Impl(Type type, InteropAccessMo if (accessMode == InteropAccessMode.BackgroundOptimized) { -#if NETFX_CORE - System.Threading.Tasks.Task.Run(() => ((IOptimizableDescriptor)udd).Optimize()); -#else ThreadPool.QueueUserWorkItem(o => ((IOptimizableDescriptor)udd).Optimize()); -#endif } return PerformRegistration(type, udd, oldDescriptor); @@ -221,7 +212,7 @@ internal static InteropAccessMode ResolveDefaultAccessModeForType(InteropAccessM { if (accessMode == InteropAccessMode.Default) { - MoonSharpUserDataAttribute attr = Framework.Do.GetCustomAttributes(type, true).OfType() + MoonSharpUserDataAttribute attr = type.GetCustomAttributes(true).OfType() .SingleOrDefault(); if (attr != null) @@ -256,14 +247,14 @@ internal static IUserDataDescriptor GetDescriptorForType(Type type, bool searchI if (RegistrationPolicy.AllowTypeAutoRegistration(type)) { // no autoreg of delegates - if (!Framework.Do.IsAssignableFrom((typeof(Delegate)), type)) + if (!typeof(Delegate).IsAssignableFrom(type)) { return RegisterType_Impl(type, DefaultAccessMode, type.FullName, null); } } // search for the base object descriptors - for (Type t = type; t != null; t = Framework.Do.GetBaseType(t)) + for (Type t = type; t != null; t = t.BaseType) { IUserDataDescriptor u; @@ -272,7 +263,7 @@ internal static IUserDataDescriptor GetDescriptorForType(Type type, bool searchI typeDescriptor = u; break; } - else if (Framework.Do.IsGenericType(t)) + else if (t.IsGenericType) { if (s_TypeRegistry.TryGetValue(t.GetGenericTypeDefinition(), out u)) { @@ -298,7 +289,7 @@ internal static IUserDataDescriptor GetDescriptorForType(Type type, bool searchI if (searchInterfaces) { - foreach (Type interfaceType in Framework.Do.GetInterfaces(type)) + foreach (Type interfaceType in type.GetInterfaces()) { IUserDataDescriptor interfaceDescriptor; @@ -310,7 +301,7 @@ internal static IUserDataDescriptor GetDescriptorForType(Type type, bool searchI if (interfaceDescriptor != null) descriptors.Add(interfaceDescriptor); } - else if (Framework.Do.IsGenericType(interfaceType)) + else if (interfaceType.IsGenericType) { if (s_TypeRegistry.TryGetValue(interfaceType.GetGenericTypeDefinition(), out interfaceDescriptor)) { @@ -349,7 +340,7 @@ private static bool FrameworkIsAssignableFrom(Type type) /// public static bool IsTypeBlacklisted(Type t) { - if (Framework.Do.IsValueType(t) && Framework.Do.GetInterfaces(t).Contains(typeof(System.Collections.IEnumerator))) + if (t.IsValueType && t.GetInterfaces().Contains(typeof(System.Collections.IEnumerator))) return true; return false; diff --git a/src/MoonSharp.Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs b/src/MoonSharp.Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs index 5c76dfa1..1327e499 100644 --- a/src/MoonSharp.Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs +++ b/src/MoonSharp.Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs @@ -22,11 +22,7 @@ public EmbeddedResourcesScriptLoader(Assembly resourceAssembly = null) { if (resourceAssembly == null) { -#if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); -#else resourceAssembly = Assembly.GetCallingAssembly(); -#endif } m_ResourceAssembly = resourceAssembly; diff --git a/src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs b/src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs index 77e69eea..ea0bfde0 100755 --- a/src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs +++ b/src/MoonSharp.Interpreter/Loaders/FileSystemScriptLoader.cs @@ -1,5 +1,4 @@ -#if DOTNET_CORE || (!(PCL || ENABLE_DOTNET || NETFX_CORE)) -using System.IO; +using System.IO; namespace MoonSharp.Interpreter.Loaders { @@ -34,5 +33,4 @@ public override object LoadFile(string file, Table globalContext) return new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Loaders/ScriptLoaderBase.cs b/src/MoonSharp.Interpreter/Loaders/ScriptLoaderBase.cs index bc4e3697..0b189b4b 100644 --- a/src/MoonSharp.Interpreter/Loaders/ScriptLoaderBase.cs +++ b/src/MoonSharp.Interpreter/Loaders/ScriptLoaderBase.cs @@ -68,7 +68,7 @@ public virtual string ResolveModuleName(string modname, Table globalContext) { DynValue s = globalContext.RawGet("LUA_PATH"); - if (s != null && s.Type == DataType.String) + if (s.Type == DataType.String) return ResolveModuleName(modname, UnpackStringPaths(s.String)); } diff --git a/src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs b/src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs index 7db23081..620ad7ae 100755 --- a/src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs +++ b/src/MoonSharp.Interpreter/Loaders/UnityAssetsScriptLoader.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Loaders { @@ -80,10 +79,10 @@ void LoadResourcesWithReflection(string assetsPath) Type resourcesType = Type.GetType("UnityEngine.Resources, UnityEngine"); Type textAssetType = Type.GetType("UnityEngine.TextAsset, UnityEngine"); - MethodInfo textAssetNameGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "name")); - MethodInfo textAssetTextGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "text")); + MethodInfo textAssetNameGet = textAssetType.GetProperty("name").GetGetMethod(true); + MethodInfo textAssetTextGet = textAssetType.GetProperty("text").GetGetMethod(true); - MethodInfo loadAll = Framework.Do.GetMethod(resourcesType, "LoadAll", + MethodInfo loadAll = resourcesType.GetMethod("LoadAll", new Type[] { typeof(string), typeof(Type) }); Array array = (Array)loadAll.Invoke(null, new object[] { assetsPath, textAssetType }); diff --git a/src/MoonSharp.Interpreter/Modules/ModuleRegister.cs b/src/MoonSharp.Interpreter/Modules/ModuleRegister.cs index f2993260..8d82d0c0 100755 --- a/src/MoonSharp.Interpreter/Modules/ModuleRegister.cs +++ b/src/MoonSharp.Interpreter/Modules/ModuleRegister.cs @@ -1,9 +1,9 @@ using System; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.CoreLib; using MoonSharp.Interpreter.Platforms; +using MoonSharp.Interpreter.Interop; namespace MoonSharp.Interpreter { @@ -86,7 +86,7 @@ public static Table RegisterModuleType(this Table gtable, Type t) { Table table = CreateModuleNamespace(gtable, t); - foreach (MethodInfo mi in Framework.Do.GetMethods(t).Where(__mi => __mi.IsStatic)) + foreach (MethodInfo mi in t.GetAllMethods().Where(__mi => __mi.IsStatic)) { if (mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).ToArray().Length > 0) { @@ -95,11 +95,8 @@ public static Table RegisterModuleType(this Table gtable, Type t) if (!CallbackFunction.CheckCallbackSignature(mi, true)) throw new ArgumentException(string.Format("Method {0} does not have the right signature.", mi.Name)); -#if NETFX_CORE - Delegate deleg = mi.CreateDelegate(typeof(Func)); -#else + Delegate deleg = Delegate.CreateDelegate(typeof(Func), mi); -#endif Func func = (Func)deleg; @@ -116,7 +113,7 @@ public static Table RegisterModuleType(this Table gtable, Type t) } } - foreach (FieldInfo fi in Framework.Do.GetFields(t).Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).ToArray().Length > 0)) + foreach (FieldInfo fi in t.GetAllFields().Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).ToArray().Length > 0)) { MoonSharpModuleMethodAttribute attr = (MoonSharpModuleMethodAttribute)fi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).First(); string name = (!string.IsNullOrEmpty(attr.Name)) ? attr.Name : fi.Name; @@ -124,7 +121,7 @@ public static Table RegisterModuleType(this Table gtable, Type t) RegisterScriptField(fi, null, table, t, name); } - foreach (FieldInfo fi in Framework.Do.GetFields(t).Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleConstantAttribute), false).ToArray().Length > 0)) + foreach (FieldInfo fi in t.GetAllFields().Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleConstantAttribute), false).ToArray().Length > 0)) { MoonSharpModuleConstantAttribute attr = (MoonSharpModuleConstantAttribute)fi.GetCustomAttributes(typeof(MoonSharpModuleConstantAttribute), false).First(); string name = (!string.IsNullOrEmpty(attr.Name)) ? attr.Name : fi.Name; @@ -170,7 +167,7 @@ private static void RegisterScriptField(FieldInfo fi, object o, Table table, Typ private static Table CreateModuleNamespace(Table gtable, Type t) { - MoonSharpModuleAttribute attr = (MoonSharpModuleAttribute)(Framework.Do.GetCustomAttributes(t, typeof(MoonSharpModuleAttribute), false).First()); + MoonSharpModuleAttribute attr = (MoonSharpModuleAttribute)(t.GetCustomAttributes(typeof(MoonSharpModuleAttribute), false).First()); if (string.IsNullOrEmpty(attr.Namespace)) { @@ -195,7 +192,7 @@ private static Table CreateModuleNamespace(Table gtable, Type t) DynValue package = gtable.RawGet("package"); - if (package == null || package.Type != DataType.Table) + if (package.Type != DataType.Table) { gtable.Set("package", package = DynValue.NewTable(gtable.OwnerScript)); } @@ -203,7 +200,7 @@ private static Table CreateModuleNamespace(Table gtable, Type t) DynValue loaded = package.Table.RawGet("loaded"); - if (loaded == null || loaded.Type != DataType.Table) + if (loaded.Type != DataType.Table) { package.Table.Set("loaded", loaded = DynValue.NewTable(gtable.OwnerScript)); } diff --git a/src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj b/src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj new file mode 100644 index 00000000..c5ecdbcd --- /dev/null +++ b/src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj @@ -0,0 +1,7 @@ + + + netstandard2.0 + 8 + + + diff --git a/src/MoonSharp.Interpreter/MoonSharp.Interpreter.net35-client.csproj b/src/MoonSharp.Interpreter/MoonSharp.Interpreter.net35-client.csproj deleted file mode 100644 index ff2e9694..00000000 --- a/src/MoonSharp.Interpreter/MoonSharp.Interpreter.net35-client.csproj +++ /dev/null @@ -1,402 +0,0 @@ - - - - - Debug - AnyCPU - {91EA9B9D-FE03-4273-BDAF-8AD42EDE1E59} - Library - Properties - MoonSharp.Interpreter - MoonSharp.Interpreter - v3.5 - 512 - - - - - - - - - Client - ee6b0a8a - true - ..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - 3021, 1591 - false - - - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - false - ExtendedDesignGuidelineRules.ruleset - bin\Release\MoonSharp.Interpreter.xml - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - 3021 - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - 3021 - pdbonly - x86 - prompt - ExtendedDesignGuidelineRules.ruleset - - - true - bin\Dev\ - TRACE;DEBUG - 3021, 1591 - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Dev\ - DEBUG;TRACE - 3021 - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG - 3021, 1591 - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Devp4\ - DEBUG;TRACE - 3021 - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - Code - - - - - - - - - Code - - - - Code - - - - - - - - - - - - - - - - Code - - - Code - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - Code - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Options/ScriptSyntax.cs b/src/MoonSharp.Interpreter/Options/ScriptSyntax.cs new file mode 100644 index 00000000..2f4890e0 --- /dev/null +++ b/src/MoonSharp.Interpreter/Options/ScriptSyntax.cs @@ -0,0 +1,22 @@ +namespace MoonSharp.Interpreter +{ + /// + /// Defines the syntax used by the compiler + /// + public enum ScriptSyntax + { + /// + /// Standard Lua syntax + lambdas + /// + Lua, + /// + /// Backwards compatible C-like syntax + /// + CompatibleCLike, + /// + /// C-like syntax including breaking changes + /// e.g. ++ and -- operators + /// + CLike, + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Platforms/DotNetCorePlatformAccessor.cs b/src/MoonSharp.Interpreter/Platforms/DotNetCorePlatformAccessor.cs deleted file mode 100755 index 2671fac8..00000000 --- a/src/MoonSharp.Interpreter/Platforms/DotNetCorePlatformAccessor.cs +++ /dev/null @@ -1,218 +0,0 @@ -#if DOTNET_CORE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Class providing the IPlatformAccessor interface for .NET Core builds - /// - public class DotNetCorePlatformAccessor : PlatformAccessorBase - { - /// - /// Converts a Lua string access mode to a FileAccess enum - /// - /// The mode. - /// - public static FileAccess ParseFileAccess(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileAccess.Read; - else if (mode == "r+") - return FileAccess.ReadWrite; - else if (mode == "w") - return FileAccess.Write; - else if (mode == "w+") - return FileAccess.ReadWrite; - else - return FileAccess.ReadWrite; - } - - /// - /// Converts a Lua string access mode to a ParseFileMode enum - /// - /// The mode. - /// - public static FileMode ParseFileMode(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileMode.Open; - else if (mode == "r+") - return FileMode.OpenOrCreate; - else if (mode == "w") - return FileMode.Create; - else if (mode == "w+") - return FileMode.Truncate; - else - return FileMode.Append; - } - - - /// - /// A function used to open files in the 'io' module. - /// Can have an invalid implementation if 'io' module is filtered out. - /// It should return a correctly initialized Stream for the given file and access - /// - /// - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - return new FileStream(filename, ParseFileMode(mode), ParseFileAccess(mode), FileShare.ReadWrite | FileShare.Delete); - } - - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - public override string GetEnvironmentVariable(string envvarname) - { - return Environment.GetEnvironmentVariable(envvarname); - } - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// - /// The type. - /// - /// type - public override Stream IO_GetStandardStream(StandardFileType type) - { - switch (type) - { - case StandardFileType.StdIn: - return Console.OpenStandardInput(); - case StandardFileType.StdOut: - return Console.OpenStandardOutput(); - case StandardFileType.StdErr: - return Console.OpenStandardError(); - default: - throw new ArgumentException("type"); - } - } - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - public override void DefaultPrint(string content) - { - Console.WriteLine(content); - } - - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. - /// - /// - public override string IO_OS_GetTempFilename() - { - return Path.GetTempFileName(); - } - - /// - /// Exits the process, returning the specified exit code. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The exit code. - public override void OS_ExitFast(int exitCode) - { - Environment.Exit(exitCode); - } - - /// - /// Checks if a file exists. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - /// - /// True if the file exists, false otherwise. - /// - public override bool OS_FileExists(string file) - { - return File.Exists(file); - } - - /// - /// Deletes the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - public override void OS_FileDelete(string file) - { - File.Delete(file); - } - - /// - /// Moves the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The source. - /// The DST. - public override void OS_FileMove(string src, string dst) - { -#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - File.Move(src, dst); -#endif - } - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The cmdline. - /// - public override int OS_Execute(string cmdline) - { - // This is windows only! - throw new NotSupportedException("Not supported on .NET core"); - - //ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", string.Format("/C {0}", cmdline)); - //psi.ErrorDialog = false; - - //Process proc = Process.Start(psi); - //proc.WaitForExit(); - //return proc.ExitCode; - } - - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - return module; - } - - /// - /// Gets the platform name prefix - /// - /// - /// - public override string GetPlatformNamePrefix() - { - return "core"; - } - } -} - -#endif diff --git a/src/MoonSharp.Interpreter/Platforms/PlatformAccessorBase.cs b/src/MoonSharp.Interpreter/Platforms/PlatformAccessorBase.cs index f09c7cc5..ea44da1e 100755 --- a/src/MoonSharp.Interpreter/Platforms/PlatformAccessorBase.cs +++ b/src/MoonSharp.Interpreter/Platforms/PlatformAccessorBase.cs @@ -44,18 +44,6 @@ public string GetPlatformName() else suffix = "dotnet"; - if (PlatformAutoDetector.IsPortableFramework) - suffix = suffix + ".portable"; - - if (PlatformAutoDetector.IsRunningOnClr4) - suffix = suffix + ".clr4"; - else - suffix = suffix + ".clr2"; - -#if DOTNET_CORE - suffix += ".netcore"; -#endif - if (PlatformAutoDetector.IsRunningOnAOT) suffix = suffix + ".aot"; diff --git a/src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs b/src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs index b1765517..9d1c2699 100755 --- a/src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs +++ b/src/MoonSharp.Interpreter/Platforms/PlatformAutoDetector.cs @@ -18,26 +18,24 @@ public static class PlatformAutoDetector /// Gets a value indicating whether this instance is running on mono. /// public static bool IsRunningOnMono { get; private set; } + /// /// Gets a value indicating whether this instance is running on a CLR4 compatible implementation /// - public static bool IsRunningOnClr4 { get; private set; } + public static bool IsRunningOnClr4 { get; private set; } = true; /// /// Gets a value indicating whether this instance is running on Unity-3D /// public static bool IsRunningOnUnity { get; private set; } + /// /// Gets a value indicating whether this instance has been built as a Portable Class Library /// - public static bool IsPortableFramework { get; private set; } + public static bool IsPortableFramework { get; private set; } = false; /// /// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL). /// public static bool IsUnityNative { get; private set; } - /// - /// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP - /// - public static bool IsUnityIL2CPP { get; private set; } /// @@ -49,9 +47,6 @@ public static bool IsRunningOnAOT // We do a lazy eval here, so we can wire out this code by not calling it, if necessary.. get { -#if UNITY_WEBGL || UNITY_IOS || UNITY_TVOS || ENABLE_IL2CPP - return true; -#else if (!m_IsRunningOnAOT.HasValue) { @@ -69,7 +64,6 @@ public static bool IsRunningOnAOT } return m_IsRunningOnAOT.Value; -#endif } } @@ -77,32 +71,17 @@ private static void AutoDetectPlatformFlags() { if (m_AutoDetectionsDone) return; -#if PCL - IsPortableFramework = true; -#if ENABLE_DOTNET - IsRunningOnUnity = true; - IsUnityNative = true; -#endif -#else -#if UNITY_5 - IsRunningOnUnity = true; - IsUnityNative = true; - - #if ENABLE_IL2CPP - IsUnityIL2CPP = true; - #endif - #elif !(NETFX_CORE) + IsRunningOnUnity = AppDomain.CurrentDomain .GetAssemblies() .SelectMany(a => a.SafeGetTypes()) .Any(t => t.FullName.StartsWith("UnityEngine.")); - #endif -#endif IsRunningOnMono = (Type.GetType("Mono.Runtime") != null); - - IsRunningOnClr4 = (Type.GetType("System.Lazy`1") != null); - + + + IsRunningOnClr4 = true; + m_AutoDetectionsDone = true; } @@ -111,19 +90,11 @@ private static void AutoDetectPlatformFlags() internal static IPlatformAccessor GetDefaultPlatform() { AutoDetectPlatformFlags(); - -#if PCL || ENABLE_DOTNET - return new LimitedPlatformAccessor(); -#else + if (IsRunningOnUnity) return new LimitedPlatformAccessor(); - -#if DOTNET_CORE - return new DotNetCorePlatformAccessor(); -#else + return new StandardPlatformAccessor(); -#endif -#endif } internal static IScriptLoader GetDefaultScriptLoader() @@ -134,13 +105,7 @@ internal static IScriptLoader GetDefaultScriptLoader() return new UnityAssetsScriptLoader(); else { -#if (DOTNET_CORE) - return new FileSystemScriptLoader(); -#elif (PCL || ENABLE_DOTNET || NETFX_CORE) - return new InvalidScriptLoader("Portable Framework"); -#else return new FileSystemScriptLoader(); -#endif } } } diff --git a/src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs deleted file mode 100644 index 9e2d6d63..00000000 --- a/src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter")] -[assembly: AssemblyDescription("An interpreter for the Lua language")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://www.moonsharp.org")] -[assembly: AssemblyProduct("MoonSharp.Interpreter")] -[assembly: AssemblyCopyright("Copyright © 2014-2015, Marco Mastropaolo")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c971e5a8-dbec-4408-8046-86e4fdd1b2e3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion(MoonSharp.Interpreter.Script.VERSION)] -[assembly: AssemblyFileVersion(MoonSharp.Interpreter.Script.VERSION)] - -// Give -[assembly: InternalsVisibleTo("MoonSharp.Interpreter.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F704C50BBDC3F2F011CC26A8C6C4797A40E0B4BC94CFB1335E9BA208326340696B686DC13099F10D3054544532F5E3E66C26A13FF260AEA2343E0410511FE56EDCC2AFB898AAA1BC21DA33C0D0AE60824EB441D02A0E6B7AE251CDE0946BFC748209C12B062573ECDB008A3D10CC40534B314847591CE5342A3BC6AA83CE23B8")] -[assembly: InternalsVisibleTo("MoonSharp.Interpreter.Tests.net40-client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F704C50BBDC3F2F011CC26A8C6C4797A40E0B4BC94CFB1335E9BA208326340696B686DC13099F10D3054544532F5E3E66C26A13FF260AEA2343E0410511FE56EDCC2AFB898AAA1BC21DA33C0D0AE60824EB441D02A0E6B7AE251CDE0946BFC748209C12B062573ECDB008A3D10CC40534B314847591CE5342A3BC6AA83CE23B8")] -[assembly: InternalsVisibleTo("MoonSharp.Interpreter.Tests.portable40, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F704C50BBDC3F2F011CC26A8C6C4797A40E0B4BC94CFB1335E9BA208326340696B686DC13099F10D3054544532F5E3E66C26A13FF260AEA2343E0410511FE56EDCC2AFB898AAA1BC21DA33C0D0AE60824EB441D02A0E6B7AE251CDE0946BFC748209C12B062573ECDB008A3D10CC40534B314847591CE5342A3BC6AA83CE23B8")] -[assembly: InternalsVisibleTo("MoonSharp.Interpreter.Tests.net35-client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F704C50BBDC3F2F011CC26A8C6C4797A40E0B4BC94CFB1335E9BA208326340696B686DC13099F10D3054544532F5E3E66C26A13FF260AEA2343E0410511FE56EDCC2AFB898AAA1BC21DA33C0D0AE60824EB441D02A0E6B7AE251CDE0946BFC748209C12B062573ECDB008A3D10CC40534B314847591CE5342A3BC6AA83CE23B8")] - - - - - - - - - - - diff --git a/src/MoonSharp.Interpreter/REPL/ReplInterpreter.cs b/src/MoonSharp.Interpreter/REPL/ReplInterpreter.cs index 155abd0e..dea27ac2 100644 --- a/src/MoonSharp.Interpreter/REPL/ReplInterpreter.cs +++ b/src/MoonSharp.Interpreter/REPL/ReplInterpreter.cs @@ -68,7 +68,7 @@ public virtual DynValue Evaluate(string input) try { - DynValue result = null; + DynValue result = DynValue.Nil; if (isFirstLine && HandleClassicExprsSyntax && m_CurrentCommand.StartsWith("=")) { @@ -100,7 +100,7 @@ public virtual DynValue Evaluate(string input) } else { - return null; + return DynValue.Nil; } } catch (ScriptRuntimeException sre) diff --git a/src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs b/src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs index 198bade8..bc324054 100755 --- a/src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs +++ b/src/MoonSharp.Interpreter/REPL/ReplInterpreterScriptLoader.cs @@ -1,5 +1,4 @@ -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) -using System; +using System; using MoonSharp.Interpreter.Loaders; namespace MoonSharp.Interpreter.REPL @@ -58,14 +57,11 @@ public override string ResolveModuleName(string modname, Table globalContext) { DynValue s = globalContext.RawGet("LUA_PATH"); - if (s != null && s.Type == DataType.String) + if (s.Type == DataType.String) return ResolveModuleName(modname, UnpackStringPaths(s.String)); else return base.ResolveModuleName(modname, globalContext); } } -} - - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Report20141003-0007.diagsession b/src/MoonSharp.Interpreter/Report20141003-0007.diagsession deleted file mode 100644 index 18bd87d5..00000000 Binary files a/src/MoonSharp.Interpreter/Report20141003-0007.diagsession and /dev/null differ diff --git a/src/MoonSharp.Interpreter/Script.cs b/src/MoonSharp.Interpreter/Script.cs index 6e3bb11a..000b803e 100755 --- a/src/MoonSharp.Interpreter/Script.cs +++ b/src/MoonSharp.Interpreter/Script.cs @@ -3,12 +3,16 @@ using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using MoonSharp.Interpreter.CoreLib; using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Diagnostics; +using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; +using MoonSharp.Interpreter.Interop; using MoonSharp.Interpreter.IO; using MoonSharp.Interpreter.Platforms; +using MoonSharp.Interpreter.Tree; using MoonSharp.Interpreter.Tree.Expressions; using MoonSharp.Interpreter.Tree.Fast_Interface; @@ -20,10 +24,36 @@ namespace MoonSharp.Interpreter /// public class Script : IScriptPrivateResource { + public enum ScriptParserMessageType + { + Error, + Warning, + Info + } + + public class ScriptParserMessage + { + public string Msg { get; set; } + private Token Token { get; set; } + public ScriptParserMessageType Type { get; set; } + + internal ScriptParserMessage(Token token) + { + Token = token; + Msg = $"unexpected symbol near '{token}'"; + } + + internal ScriptParserMessage(Token token, string msg) + { + Token = token; + Msg = msg; + } + } + /// /// The version of the MoonSharp engine /// - public const string VERSION = "2.0.0.0"; + public const string VERSION = "3.0.0.0"; /// /// The Lua version being supported @@ -36,6 +66,7 @@ public class Script : IScriptPrivateResource Table m_GlobalTable; IDebugger m_Debugger; Table[] m_TypeMetatables = new Table[(int)LuaTypeExtensions.MaxMetaTypes]; + internal List i_ParserMessages { get; set; } = new List(); /// /// Initializes the class. @@ -201,12 +232,10 @@ public DynValue LoadString(string code, Table globalTable = null, string codeFri public DynValue LoadStream(Stream stream, Table globalTable = null, string codeFriendlyName = null) { this.CheckScriptOwnership(globalTable); - - Stream codeStream = new UndisposableStream(stream); - - if (!Processor.IsDumpStream(codeStream)) + + if (!Processor.IsDumpStream(stream)) { - using (StreamReader sr = new StreamReader(codeStream)) + using (StreamReader sr = new StreamReader(stream, Encoding.UTF8, true, 4096, true)) { string scriptCode = sr.ReadToEnd(); return LoadString(scriptCode, globalTable, codeFriendlyName); @@ -223,7 +252,7 @@ public DynValue LoadStream(Stream stream, Table globalTable = null, string codeF m_Sources.Add(source); bool hasUpvalues; - int address = m_MainProcessor.Undump(codeStream, m_Sources.Count - 1, globalTable ?? m_GlobalTable, out hasUpvalues); + int address = m_MainProcessor.Undump(stream, m_Sources.Count - 1, globalTable ?? m_GlobalTable, out hasUpvalues); SignalSourceCodeChange(source); SignalByteCodeChange(); @@ -240,6 +269,7 @@ public DynValue LoadStream(Stream stream, Table globalTable = null, string codeF /// /// The function. /// The stream. + /// Write referenced line numbers /// /// function arg is not a function! /// or @@ -247,7 +277,7 @@ public DynValue LoadStream(Stream stream, Table globalTable = null, string codeF /// or /// function arg has upvalues other than _ENV /// - public void Dump(DynValue function, Stream stream) + public void Dump(DynValue function, Stream stream, bool writeSourceRefs = true) { this.CheckScriptOwnership(function); @@ -262,8 +292,21 @@ public void Dump(DynValue function, Stream stream) if (upvaluesType == Closure.UpvaluesType.Closure) throw new ArgumentException("function arg has upvalues other than _ENV"); - UndisposableStream outStream = new UndisposableStream(stream); - m_MainProcessor.Dump(outStream, function.Function.EntryPointByteCodeLocation, upvaluesType == Closure.UpvaluesType.Environment); + m_MainProcessor.Dump(stream, function.Function.EntryPointByteCodeLocation, upvaluesType == Closure.UpvaluesType.Environment, writeSourceRefs); + + } + + /// + /// Dumps the bytecode for a function to a human-readable string + /// + /// + public string DumpString(DynValue function) + { + this.CheckScriptOwnership(function); + + if (function.Type != DataType.Function) + throw new ArgumentException("function arg is not a function!"); + return m_MainProcessor.DumpString(function.Function.EntryPointByteCodeLocation); } @@ -331,6 +374,12 @@ public DynValue DoString(string code, Table globalContext = null, string codeFri return Call(func); } + public Task DoStringAsync(string code, Table globalContext = null, string codeFriendlyName = null) + { + DynValue func = LoadString(code, globalContext, codeFriendlyName); + return CallAsync(func); + } + /// /// Loads and executes a stream containing a Lua/MoonSharp script. @@ -396,21 +445,21 @@ private DynValue MakeClosure(int address, Table envTable = null) { this.CheckScriptOwnership(envTable); Closure c; - + var annotations = m_MainProcessor.FindAnnotations(address); if (envTable == null) { - Instruction meta = m_MainProcessor.FindMeta(ref address); + Instruction? meta = m_MainProcessor.FindMeta(ref address); // if we find the meta for a new chunk, we use the value in the meta for the _ENV upvalue - if ((meta != null) && (meta.NumVal2 == (int)OpCodeMetadataType.ChunkEntrypoint)) + if ((meta != null) && (meta.Value.NumVal2 == (int)OpCodeMetadataType.ChunkEntrypoint)) { c = new Closure(this, address, - new SymbolRef[] { SymbolRef.Upvalue(WellKnownSymbols.ENV, 0) }, - new DynValue[] { meta.Value }); + new SymbolRef[] { SymbolRef.Upvalue(WellKnownSymbols.ENV, 0) }, annotations, + new Upvalue[1]); } else { - c = new Closure(this, address, new SymbolRef[0], new DynValue[0]); + c = new Closure(this, address, new SymbolRef[0], annotations, new Upvalue[0]); } } else @@ -419,11 +468,11 @@ private DynValue MakeClosure(int address, Table envTable = null) new SymbolRef() { i_Env = null, i_Index= 0, i_Name = WellKnownSymbols.ENV, i_Type = SymbolRefType.DefaultEnv }, }; - var vals = new DynValue[] { - DynValue.NewTable(envTable) + var vals = new Upvalue[] { + Upvalue.Create(DynValue.NewTable(envTable)) }; - c = new Closure(this, address, syms, vals); + c = new Closure(this, address, syms, annotations, vals); } return DynValue.NewClosure(c); @@ -442,6 +491,11 @@ public DynValue Call(DynValue function) return Call(function, new DynValue[0]); } + public Task CallAsync(DynValue function) + { + return CallAsync(function, new DynValue[0]); + } + /// /// Calls the specified function. /// @@ -460,7 +514,7 @@ public DynValue Call(DynValue function, params DynValue[] args) { DynValue metafunction = m_MainProcessor.GetMetamethod(function, "__call"); - if (metafunction != null) + if (metafunction.IsNotNil()) { DynValue[] metaargs = new DynValue[args.Length + 1]; metaargs[0] = function; @@ -483,6 +537,39 @@ public DynValue Call(DynValue function, params DynValue[] args) return m_MainProcessor.Call(function, args); } + public Task CallAsync(DynValue function, params DynValue[] args) + { + this.CheckScriptOwnership(function); + this.CheckScriptOwnership(args); + + if (function.Type != DataType.Function && function.Type != DataType.ClrFunction) + { + DynValue metafunction = m_MainProcessor.GetMetamethod(function, "__call"); + + if (metafunction.IsNotNil()) + { + DynValue[] metaargs = new DynValue[args.Length + 1]; + metaargs[0] = function; + for (int i = 0; i < args.Length; i++) + metaargs[i + 1] = args[i]; + + function = metafunction; + args = metaargs; + } + else + { + throw new ArgumentException("function is not a function and has no __call metamethod."); + } + } + else if (function.Type == DataType.ClrFunction) + { + return Task.FromResult(function.Callback.ClrCallback( + this.CreateDynamicExecutionContext(function.Callback), new CallbackArguments(args, false))); + } + + return m_MainProcessor.CallAsync(function, args); + } + /// /// Calls the specified function. /// @@ -525,6 +612,40 @@ public DynValue Call(object function, params object[] args) return Call(DynValue.FromObject(this, function), args); } + /// + /// Calls the specified function. + /// + /// The Lua/MoonSharp function to be called + /// The arguments to pass to the function. + /// + /// Thrown if function is not of DataType.Function + public DynValue Call(object function, params DynValue[] args) + { + return Call(DynValue.FromObject(this, function), args); + } + + public Task CallAsync(DynValue function, params object[] args) + { + DynValue[] dargs = new DynValue[args.Length]; + + for (int i = 0; i < dargs.Length; i++) + dargs[i] = DynValue.FromObject(this, args[i]); + + return CallAsync(function, dargs); + } + + + public Task CallAsync(object function) + { + return CallAsync(DynValue.FromObject(this, function)); + } + + + public Task CallAsync(object function, params object[] args) + { + return CallAsync(DynValue.FromObject(this, function), args); + } + /// /// Creates a coroutine pointing at the specified function. /// @@ -736,7 +857,7 @@ public static string GetBanner(string subproduct = null) StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("MoonSharp {0}{1} [{2}]", subproduct, Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName())); - sb.AppendLine("Copyright (C) 2014-2016 Marco Mastropaolo"); + sb.AppendLine("Copyright (C) 2014-2022 MoonSharp Contributors"); sb.AppendLine("http://www.moonsharp.org"); return sb.ToString(); } @@ -745,5 +866,7 @@ Script IScriptPrivateResource.OwnerScript { get { return this; } } + + public List ParserMessages => i_ParserMessages; } } diff --git a/src/MoonSharp.Interpreter/ScriptOptions.cs b/src/MoonSharp.Interpreter/ScriptOptions.cs index f74131a9..a95656d8 100644 --- a/src/MoonSharp.Interpreter/ScriptOptions.cs +++ b/src/MoonSharp.Interpreter/ScriptOptions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using MoonSharp.Interpreter.Loaders; @@ -28,6 +29,12 @@ internal ScriptOptions(ScriptOptions defaults) this.CheckThreadAccess = defaults.CheckThreadAccess; } + + public enum ParserErrorModes + { + Throw, + Report + } /// /// Gets or sets the current script-loader. @@ -95,6 +102,43 @@ internal ScriptOptions(ScriptOptions defaults) /// you are not calling MoonSharp execution concurrently as it is not supported. /// public bool CheckThreadAccess { get; set; } + + /// + /// Gets or sets a value indicating whether or not tasks are automatically awaited. + /// When set to true, each call to a CLR function returning Task will automatically await and cast the value + /// When set to false, the call returns a task object that can have await() called on it. + /// + public bool AutoAwait { get; set; } + + /// + /// Gets or sets a value indicating the syntax used by the compiler. + /// + public ScriptSyntax Syntax { get; set; } + + /// + /// Gets or sets a value indicating whether tables are indexed from zero or one (default) + /// When set to 1, tables will be indexed from one + /// When set to 0, tables will be indexed from zero + /// Other values are not supported + /// + public int IndexTablesFrom { get; set; } = 1; + /// + /// Gets or sets the annotation policy for the script compiler (C-Like mode only) + /// + /// + public IAnnotationPolicy AnnotationPolicy { get; set; } = AnnotationPolicies.Allow; + + /// + /// List of keywords that will be interpreted as directives by the compiler (C-Like mode only). + /// These directions will store the RHS as a string annotation on the chunk. + /// + public HashSet Directives { get; set; } = new HashSet(); + + /// + /// Specifies how parser reacts to errors while parsing. + /// Options are: Throw (paring is aborted after first error), Report (errors are stashed and available in Script.ParserMessages) + /// + public ParserErrorModes ParserErrorMode { get; set; } = ParserErrorModes.Throw; } } diff --git a/src/MoonSharp.Interpreter/Serialization/Json/JsonTableConverter.cs b/src/MoonSharp.Interpreter/Serialization/Json/JsonTableConverter.cs index 2615d251..7f1e89a6 100755 --- a/src/MoonSharp.Interpreter/Serialization/Json/JsonTableConverter.cs +++ b/src/MoonSharp.Interpreter/Serialization/Json/JsonTableConverter.cs @@ -140,7 +140,7 @@ private static bool IsValueJsonCompatible(DynValue value) /// A table containing the representation of the given json. public static Table JsonToTable(string json, Script script = null) { - Lexer L = new Lexer(0, json, false); + Lexer L = new Lexer(0, json, false, false, false, null); if (L.Current.Type == TokenType.Brk_Open_Curly) return ParseJsonObject(L, script); @@ -258,7 +258,7 @@ private static DynValue ParseJsonNumberValue(Lexer L, Script script) { numberValue = -numberValue; } - return DynValue.NewNumber(numberValue).AsReadOnly(); + return DynValue.NewNumber(numberValue); } } } diff --git a/src/MoonSharp.Interpreter/Serialization/ObjectValueConverter.cs b/src/MoonSharp.Interpreter/Serialization/ObjectValueConverter.cs index 62263403..a4ba0c00 100755 --- a/src/MoonSharp.Interpreter/Serialization/ObjectValueConverter.cs +++ b/src/MoonSharp.Interpreter/Serialization/ObjectValueConverter.cs @@ -3,21 +3,21 @@ using System.Linq; using System.Reflection; using System.Text; -using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.Converters; +using MoonSharp.Interpreter.Interop; namespace MoonSharp.Interpreter.Serialization { public static class ObjectValueConverter { - public static DynValue SerializeObjectToDynValue(Script script, object o, DynValue valueForNulls = null) + public static DynValue SerializeObjectToDynValue(Script script, object o, DynValue valueForNulls = default) { if (o == null) - return valueForNulls ?? DynValue.Nil; + return valueForNulls; DynValue v = ClrToScriptConversions.TryObjectToTrivialDynValue(script, o); - if (v != null) + if (v.IsNotNil()) return v; if (o is Enum) @@ -38,9 +38,9 @@ public static DynValue SerializeObjectToDynValue(Script script, object o, DynVal { Type type = o.GetType(); - foreach (PropertyInfo pi in Framework.Do.GetProperties(type)) + foreach (PropertyInfo pi in type.GetAllProperties()) { - var getter = Framework.Do.GetGetMethod(pi); + var getter = pi.GetGetMethod(true); var isStatic = getter.IsStatic; var obj = getter.Invoke(isStatic ? null : o, null); // convoluted workaround for --full-aot Mono execution diff --git a/src/MoonSharp.Interpreter/Tree/Expression_.cs b/src/MoonSharp.Interpreter/Tree/Expression_.cs index d0235bbb..09b94024 100644 --- a/src/MoonSharp.Interpreter/Tree/Expression_.cs +++ b/src/MoonSharp.Interpreter/Tree/Expression_.cs @@ -1,6 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Tree.Expressions; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree { @@ -10,6 +13,8 @@ public Expression(ScriptLoadingContext lcontext) : base(lcontext) { } + public bool LexerCarry { get; set; } // currently used to indicate whether ternary parsing in in progress + public virtual string GetFriendlyDebugName() { return null; @@ -17,6 +22,19 @@ public virtual string GetFriendlyDebugName() public abstract DynValue Eval(ScriptExecutionContext context); + public abstract void ResolveScope(ScriptLoadingContext lcontext); + + public abstract bool EvalLiteral(out DynValue dv); + + public void CompilePossibleLiteral(ByteCode bc) + { + if (EvalLiteral(out var dv)) + { + bc.Emit_Literal(dv); + } + else Compile(bc); + } + public virtual SymbolRef FindDynamic(ScriptExecutionContext context) { return null; @@ -36,8 +54,7 @@ internal static List ExprListAfterFirstExpr(ScriptLoadingContext lco return exps; } - - + internal static List ExprList(ScriptLoadingContext lcontext) { List exps = new List(); @@ -60,10 +77,9 @@ internal static Expression Expr(ScriptLoadingContext lcontext) return SubExpr(lcontext, true); } - internal static Expression SubExpr(ScriptLoadingContext lcontext, bool isPrimary) + internal static Expression SubExpr(ScriptLoadingContext lcontext, bool isPrimary, bool binaryChainInProgress = false) { - Expression e = null; - + Expression e; Token T = lcontext.Lexer.Current; if (T.IsUnaryOperator()) @@ -104,22 +120,44 @@ internal static Expression SubExpr(ScriptLoadingContext lcontext, bool isPrimary T = lcontext.Lexer.Current; + if (T.Type == TokenType.Ternary) + { + if (!binaryChainInProgress) + { + return new TernaryExpression(lcontext, e); + } + + e.LexerCarry = true; + return e; + } + if (isPrimary && T.IsBinaryOperator()) { object chain = BinaryOperatorExpression.BeginOperatorChain(); BinaryOperatorExpression.AddExpressionToChain(chain, e); - + bool forceReturnTernary = false; + while (T.IsBinaryOperator()) { BinaryOperatorExpression.AddOperatorToChain(chain, T); lcontext.Lexer.Next(); - Expression right = SubExpr(lcontext, false); + Expression right = SubExpr(lcontext, false, true); BinaryOperatorExpression.AddExpressionToChain(chain, right); T = lcontext.Lexer.Current; + + if (right.LexerCarry) + { + forceReturnTernary = true; + } } e = BinaryOperatorExpression.CommitOperatorChain(chain, lcontext); + + if (forceReturnTernary) + { + return new TernaryExpression(lcontext, e); + } } return e; @@ -134,7 +172,7 @@ internal static Expression SimpleExp(ScriptLoadingContext lcontext) case TokenType.Number: case TokenType.Number_Hex: case TokenType.Number_HexFloat: - case TokenType.String: + case TokenType.String when lcontext.Syntax != ScriptSyntax.CLike: case TokenType.String_Long: case TokenType.Nil: case TokenType.True: @@ -145,11 +183,32 @@ internal static Expression SimpleExp(ScriptLoadingContext lcontext) case TokenType.Brk_Open_Curly: case TokenType.Brk_Open_Curly_Shared: return new TableConstructor(lcontext, t.Type == TokenType.Brk_Open_Curly_Shared); + case TokenType.Brk_Open_Square when lcontext.Syntax != ScriptSyntax.Lua: + return new TableConstructor(lcontext, false); case TokenType.Function: lcontext.Lexer.Next(); return new FunctionDefinitionExpression(lcontext, false, false); case TokenType.Lambda: return new FunctionDefinitionExpression(lcontext, false, true); + case TokenType.Brk_Open_Round: + { + if (lcontext.Syntax == ScriptSyntax.Lua) return PrimaryExp(lcontext); + //Scan to see if this is an arrow lambda + lcontext.Lexer.SavePos(); + lcontext.Lexer.Next(); // skip bracket + while (lcontext.Lexer.Current.Type != TokenType.Eof && + lcontext.Lexer.Current.Type != TokenType.Brk_Close_Round && + lcontext.Lexer.Current.Type != TokenType.Brk_Open_Round) { + lcontext.Lexer.Next(); + } + lcontext.Lexer.Next(); + bool arrowLambda = lcontext.Lexer.Current.Type == TokenType.Arrow || lcontext.Lexer.PeekNext().Type == TokenType.Arrow; + lcontext.Lexer.RestorePos(); + if (arrowLambda) + return new FunctionDefinitionExpression(lcontext, false, true); + else + return PrimaryExp(lcontext); + } default: return PrimaryExp(lcontext); } @@ -163,50 +222,76 @@ internal static Expression SimpleExp(ScriptLoadingContext lcontext) /// internal static Expression PrimaryExp(ScriptLoadingContext lcontext) { + if (lcontext.Lexer.PeekNext().Type == TokenType.Arrow && lcontext.Lexer.Current.Type == TokenType.Name) + { + return new FunctionDefinitionExpression(lcontext, false, true); + } + Expression e = PrefixExp(lcontext); while (true) { Token T = lcontext.Lexer.Current; Token thisCallName = null; - + switch (T.Type) { case TokenType.Dot: - { - lcontext.Lexer.Next(); - Token name = CheckTokenType(lcontext, TokenType.Name); - e = new IndexExpression(e, name.Text, lcontext); - } + case TokenType.DotNil: + { + lcontext.Lexer.Next(); + Token name = CheckTokenType(lcontext, TokenType.Name); + var ne = new IndexExpression(e, name, T.Type == TokenType.DotNil, lcontext); + //Break nil checking chain on next nil check + if (e is IndexExpression ie && T.Type != TokenType.DotNil) ie.NilChainNext = ne; + e = ne; break; + } + case TokenType.BrkOpenSquareNil: case TokenType.Brk_Open_Square: { Token openBrk = lcontext.Lexer.Current; lcontext.Lexer.Next(); // skip bracket Expression index = Expr(lcontext); - // support moonsharp multiple indexers for userdata if (lcontext.Lexer.Current.Type == TokenType.Comma) { var explist = ExprListAfterFirstExpr(lcontext, index); index = new ExprListExpression(explist, lcontext); } - CheckMatch(lcontext, openBrk, TokenType.Brk_Close_Square, "]"); - e = new IndexExpression(e, index, lcontext); + var ne = new IndexExpression(e, index, T.Type == TokenType.BrkOpenSquareNil, lcontext); + //Break nil checking chain on next nil check + if (e is IndexExpression ie && T.Type != TokenType.BrkOpenSquareNil) ie.NilChainNext = ne; + e = ne; + break; } - break; - case TokenType.Colon: + case TokenType.Colon when lcontext.Syntax != ScriptSyntax.CLike: + case TokenType.DoubleColon when lcontext.Syntax == ScriptSyntax.CLike: lcontext.Lexer.Next(); thisCallName = CheckTokenType(lcontext, TokenType.Name); goto case TokenType.Brk_Open_Round; case TokenType.Brk_Open_Round: case TokenType.String: case TokenType.String_Long: - case TokenType.Brk_Open_Curly: case TokenType.Brk_Open_Curly_Shared: - e = new FunctionCallExpression(lcontext, e, thisCallName); + { + var ne = new FunctionCallExpression(lcontext, e, thisCallName); + if (e is IndexExpression ie) ie.NilChainNext = ne; + e = ne; + break; + } + case TokenType.Brk_Open_Curly: + { + if (e is AdjustmentExpression) + { + return e; + } + var ne = new FunctionCallExpression(lcontext, e, thisCallName); + if (e is IndexExpression ie) ie.NilChainNext = ne; + e = ne; break; + } default: return e; } @@ -220,6 +305,11 @@ private static Expression PrefixExp(ScriptLoadingContext lcontext) Token T = lcontext.Lexer.Current; switch (T.Type) { + case TokenType.String when lcontext.Syntax == ScriptSyntax.CLike: + case TokenType.String_EndTemplate: + return new LiteralExpression(lcontext, T); + case TokenType.String_TemplateFragment: + return new TemplatedStringExpression(lcontext, T); case TokenType.Brk_Open_Round: lcontext.Lexer.Next(); Expression e = Expr(lcontext); diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/AdjustmentExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/AdjustmentExpression.cs index 26489201..b7b49873 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/AdjustmentExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/AdjustmentExpression.cs @@ -1,4 +1,5 @@ -using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Expressions @@ -23,5 +24,20 @@ public override DynValue Eval(ScriptExecutionContext context) { return expression.Eval(context).ToScalar(); } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + expression.ResolveScope(lcontext); + } + + public override bool EvalLiteral(out DynValue dv) + { + if (expression.EvalLiteral(out dv)) + { + dv = dv.ToScalar(); + return true; + } + return false; + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/BinaryOperatorExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/BinaryOperatorExpression.cs index 255039f5..a31699f4 100755 --- a/src/MoonSharp.Interpreter/Tree/Expressions/BinaryOperatorExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/BinaryOperatorExpression.cs @@ -1,38 +1,47 @@ using System; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree.Expressions { + [Flags] + public enum Operator + { + NotAnOperator = 0, + + Or = 0x1, + And = 0x2, + Less = 0x4, + Greater = 0x8, + LessOrEqual = 0x10, + + GreaterOrEqual = 0x20, + NotEqual = 0x40, + Equal = 0x80, + StrConcat = 0x100, + Add = 0x200, + Sub = 0x400, + Mul = 0x1000, + Div = 0x2000, + Mod = 0x4000, + Power = 0x8000, + AddConcat = 0x10000, + NilCoalescing = 0x20000, + BitAnd = 0x40000, + BitOr = 0x80000, + BitXor = 0x100000, + BitLShift = 0x200000, + BitRShiftA = 0x400000, + BitRShiftL = 0x4800000, + NilCoalescingInverse = 0x9000000, + } + /// /// /// class BinaryOperatorExpression : Expression { - [Flags] - private enum Operator - { - NotAnOperator = 0, - - Or = 0x1, - And = 0x2, - Less = 0x4, - Greater = 0x8, - LessOrEqual = 0x10, - - GreaterOrEqual = 0x20, - NotEqual = 0x40, - Equal = 0x80, - StrConcat = 0x100, - Add = 0x200, - Sub = 0x400, - Mul = 0x1000, - Div = 0x2000, - Mod = 0x4000, - Power = 0x8000, - } - - class Node { public Expression Expr; @@ -50,12 +59,14 @@ class LinkedList const Operator POWER = Operator.Power; const Operator MUL_DIV_MOD = Operator.Mul | Operator.Div | Operator.Mod; - const Operator ADD_SUB = Operator.Add | Operator.Sub; + const Operator ADD_SUB = Operator.Add | Operator.Sub | Operator.AddConcat; const Operator STRCAT = Operator.StrConcat; const Operator COMPARES = Operator.Less | Operator.Greater | Operator.GreaterOrEqual | Operator.LessOrEqual | Operator.Equal | Operator.NotEqual; const Operator LOGIC_AND = Operator.And; const Operator LOGIC_OR = Operator.Or; - + const Operator NIL_COAL_ASSIGN = Operator.NilCoalescing; + const Operator SHIFTS = Operator.BitLShift | Operator.BitRShiftA | Operator.BitRShiftL; + const Operator NIL_COAL_INVERSE = Operator.NilCoalescingInverse; public static object BeginOperatorChain() { @@ -126,15 +137,32 @@ private static Expression CreateSubTree(LinkedList list, ScriptLoadingContext lc if ((opfound & STRCAT) != 0) nodes = PrioritizeRightAssociative(nodes, lcontext, STRCAT); + if ((opfound & SHIFTS) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, SHIFTS); + if ((opfound & COMPARES) != 0) nodes = PrioritizeLeftAssociative(nodes, lcontext, COMPARES); + if ((opfound & Operator.BitAnd) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, Operator.BitAnd); + + if ((opfound & Operator.BitXor) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, Operator.BitXor); + + if ((opfound & Operator.BitOr) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, Operator.BitOr); + if ((opfound & LOGIC_AND) != 0) nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_AND); if ((opfound & LOGIC_OR) != 0) nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_OR); + if ((opfound & NIL_COAL_ASSIGN) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, NIL_COAL_ASSIGN); + + if ((opfound & NIL_COAL_INVERSE) != 0) + nodes = PrioritizeLeftAssociative(nodes, lcontext, NIL_COAL_INVERSE); if (nodes.Next != null || nodes.Prev != null) throw new InternalErrorException("Expression reduction didn't work! - 1"); @@ -236,6 +264,22 @@ private static Operator ParseBinaryOperator(Token token) return Operator.Mod; case TokenType.Op_Pwr: return Operator.Power; + case TokenType.Op_NilCoalesce: + return Operator.NilCoalescing; + case TokenType.Op_NilCoalesceInverse: + return Operator.NilCoalescingInverse; + case TokenType.Op_Or: + return Operator.BitOr; + case TokenType.Op_And: + return Operator.BitAnd; + case TokenType.Op_Xor: + return Operator.BitXor; + case TokenType.Op_LShift: + return Operator.BitLShift; + case TokenType.Op_RShiftArithmetic: + return Operator.BitRShiftA; + case TokenType.Op_RShiftLogical: + return Operator.BitRShiftL; default: throw new InternalErrorException("Unexpected binary operator '{0}'", token.Text); } @@ -255,6 +299,8 @@ private BinaryOperatorExpression(Expression exp1, Expression exp2, Operator op, m_Exp1 = exp1; m_Exp2 = exp2; m_Operator = op; + if (op == Operator.Add && lcontext.Syntax == ScriptSyntax.CLike) + m_Operator = Operator.AddConcat; } private static bool ShouldInvertBoolean(Operator op) @@ -264,7 +310,7 @@ private static bool ShouldInvertBoolean(Operator op) || (op == Operator.Greater); } - private static OpCode OperatorToOpCode(Operator op) + public static OpCode OperatorToOpCode(Operator op) { switch (op) { @@ -291,36 +337,60 @@ private static OpCode OperatorToOpCode(Operator op) return OpCode.Mod; case Operator.Power: return OpCode.Power; + case Operator.AddConcat: + return OpCode.AddStr; + case Operator.NilCoalescing: + return OpCode.NilCoalescing; + case Operator.BitAnd: + return OpCode.BAnd; + case Operator.BitOr: + return OpCode.BOr; + case Operator.BitXor: + return OpCode.BXor; + case Operator.BitLShift: + return OpCode.BLShift; + case Operator.BitRShiftA: + return OpCode.BRShiftA; + case Operator.BitRShiftL: + return OpCode.BRShiftL; + case Operator.NilCoalescingInverse: + return OpCode.NilCoalescingInverse; default: throw new InternalErrorException("Unsupported operator {0}", op); } } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Exp1.ResolveScope(lcontext); + m_Exp2.ResolveScope(lcontext); + } + public override void Compile(Execution.VM.ByteCode bc) { - m_Exp1.Compile(bc); + m_Exp1.CompilePossibleLiteral(bc); if (m_Operator == Operator.Or) { - Instruction i = bc.Emit_Jump(OpCode.JtOrPop, -1); - m_Exp2.Compile(bc); - i.NumVal = bc.GetJumpPointForNextInstruction(); + int i = bc.Emit_Jump(OpCode.JtOrPop, -1); + m_Exp2.CompilePossibleLiteral(bc); + bc.SetNumVal(i, bc.GetJumpPointForNextInstruction()); return; } if (m_Operator == Operator.And) { - Instruction i = bc.Emit_Jump(OpCode.JfOrPop, -1); - m_Exp2.Compile(bc); - i.NumVal = bc.GetJumpPointForNextInstruction(); + int i = bc.Emit_Jump(OpCode.JfOrPop, -1); + m_Exp2.CompilePossibleLiteral(bc); + bc.SetNumVal(i, bc.GetJumpPointForNextInstruction()); return; } if (m_Exp2 != null) { - m_Exp2.Compile(bc); + m_Exp2.CompilePossibleLiteral(bc); } bc.Emit_Operator(OperatorToOpCode(m_Operator)); @@ -329,10 +399,88 @@ public override void Compile(Execution.VM.ByteCode bc) bc.Emit_Operator(OpCode.Not); } + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + if (!m_Exp1.EvalLiteral(out var v1)) + return false; + bool t1Neg = m_Exp1 is UnaryOperatorExpression uo && + uo.IsNegativeNumber; + v1 = v1.ToScalar(); + if (!m_Exp2.EvalLiteral(out var v2)) + return false; + v2 = v2.ToScalar(); + if (m_Operator == Operator.NilCoalescing) + { + if (v1.IsNil()) dv = v2; + else dv = v1; + return true; + } + if (m_Operator == Operator.NilCoalescingInverse) + { + if (v1.IsNotNil()) dv = v2; + else dv = v1; + return true; + } + if (m_Operator == Operator.Or) + { + if (v1.CastToBool()) + dv = v1; + else + dv = v2; + } + else if (m_Operator == Operator.And) + { + if (!v1.CastToBool()) + dv = v1; + else + dv = v2; + } + else if ((m_Operator & COMPARES) != 0) + { + if (v1.Type == DataType.Number && v2.Type == DataType.Number || + v1.Type == DataType.String && v2.Type == DataType.String) + dv = DynValue.NewBoolean(EvalComparison(v1, v2, m_Operator)); + else + return false; + } + else if (m_Operator == Operator.StrConcat) + { + string s1 = v1.CastToString(); + string s2 = v2.CastToString(); + + if (s1 == null || s2 == null) + return false; + + dv = DynValue.NewString(s1 + s2); + } + else + { + //Check correct casts + double? nd1 = v1.CastToNumber(); + double? nd2 = v2.CastToNumber(); + if (nd1 == null || nd2 == null) + return false; + //Literal evaluation + dv = DynValue.NewNumber(EvalArithmetic(v1, v2, t1Neg)); + } + return true; + } + public override DynValue Eval(ScriptExecutionContext context) { DynValue v1 = m_Exp1.Eval(context).ToScalar(); + if (m_Operator == Operator.NilCoalescing) + { + if (v1.IsNil()) return m_Exp2.Eval(context); + return v1; + } + if (m_Operator == Operator.NilCoalescingInverse) + { + if (v1.IsNotNil()) return m_Exp2.Eval(context); + return v1; + } if (m_Operator == Operator.Or) { if (v1.CastToBool()) @@ -371,7 +519,7 @@ public override DynValue Eval(ScriptExecutionContext context) } } - private double EvalArithmetic(DynValue v1, DynValue v2) + private double EvalArithmetic(DynValue v1, DynValue v2, bool t1Neg = false) { double? nd1 = v1.CastToNumber(); double? nd2 = v2.CastToNumber(); @@ -384,7 +532,20 @@ private double EvalArithmetic(DynValue v1, DynValue v2) switch (m_Operator) { + case Operator.BitAnd: + return (int) d1 & (int) d2; + case Operator.BitOr: + return (int) d1 | (int) d2; + case Operator.BitXor: + return (int) d1 ^ (int) d2; + case Operator.BitLShift: + return (int) d1 << (int) d2; + case Operator.BitRShiftA: + return (int) d1 >> (int) d2; + case Operator.BitRShiftL: + return (int) ((uint) d1 >> (int) d2); case Operator.Add: + case Operator.AddConcat: return d1 + d2; case Operator.Sub: return d1 - d2; @@ -393,11 +554,10 @@ private double EvalArithmetic(DynValue v1, DynValue v2) case Operator.Div: return d1 / d2; case Operator.Mod: - { - double mod = Math.IEEERemainder(d1, d2); - if (mod < 0) mod += d2; - return mod; - } + return (d1) - Math.Floor((d1) / (d2)) * (d2); + case Operator.Power: + var res = Math.Pow(t1Neg ? -d1 : d1, d2); + return t1Neg ? -res : res; default: throw new DynamicExpressionException("Unsupported operator {0}", m_Operator); } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/DynamicExprExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/DynamicExprExpression.cs index 80a5491a..17389d75 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/DynamicExprExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/DynamicExprExpression.cs @@ -1,4 +1,5 @@ using System; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Expressions @@ -14,12 +15,21 @@ public DynamicExprExpression(Expression exp, ScriptLoadingContext lcontext) m_Exp = exp; } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Exp.ResolveScope(lcontext); + } public override DynValue Eval(ScriptExecutionContext context) { return m_Exp.Eval(context); } + public override bool EvalLiteral(out DynValue dv) + { + throw new InvalidOperationException(); + } + public override void Compile(Execution.VM.ByteCode bc) { throw new InvalidOperationException(); diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/ExprListExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/ExprListExpression.cs index c300a618..33d10f35 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/ExprListExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/ExprListExpression.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Expressions @@ -19,10 +20,16 @@ public Expression[] GetExpressions() return expressions.ToArray(); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + foreach(var exp in expressions) + exp.ResolveScope(lcontext); + } + public override void Compile(Execution.VM.ByteCode bc) { foreach (var exp in expressions) - exp.Compile(bc); + exp.CompilePossibleLiteral(bc); if (expressions.Count > 1) bc.Emit_MkTuple(expressions.Count); @@ -35,5 +42,11 @@ public override DynValue Eval(ScriptExecutionContext context) return DynValue.Void; } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/FunctionCallExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/FunctionCallExpression.cs index e0e8018f..99948a70 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/FunctionCallExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/FunctionCallExpression.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Execution; @@ -10,10 +11,8 @@ class FunctionCallExpression : Expression Expression m_Function; string m_Name; string m_DebugErr; - internal SourceRef SourceRef { get; private set; } - public FunctionCallExpression(ScriptLoadingContext lcontext, Expression function, Token thisCallName) : base(lcontext) { @@ -66,6 +65,13 @@ public FunctionCallExpression(ScriptLoadingContext lcontext, Expression function } } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Function.ResolveScope(lcontext); + foreach(var arg in m_Arguments) + arg.ResolveScope(lcontext); + } + public override void Compile(Execution.VM.ByteCode bc) { m_Function.Compile(bc); @@ -75,13 +81,14 @@ public override void Compile(Execution.VM.ByteCode bc) if (!string.IsNullOrEmpty(m_Name)) { bc.Emit_Copy(0); - bc.Emit_Index(DynValue.NewString(m_Name), true); + bc.Emit_Index(m_Name, true); bc.Emit_Swap(0, 1); ++argslen; } + for (int i = 0; i < m_Arguments.Count; i++) - m_Arguments[i].Compile(bc); + m_Arguments[i].CompilePossibleLiteral(bc); if (!string.IsNullOrEmpty(m_Name)) { @@ -91,6 +98,15 @@ public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Call(argslen, m_DebugErr); } + if (bc.NilChainTargets.Count > 0) { + bc.SetNumVal(bc.NilChainTargets.Pop(), bc.GetJumpPointForNextInstruction()); + } + } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; } public override DynValue Eval(ScriptExecutionContext context) diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/FunctionDefinitionExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/FunctionDefinitionExpression.cs index 3146cedb..db884c5a 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/FunctionDefinitionExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/FunctionDefinitionExpression.cs @@ -1,5 +1,6 @@ -using System; +using System; using System.Collections.Generic; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; @@ -14,14 +15,18 @@ class FunctionDefinitionExpression : Expression, IClosureBuilder Statement m_Statement; RuntimeScopeFrame m_StackFrame; List m_Closure = new List(); + private Annotation[] m_Annotations; bool m_HasVarArgs = false; - Instruction m_ClosureInstruction = null; - + + int m_ClosureInstruction = -1; + private ByteCode m_bc = null; + bool m_UsesGlobalEnv; SymbolRef m_Env; SourceRef m_Begin, m_End; - + private ScriptLoadingContext lcontext; + List paramnames; public FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool usesGlobalEnv) : this(lcontext, false, usesGlobalEnv, false) @@ -30,24 +35,69 @@ public FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool usesGlob public FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSelfParam, bool isLambda) : this(lcontext, pushSelfParam, false, isLambda) { } - - + private FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSelfParam, bool usesGlobalEnv, bool isLambda) : base(lcontext) { + this.lcontext = lcontext; + if (m_UsesGlobalEnv = usesGlobalEnv) CheckTokenType(lcontext, TokenType.Function); + m_Annotations = lcontext.FunctionAnnotations.ToArray(); + lcontext.FunctionAnnotations = new List(); + + // Parse arguments // here lexer should be at the '(' or at the '|' - Token openRound = CheckTokenType(lcontext, isLambda ? TokenType.Lambda : TokenType.Brk_Open_Round); + //Token openRound = CheckTokenType(lcontext, isLambda ? TokenType.Lambda : TokenType.Brk_Open_Round); - List paramnames = BuildParamList(lcontext, pushSelfParam, openRound, isLambda); + Token openRound; + bool openCurly = false; + if (isLambda) + { + openRound = lcontext.Lexer.Current; + lcontext.Lexer.Next(); + if (openRound.Type == TokenType.Name) + paramnames = new List(new FunctionDefinitionStatement.FunctionParamRef[] {new FunctionDefinitionStatement.FunctionParamRef(openRound.Text)}); + else + paramnames = BuildParamList(lcontext, pushSelfParam, openRound); + } + else + { + openRound = CheckTokenType(lcontext, TokenType.Brk_Open_Round); + paramnames = BuildParamList(lcontext, pushSelfParam, openRound); + if (lcontext.Syntax != ScriptSyntax.Lua && lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) { + openCurly = true; + lcontext.Lexer.Next(); + } + } + + // skip arrow + bool arrowFunc = false; + if (lcontext.Lexer.Current.Type == TokenType.Arrow) { + arrowFunc = true; + lcontext.Lexer.Next(); + } + // here lexer is at first token of body m_Begin = openRound.GetSourceRefUpTo(lcontext.Lexer.Current); + + if(isLambda) + m_Statement = CreateLambdaBody(lcontext, arrowFunc); + else + m_Statement = CreateBody(lcontext, openCurly); + + + lcontext.Source.Refs.Add(m_Begin); + lcontext.Source.Refs.Add(m_End); - // create scope - lcontext.Scope.PushFunction(this, m_HasVarArgs); + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + resolved = true; + lcontext.Scope.PushFunction(this); if (m_UsesGlobalEnv) { @@ -57,76 +107,118 @@ private FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSel { lcontext.Scope.ForceEnvUpValue(); } - + m_ParamNames = DefineArguments(paramnames, lcontext); - - if(isLambda) - m_Statement = CreateLambdaBody(lcontext); - else - m_Statement = CreateBody(lcontext); - + + if(m_HasVarArgs) lcontext.Scope.SetHasVarArgs(); //Moved here + + m_Statement.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopFunction(); - - lcontext.Source.Refs.Add(m_Begin); - lcontext.Source.Refs.Add(m_End); - } - private Statement CreateLambdaBody(ScriptLoadingContext lcontext) + private Statement CreateLambdaBody(ScriptLoadingContext lcontext, bool arrowFunc) { Token start = lcontext.Lexer.Current; - Expression e = Expression.Expr(lcontext); - Token end = lcontext.Lexer.Current; - SourceRef sref = start.GetSourceRefUpTo(end); - Statement s = new ReturnStatement(lcontext, e, sref); - return s; + if (lcontext.Syntax != ScriptSyntax.Lua && start.Type == TokenType.Brk_Open_Curly) + { + lcontext.Lexer.Next(); + return CreateBody(lcontext, true); + } + else + { + Expression e = Expression.Expr(lcontext); + Token end = lcontext.Lexer.Current; + SourceRef sref = start.GetSourceRefUpTo(end); + Statement s = new ReturnStatement(lcontext, e, sref); + return s; + } } - private Statement CreateBody(ScriptLoadingContext lcontext) + private Statement CreateBody(ScriptLoadingContext lcontext, bool openCurly) { - Statement s = new CompositeStatement(lcontext); - - if (lcontext.Lexer.Current.Type != TokenType.End) - throw new SyntaxErrorException(lcontext.Lexer.Current, "'end' expected near '{0}'", lcontext.Lexer.Current.Text) + Statement s = new CompositeStatement(lcontext, openCurly ? BlockEndType.CloseCurly : BlockEndType.Normal); + + if (openCurly) { + if(lcontext.Lexer.Current.Type != TokenType.Brk_Close_Curly) { + throw new SyntaxErrorException(lcontext.Lexer.Current, "'}' expected near '{0}'", + lcontext.Lexer.Current.Text) + { + IsPrematureStreamTermination = (lcontext.Lexer.Current.Type == TokenType.Eof) + }; + } + } + else if (lcontext.Lexer.Current.Type != TokenType.End) + { + throw new SyntaxErrorException(lcontext.Lexer.Current, "'end' expected near '{0}'", + lcontext.Lexer.Current.Text) { IsPrematureStreamTermination = (lcontext.Lexer.Current.Type == TokenType.Eof) }; - + } m_End = lcontext.Lexer.Current.GetSourceRef(); lcontext.Lexer.Next(); return s; } - private List BuildParamList(ScriptLoadingContext lcontext, bool pushSelfParam, Token openBracketToken, bool isLambda) + private List BuildParamList(ScriptLoadingContext lcontext, bool pushSelfParam, Token openBracketToken) { - TokenType closeToken = isLambda ? TokenType.Lambda : TokenType.Brk_Close_Round; + TokenType closeToken = openBracketToken.Type == TokenType.Lambda ? TokenType.Lambda : TokenType.Brk_Close_Round; - List paramnames = new List(); + List paramnames = new List(); // method decls with ':' must push an implicit 'self' param if (pushSelfParam) - paramnames.Add("self"); + paramnames.Add(lcontext.Syntax == ScriptSyntax.CLike ? new FunctionDefinitionStatement.FunctionParamRef("this") : new FunctionDefinitionStatement.FunctionParamRef("self")); + bool parsingDefaultParams = false; while (lcontext.Lexer.Current.Type != closeToken) { Token t = lcontext.Lexer.Current; + bool nextAfterParamDeclr = true; if (t.Type == TokenType.Name) { - paramnames.Add(t.Text); + string paramName = t.Text; + + if (lcontext.Lexer.PeekNext().Type == TokenType.Op_Assignment) + { + parsingDefaultParams = true; + lcontext.Lexer.Next(); + lcontext.Lexer.Next(); + Expression defaultVal = Expr(lcontext); + nextAfterParamDeclr = false; + + paramnames.Add(new FunctionDefinitionStatement.FunctionParamRef(paramName, defaultVal)); + } + else + { + if (parsingDefaultParams) + { + throw new SyntaxErrorException(t, "after first parameter with default value a parameter without default value cannot be declared", t.Text) + { + IsPrematureStreamTermination = (t.Type == TokenType.Eof) + }; + } + + paramnames.Add(new FunctionDefinitionStatement.FunctionParamRef(paramName)); + } } else if (t.Type == TokenType.VarArgs) { m_HasVarArgs = true; - paramnames.Add(WellKnownSymbols.VARARGS); + paramnames.Add(new FunctionDefinitionStatement.FunctionParamRef(WellKnownSymbols.VARARGS)); } else UnexpectedTokenType(t); - lcontext.Lexer.Next(); + if (nextAfterParamDeclr) + { + lcontext.Lexer.Next(); + } t = lcontext.Lexer.Current; @@ -136,7 +228,7 @@ private List BuildParamList(ScriptLoadingContext lcontext, bool pushSelf } else { - CheckMatch(lcontext, openBracketToken, closeToken, isLambda ? "|" : ")"); + CheckMatch(lcontext, openBracketToken, closeToken, openBracketToken.Type == TokenType.Lambda ? "|" : ")"); break; } } @@ -147,7 +239,7 @@ private List BuildParamList(ScriptLoadingContext lcontext, bool pushSelf return paramnames; } - private SymbolRef[] DefineArguments(List paramnames, ScriptLoadingContext lcontext) + private SymbolRef[] DefineArguments(List paramnames, ScriptLoadingContext lcontext) { HashSet names = new HashSet(); @@ -155,10 +247,10 @@ private SymbolRef[] DefineArguments(List paramnames, ScriptLoadingContex for (int i = paramnames.Count - 1; i >= 0; i--) { - if (!names.Add(paramnames[i])) - paramnames[i] = paramnames[i] + "@" + i.ToString(); - - ret[i] = lcontext.Scope.DefineLocal(paramnames[i]); + if (!names.Add(paramnames[i].Name)) + paramnames[i].Name = paramnames[i].Name + "@" + i.ToString(); + paramnames[i].DefaultValue?.ResolveScope(lcontext); + ret[i] = lcontext.Scope.DefineLocal(paramnames[i].Name); } return ret; @@ -176,9 +268,11 @@ public SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol) m_Closure.Add(symbol); - if (m_ClosureInstruction != null) + if (m_ClosureInstruction != -1) { - m_ClosureInstruction.SymbolList = m_Closure.ToArray(); + var i = m_bc.Code[m_ClosureInstruction]; + i.SymbolList = m_Closure.ToArray(); + m_bc.Code[m_ClosureInstruction] = i; } return SymbolRef.Upvalue(symbol.i_Name, m_Closure.Count - 1); @@ -189,17 +283,26 @@ public override DynValue Eval(ScriptExecutionContext context) throw new DynamicExpressionException("Dynamic Expressions cannot define new functions."); } + private bool resolved = false; + public int CompileBody(ByteCode bc, string friendlyName) { + if (!resolved) throw new InternalErrorException("Function definition scope not resolved"); + //LoadingContext.Scope.PopFunction() + string funcName = friendlyName ?? ("<" + this.m_Begin.FormatLocation(bc.Script, true) + ">"); bc.PushSourceRef(m_Begin); - Instruction I = bc.Emit_Jump(OpCode.Jump, -1); + int I = bc.Emit_Jump(OpCode.Jump, -1); - Instruction meta = bc.Emit_Meta(funcName, OpCodeMetadataType.FunctionEntrypoint); - int metaip = bc.GetJumpPointForLastInstruction(); + int meta = bc.Emit_Meta(funcName, OpCodeMetadataType.FunctionEntrypoint); + if (m_Annotations.Length != 0) + { + bc.Emit_Annot(m_Annotations); + } + bc.Emit_BeginFn(m_StackFrame); bc.LoopTracker.Loops.Push(new LoopBoundary()); @@ -214,8 +317,25 @@ public int CompileBody(ByteCode bc, string friendlyName) } if (m_ParamNames.Length > 0) + { bc.Emit_Args(m_ParamNames); + for (int i = 0; i < m_ParamNames.Length; i++) + { + FunctionDefinitionStatement.FunctionParamRef fr = paramnames[i]; + SymbolRef sr = m_ParamNames[i]; + + if (fr.DefaultValue != null) + { + var jp = bc.Emit_JLclInit(sr, -1); + fr.DefaultValue.CompilePossibleLiteral(bc); + new SymbolRefExpression(lcontext, sr).CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + bc.Emit_Pop(); + bc.SetNumVal(jp, bc.GetJumpPointForNextInstruction()); + } + } + } + m_Statement.Compile(bc); bc.PopSourceRef(); @@ -225,8 +345,8 @@ public int CompileBody(ByteCode bc, string friendlyName) bc.LoopTracker.Loops.Pop(); - I.NumVal = bc.GetJumpPointForNextInstruction(); - meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; + bc.SetNumVal(I, bc.GetJumpPointForNextInstruction()); + bc.SetNumVal(meta, bc.GetJumpPointForLastInstruction() - meta); bc.PopSourceRef(); @@ -241,15 +361,24 @@ public int Compile(ByteCode bc, Func afterDecl, string friendlyName) //.Select((s, idx) => s.CloneLocalAndSetFrame(m_ClosureFrames[idx])) .ToArray(); + m_bc = bc; m_ClosureInstruction = bc.Emit_Closure(symbs, bc.GetJumpPointForNextInstruction()); int ops = afterDecl(); - m_ClosureInstruction.NumVal += 2 + ops; + var ins = bc.Code[m_ClosureInstruction]; + ins.NumVal += 2 + ops; + bc.Code[m_ClosureInstruction] = ins; } return CompileBody(bc, friendlyName); } + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; + } + public override void Compile(ByteCode bc) { diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/IndexExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/IndexExpression.cs index 1e81aeaf..d46e7397 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/IndexExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/IndexExpression.cs @@ -1,4 +1,6 @@ -using MoonSharp.Interpreter.Execution; +using System; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree.Expressions @@ -8,61 +10,153 @@ class IndexExpression : Expression, IVariable Expression m_BaseExp; Expression m_IndexExp; string m_Name; + private bool inc; + private bool dec; + private bool nilCheck; + private bool isLength = false; + public bool IsAssignment => inc || dec; - public IndexExpression(Expression baseExp, Expression indexExp, ScriptLoadingContext lcontext) + public bool NilCheck => nilCheck; + public Expression NilChainNext { get; set; } + + public IndexExpression(Expression baseExp, Expression indexExp, bool nilCheck, ScriptLoadingContext lcontext) : base(lcontext) { m_BaseExp = baseExp; m_IndexExp = indexExp; + this.nilCheck = nilCheck; + //inc/dec expr + if (lcontext.Lexer.Current.Type == TokenType.Op_Inc) + { + inc = true; + lcontext.Lexer.Next(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Op_Dec) + { + dec = true; + lcontext.Lexer.Next(); + } } - public IndexExpression(Expression baseExp, string name, ScriptLoadingContext lcontext) + public IndexExpression(Expression baseExp, Token nameToken, bool nilCheck, ScriptLoadingContext lcontext) : base(lcontext) { m_BaseExp = baseExp; - m_Name = name; + m_Name = nameToken.Text; + this.nilCheck = nilCheck; + // + if (lcontext.Syntax == ScriptSyntax.CLike && m_Name.Equals("length")) { + isLength = true; + } + //inc/dec expr + if (lcontext.Lexer.Current.Type == TokenType.Op_Inc) + { + if (isLength) + throw new SyntaxErrorException(lcontext.Lexer.Current, "Cannot assign to readonly property .length"); + inc = true; + lcontext.Lexer.Next(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Op_Dec) + { + if (isLength) + throw new SyntaxErrorException(lcontext.Lexer.Current, "Cannot assign to readonly property .length"); + dec = true; + lcontext.Lexer.Next(); + } } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_BaseExp.ResolveScope(lcontext); + m_IndexExp?.ResolveScope(lcontext); + } + public override void Compile(ByteCode bc) { m_BaseExp.Compile(bc); - + if (isLength) { + if (nilCheck) { + bc.NilChainTargets.Push(bc.Emit_Jump(OpCode.JNilChk, -1)); + } + bc.Emit_Operator(OpCode.Len); + if (bc.NilChainTargets.Count > 0 && NilChainNext == null) + { + bc.SetNumVal(bc.NilChainTargets.Pop(), bc.GetJumpPointForNextInstruction()); + } + return; + } + if (nilCheck) + { + bc.NilChainTargets.Push(bc.Emit_Jump(OpCode.JNilChk, -1)); + } if (m_Name != null) { - bc.Emit_Index(DynValue.NewString(m_Name), true); + bc.Emit_Index(m_Name, true); } - else if (m_IndexExp is LiteralExpression) + else if (m_IndexExp is LiteralExpression lit && lit.Value.Type == DataType.String) { - LiteralExpression lit = (LiteralExpression)m_IndexExp; - bc.Emit_Index(lit.Value); + bc.Emit_Index(lit.Value.String); } else { m_IndexExp.Compile(bc); bc.Emit_Index(isExpList: (m_IndexExp is ExprListExpression)); } + if (inc) + { + bc.Emit_Copy(0); + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Add); + CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + bc.Emit_Pop(); + } + else if (dec) + { + bc.Emit_Copy(0); + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Sub); + CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + bc.Emit_Pop(); + } + if (bc.NilChainTargets.Count > 0 && NilChainNext == null) + { + bc.SetNumVal(bc.NilChainTargets.Pop(), bc.GetJumpPointForNextInstruction()); + } } - public void CompileAssignment(ByteCode bc, int stackofs, int tupleidx) + public void CompileAssignment(ByteCode bc, Operator op, int stackofs, int tupleidx) { + if (isLength) + { + throw new SyntaxErrorException(null, "Cannot assign to readonly property .length"); + } + if (op != Operator.NotAnOperator) + { + Compile(bc); //left + bc.Emit_CopyValue(stackofs + 1, tupleidx); //right + bc.Emit_Operator(BinaryOperatorExpression.OperatorToOpCode(op)); + stackofs = 0; + tupleidx = 0; + } m_BaseExp.Compile(bc); if (m_Name != null) { - bc.Emit_IndexSet(stackofs, tupleidx, DynValue.NewString(m_Name), isNameIndex: true); + bc.Emit_IndexSet(stackofs, tupleidx, m_Name, isNameIndex: true); } - else if (m_IndexExp is LiteralExpression) + else if (m_IndexExp is LiteralExpression lit && lit.Value.Type == DataType.String) { - LiteralExpression lit = (LiteralExpression)m_IndexExp; - bc.Emit_IndexSet(stackofs, tupleidx, lit.Value); + bc.Emit_IndexSet(stackofs, tupleidx, lit.Value.String); } else { m_IndexExp.Compile(bc); bc.Emit_IndexSet(stackofs, tupleidx, isExpList: (m_IndexExp is ExprListExpression)); } + + if (op != Operator.NotAnOperator) bc.Emit_Pop(); } public override DynValue Eval(ScriptExecutionContext context) @@ -72,7 +166,13 @@ public override DynValue Eval(ScriptExecutionContext context) if (b.Type != DataType.Table) throw new DynamicExpressionException("Attempt to index non-table."); else if (i.IsNilOrNan()) throw new DynamicExpressionException("Attempt to index with nil or nan key."); - return b.Table.Get(i) ?? DynValue.Nil; + return b.Table.Get(i); + } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; } } } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/LiteralExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/LiteralExpression.cs index 9580c60c..a5c67534 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/LiteralExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/LiteralExpression.cs @@ -1,10 +1,11 @@ -using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Expressions { class LiteralExpression : Expression { - DynValue m_Value; + DynValue m_Value = DynValue.Void; public DynValue Value { @@ -27,11 +28,12 @@ public LiteralExpression(ScriptLoadingContext lcontext, Token t) case TokenType.Number: case TokenType.Number_Hex: case TokenType.Number_HexFloat: - m_Value = DynValue.NewNumber(t.GetNumberValue()).AsReadOnly(); + m_Value = DynValue.NewNumber(t.GetNumberValue()); break; case TokenType.String: case TokenType.String_Long: - m_Value = DynValue.NewString(t.Text).AsReadOnly(); + case TokenType.String_EndTemplate: + m_Value = DynValue.NewString(t.Text); break; case TokenType.True: m_Value = DynValue.True; @@ -46,12 +48,17 @@ public LiteralExpression(ScriptLoadingContext lcontext, Token t) throw new InternalErrorException("type mismatch"); } - if (m_Value == null) + if (m_Value.IsVoid()) throw new SyntaxErrorException(t, "unknown literal format near '{0}'", t.Text); lcontext.Lexer.Next(); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + //No-op + } + public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Literal(m_Value); @@ -61,5 +68,11 @@ public override DynValue Eval(ScriptExecutionContext context) { return m_Value; } + + public override bool EvalLiteral(out DynValue dv) + { + dv = m_Value; + return true; + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/SymbolRefExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/SymbolRefExpression.cs index 722c1d60..c47c3020 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/SymbolRefExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/SymbolRefExpression.cs @@ -1,4 +1,7 @@ -using MoonSharp.Interpreter.Execution; +using System; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree.Expressions { @@ -6,29 +9,53 @@ class SymbolRefExpression : Expression, IVariable { SymbolRef m_Ref; string m_VarName; + private Token T; + + private bool inc = false; + private bool dec = false; + + public bool IsAssignment => inc || dec; + public SymbolRef Symbol => m_Ref; public SymbolRefExpression(Token T, ScriptLoadingContext lcontext) : base(lcontext) { m_VarName = T.Text; + this.T = T; - if (T.Type == TokenType.VarArgs) + lcontext.Lexer.Next(); + //inc/dec expr + if (lcontext.Lexer.Current.Type == TokenType.Op_Inc) { - m_Ref = lcontext.Scope.Find(WellKnownSymbols.VARARGS); - - if (!lcontext.Scope.CurrentFunctionHasVarArgs()) - throw new SyntaxErrorException(T, "cannot use '...' outside a vararg function"); - - if (lcontext.IsDynamicExpression) - throw new DynamicExpressionException("cannot use '...' in a dynamic expression."); - } - else + inc = true; + lcontext.Lexer.Next(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Op_Dec) { - if (!lcontext.IsDynamicExpression) - m_Ref = lcontext.Scope.Find(m_VarName); + dec = true; + lcontext.Lexer.Next(); } + } - lcontext.Lexer.Next(); + public override void ResolveScope(ScriptLoadingContext lcontext) + { + if (m_Ref == null) { + if (T.Type == TokenType.VarArgs) + { + m_Ref = lcontext.Scope.Find(WellKnownSymbols.VARARGS); + + if (!lcontext.Scope.CurrentFunctionHasVarArgs()) + throw new SyntaxErrorException(T, "cannot use '...' outside a vararg function"); + + if (lcontext.IsDynamicExpression) + throw new DynamicExpressionException("cannot use '...' in a dynamic expression."); + } + else + { + if (!lcontext.IsDynamicExpression) + m_Ref = lcontext.Scope.Find(m_VarName); + } + } } public SymbolRefExpression(ScriptLoadingContext lcontext, SymbolRef refr) @@ -45,12 +72,38 @@ public SymbolRefExpression(ScriptLoadingContext lcontext, SymbolRef refr) public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Load(m_Ref); + if (inc) + { + bc.Emit_Copy(0); //do copy before returning number + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Add); + bc.Emit_Store(m_Ref, 0, 0); + bc.Emit_Pop(); + } + else if (dec) + { + bc.Emit_Copy(0); //do copy before returning number + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Sub); + bc.Emit_Store(m_Ref, 0, 0); + bc.Emit_Pop(); + } } - public void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx) + public void CompileAssignment(Execution.VM.ByteCode bc, Operator op, int stackofs, int tupleidx) { - bc.Emit_Store(m_Ref, stackofs, tupleidx); + if (op != Operator.NotAnOperator) + { + bc.Emit_Load(m_Ref); //left + bc.Emit_CopyValue(stackofs + 1, tupleidx); //right + bc.Emit_Operator(BinaryOperatorExpression.OperatorToOpCode(op)); + bc.Emit_Store(m_Ref, 0, 0); + bc.Emit_Pop(); + } + else { + bc.Emit_Store(m_Ref, stackofs, tupleidx); + } } public override DynValue Eval(ScriptExecutionContext context) @@ -58,6 +111,12 @@ public override DynValue Eval(ScriptExecutionContext context) return context.EvaluateSymbolByName(m_VarName); } + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; + } + public override SymbolRef FindDynamic(ScriptExecutionContext context) { return context.FindSymbolByName(m_VarName); diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/TableConstructor.cs b/src/MoonSharp.Interpreter/Tree/Expressions/TableConstructor.cs index be4093ca..6b3be816 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/TableConstructor.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/TableConstructor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Expressions @@ -14,19 +15,38 @@ public TableConstructor(ScriptLoadingContext lcontext, bool shared) { m_Shared = shared; - // here lexer is at the '{', go on - CheckTokenType(lcontext, TokenType.Brk_Open_Curly, TokenType.Brk_Open_Curly_Shared); + // here lexer is at the '{' (or '[' for c-like), go on + TokenType closeType = TokenType.Brk_Close_Curly; + if (lcontext.Syntax != ScriptSyntax.Lua && lcontext.Lexer.Current.Type == TokenType.Brk_Open_Square) { + closeType = TokenType.Brk_Close_Square; + lcontext.Lexer.Next(); + } + else { + CheckTokenType(lcontext, TokenType.Brk_Open_Curly, TokenType.Brk_Open_Curly_Shared); + } - while (lcontext.Lexer.Current.Type != TokenType.Brk_Close_Curly) + while (lcontext.Lexer.Current.Type != closeType) { switch (lcontext.Lexer.Current.Type) { + case TokenType.String: + if (lcontext.Syntax != ScriptSyntax.Lua) + { + Token assign = lcontext.Lexer.PeekNext(); + if(assign.Type == TokenType.Colon) + StructField(lcontext); + else + ArrayField(lcontext); + } + else ArrayField(lcontext); + break; case TokenType.Name: { Token assign = lcontext.Lexer.PeekNext(); - if (assign.Type == TokenType.Op_Assignment) - StructField(lcontext); + if (assign.Type == TokenType.Op_Assignment || + assign.Type == TokenType.Colon && lcontext.Syntax != ScriptSyntax.Lua) + StructField(lcontext); else ArrayField(lcontext); } @@ -51,18 +71,32 @@ public TableConstructor(ScriptLoadingContext lcontext, bool shared) } } - CheckTokenType(lcontext, TokenType.Brk_Close_Curly); + CheckTokenType(lcontext, closeType); } private void MapField(ScriptLoadingContext lcontext) { + lcontext.Lexer.SavePos(); lcontext.Lexer.Next(); // skip '[' Expression key = Expr(lcontext); - + if (lcontext.Syntax != ScriptSyntax.Lua && + lcontext.Lexer.Current.Type == TokenType.Comma) { + lcontext.Lexer.RestorePos(); + ArrayField(lcontext); + return; + } CheckTokenType(lcontext, TokenType.Brk_Close_Square); + if (lcontext.Syntax != ScriptSyntax.Lua && + lcontext.Lexer.Current.Type != TokenType.Op_Assignment && + lcontext.Lexer.Current.Type != TokenType.Colon) + { + lcontext.Lexer.RestorePos(); + ArrayField(lcontext); + return; + } - CheckTokenType(lcontext, TokenType.Op_Assignment); + CheckTokenTypeEx(lcontext, TokenType.Op_Assignment, TokenType.Colon); Expression value = Expr(lcontext); @@ -74,7 +108,7 @@ private void StructField(ScriptLoadingContext lcontext) Expression key = new LiteralExpression(lcontext, DynValue.NewString(lcontext.Lexer.Current.Text)); lcontext.Lexer.Next(); - CheckTokenType(lcontext, TokenType.Op_Assignment); + CheckTokenTypeEx(lcontext, TokenType.Op_Assignment, TokenType.Colon); Expression value = Expr(lcontext); @@ -88,6 +122,69 @@ private void ArrayField(ScriptLoadingContext lcontext) m_PositionalValues.Add(e); } + + /// + /// Different to EvalLiteral, as this can't be stored in regular code. + /// dv is a prime table on success + /// + public bool TryGetLiteral(out DynValue dv) + { + dv = DynValue.Nil; + var tblVal = DynValue.NewPrimeTable(); + var table = tblVal.Table; + foreach (var kvp in m_CtorArgs) + { + DynValue key, value; + //Key must be literal + if (!kvp.Key.EvalLiteral(out key)) return false; + //Value can be prime table or literal + if (kvp.Value is TableConstructor tbl) + { + if (!tbl.TryGetLiteral(out value)) + { + return false; + } + } + else if (!kvp.Value.EvalLiteral(out value)) + { + return false; + } + table.Set(key, value); + } + for (int i = 0; i < m_PositionalValues.Count; i++) + { + var exp = m_PositionalValues[i]; + DynValue value; + if (exp is TableConstructor tbl) + { + if (!tbl.TryGetLiteral(out value)) + { + return false; + } + } + else if (!exp.EvalLiteral(out value)) + { + return false; + } + table.Set(i + 1, value); + } + dv = tblVal; + return true; + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + foreach (var kvp in m_CtorArgs) + { + kvp.Key.ResolveScope(lcontext); + kvp.Value.ResolveScope(lcontext); + } + foreach (var p in m_PositionalValues) + { + p.ResolveScope(lcontext); + } + } + public override void Compile(Execution.VM.ByteCode bc) { @@ -131,5 +228,11 @@ public override DynValue Eval(ScriptExecutionContext context) return tval; } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/TemplatedStringExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/TemplatedStringExpression.cs new file mode 100644 index 00000000..7725c19f --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Expressions/TemplatedStringExpression.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; + +namespace MoonSharp.Interpreter.Tree.Expressions +{ + class TemplatedStringExpression : Expression + { + private List arguments = new List(); + private string formatString; + + static string EscapeForFormat(string s) => s.Replace("{", "{{").Replace("}", "}}"); + + public TemplatedStringExpression(ScriptLoadingContext lcontext, Token startToken) : base(lcontext) + { + var builder = new StringBuilder(); + builder.Append(EscapeForFormat(startToken.Text)); + lcontext.Lexer.Next(); + int i = 0; + while (lcontext.Lexer.Current.Type != TokenType.String_EndTemplate) { + if (lcontext.Lexer.Current.Type == TokenType.Eof) { + throw new SyntaxErrorException(lcontext.Lexer.Current, "`` expected") + { + IsPrematureStreamTermination = true + }; + } + if (lcontext.Lexer.Current.Type != TokenType.String_TemplateFragment) { + builder.Append("{").Append(i++).Append("}"); + arguments.Add(Expr(lcontext)); + } + else { + builder.Append(EscapeForFormat(lcontext.Lexer.Current.Text)); + lcontext.Lexer.Next(); + } + } + builder.Append(EscapeForFormat(lcontext.Lexer.Current.Text)); + lcontext.Lexer.Next(); + formatString = builder.ToString(); + } + + public override void Compile(ByteCode bc) + { + bc.Emit_Literal(DynValue.NewString(formatString)); + foreach (var exp in arguments) { + exp.CompilePossibleLiteral(bc); + } + bc.Emit_StrFormat(arguments.Count); + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + foreach(var exp in arguments) + exp.ResolveScope(lcontext); + } + + public override DynValue Eval(ScriptExecutionContext context) + { + return DynValue.NewString(string.Format(formatString, arguments.Select(x => + { + var dyn = x.Eval(context); + if (dyn.Type == DataType.String) return dyn.String; + else if (dyn.Type == DataType.Number) return dyn.Number.ToString(); + else if (dyn.Type == DataType.Boolean) { + return dyn.Boolean ? "true" : "false"; + } + else { + //TODO: I think this is incorrect + throw new DynamicExpressionException("Cannot call __tostring in dynamic expression"); + } + }))); + } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + return false; + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/TernaryExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/TernaryExpression.cs new file mode 100644 index 00000000..c1e10291 --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Expressions/TernaryExpression.cs @@ -0,0 +1,72 @@ +using System; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; + +namespace MoonSharp.Interpreter.Tree.Expressions +{ + class TernaryExpression : Expression + { + private Expression condition; + private Expression exp1; + private Expression exp2; + public TernaryExpression(ScriptLoadingContext lcontext, Expression cond) : base(lcontext) + { + this.condition = cond; + CheckTokenType(lcontext, TokenType.Ternary); + exp1 = Expr(lcontext); + CheckTokenType(lcontext, TokenType.Colon); + exp2 = Expr(lcontext); + } + + public override void Compile(ByteCode bc) + { + if (condition.EvalLiteral(out var evaluated)) + { + if(evaluated.CastToBool()) + exp1.CompilePossibleLiteral(bc); + else + exp2.CompilePossibleLiteral(bc); + } + else + { + condition.Compile(bc); + int j1 = bc.Emit_Jump(OpCode.Jf, -1); + exp1.CompilePossibleLiteral(bc); + int j2 = bc.Emit_Jump(OpCode.Jump, -1); + bc.SetNumVal(j1, bc.GetJumpPointForNextInstruction()); //JF to here + exp2.CompilePossibleLiteral(bc); + bc.SetNumVal(j2, bc.GetJumpPointForNextInstruction()); //JUMP to here + } + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + condition.ResolveScope(lcontext); + exp1.ResolveScope(lcontext); + exp2.ResolveScope(lcontext); + } + + public override DynValue Eval(ScriptExecutionContext context) + { + if (condition.Eval(context).CastToBool()) + return exp1.Eval(context); + else + return exp2.Eval(context); + } + + public override bool EvalLiteral(out DynValue dv) + { + if (condition.EvalLiteral(out var cond)) { + if (cond.CastToBool()) + { + return exp1.EvalLiteral(out dv); + } + else { + return exp2.EvalLiteral(out dv); + } + } + dv = DynValue.Nil; + return false; + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Expressions/UnaryOperatorExpression.cs b/src/MoonSharp.Interpreter/Tree/Expressions/UnaryOperatorExpression.cs index ec763585..442ce024 100644 --- a/src/MoonSharp.Interpreter/Tree/Expressions/UnaryOperatorExpression.cs +++ b/src/MoonSharp.Interpreter/Tree/Expressions/UnaryOperatorExpression.cs @@ -1,4 +1,6 @@ -using MoonSharp.Interpreter.Execution; +using System; +using MoonSharp.Interpreter.DataStructs; +using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree.Expressions @@ -7,29 +9,69 @@ class UnaryOperatorExpression : Expression { Expression m_Exp; string m_OpText; + private Token tok; public UnaryOperatorExpression(ScriptLoadingContext lcontext, Expression subExpression, Token unaryOpToken) : base(lcontext) { m_OpText = unaryOpToken.Text; + tok = unaryOpToken; m_Exp = subExpression; } + public bool IsNegativeNumber => m_Exp is LiteralExpression && m_OpText == "-"; + public override void Compile(ByteCode bc) { - m_Exp.Compile(bc); - switch (m_OpText) { + //prefix inc/dec operators - return number AFTER calculation + case "++": + { + if (m_Exp is IVariable var) + { + m_Exp.Compile(bc); + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Add); + //assignment doesn't pop + var.CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + } + else + throw new SyntaxErrorException(tok, "'++' can only be used with indexers or variables", + "++"); + break; + } + case "--": + { + if (m_Exp is IVariable var) + { + m_Exp.Compile(bc); + bc.Emit_Literal(DynValue.NewNumber(1.0)); + bc.Emit_Operator(OpCode.Sub); + var.CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + } + else + throw new SyntaxErrorException(tok, "'--' can only be used with indexers or variables", + "--"); + break; + } + case "~": + m_Exp.Compile(bc); + bc.Emit_Operator(OpCode.BNot); + break; + case "!": case "not": + m_Exp.Compile(bc); bc.Emit_Operator(OpCode.Not); break; case "#": + m_Exp.Compile(bc); bc.Emit_Operator(OpCode.Len); break; case "-": + m_Exp.Compile(bc); bc.Emit_Operator(OpCode.Neg); break; default: @@ -39,12 +81,29 @@ public override void Compile(ByteCode bc) } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Exp.ResolveScope(lcontext); + } + public override DynValue Eval(ScriptExecutionContext context) { DynValue v = m_Exp.Eval(context).ToScalar(); switch (m_OpText) { + case "~": + { + double? d = v.CastToNumber(); + + if (d.HasValue) + { + return DynValue.NewNumber(~(int)d.Value); + } + + throw new DynamicExpressionException("Attempt to perform arithmetic on non-numbers."); + } + case "!": case "not": return DynValue.NewBoolean(!v.CastToBool()); case "#": @@ -62,5 +121,48 @@ public override DynValue Eval(ScriptExecutionContext context) throw new DynamicExpressionException("Unexpected unary operator '{0}'", m_OpText); } } + + public override bool EvalLiteral(out DynValue dv) + { + dv = DynValue.Nil; + if (!m_Exp.EvalLiteral(out var v)) + { + return false; + } + switch (m_OpText) + { + case "!": + case "not": + dv = DynValue.NewBoolean(!v.CastToBool()); + return true; + case "#": + case "++": + case "--": + return false; + case "-": + { + double? d = v.CastToNumber(); + if (d.HasValue) + { + dv = DynValue.NewNumber(-d.Value); + return true; + } + + break; + } + case "~": + { + double? d = v.CastToNumber(); + if (d.HasValue) + { + dv = DynValue.NewNumber(~(int)d.Value); + return true; + } + break; + } + } + //Could not evaluate literal - give runtime error later + return false; + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Fast_Interface/Loader_Fast.cs b/src/MoonSharp.Interpreter/Tree/Fast_Interface/Loader_Fast.cs index e3775921..f3eeac05 100644 --- a/src/MoonSharp.Interpreter/Tree/Fast_Interface/Loader_Fast.cs +++ b/src/MoonSharp.Interpreter/Tree/Fast_Interface/Loader_Fast.cs @@ -19,7 +19,11 @@ internal static DynamicExprExpression LoadDynamicExpr(Script script, SourceCode Expression exp; using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) + { exp = Expression.Expr(lcontext); + lcontext.Scope = new BuildTimeScope(); + exp.ResolveScope(lcontext); + } return new DynamicExprExpression(exp, lcontext); } @@ -35,21 +39,27 @@ private static ScriptLoadingContext CreateLoadingContext(Script script, SourceCo { return new ScriptLoadingContext(script) { - Scope = new BuildTimeScope(), Source = source, - Lexer = new Lexer(source.SourceID, source.Code, true) + Lexer = new Lexer(source.SourceID, source.Code, true, script.Options.Syntax != ScriptSyntax.Lua, script.Options.Syntax == ScriptSyntax.CLike, script.Options.Directives), + Syntax = script.Options.Syntax }; } internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecode) { ScriptLoadingContext lcontext = CreateLoadingContext(script, source); + #if !DEBUG_PARSER try { + #endif Statement stat; using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) + { stat = new ChunkStatement(lcontext); + lcontext.Scope = new BuildTimeScope(); + stat.ResolveScope(lcontext); + } int beginIp = -1; @@ -67,6 +77,8 @@ internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecod //Debug_DumpByteCode(bytecode, source.SourceID); return beginIp; +#if !DEBUG_PARSER + } catch (SyntaxErrorException ex) { @@ -74,6 +86,7 @@ internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecod ex.Rethrow(); throw; } +#endif } internal static int LoadFunction(Script script, SourceCode source, ByteCode bytecode, bool usesGlobalEnv) @@ -85,7 +98,11 @@ internal static int LoadFunction(Script script, SourceCode source, ByteCode byte FunctionDefinitionExpression fnx; using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) + { fnx = new FunctionDefinitionExpression(lcontext, usesGlobalEnv); + lcontext.Scope = new BuildTimeScope(); + fnx.ResolveScope(lcontext); + } int beginIp = -1; diff --git a/src/MoonSharp.Interpreter/Tree/IVariable.cs b/src/MoonSharp.Interpreter/Tree/IVariable.cs index 1130a5a0..fa1e15c7 100644 --- a/src/MoonSharp.Interpreter/Tree/IVariable.cs +++ b/src/MoonSharp.Interpreter/Tree/IVariable.cs @@ -1,8 +1,12 @@  +using MoonSharp.Interpreter.Tree.Expressions; + namespace MoonSharp.Interpreter.Tree { interface IVariable { - void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx); + void CompileAssignment(Execution.VM.ByteCode bc, Operator op, int stackofs, int tupleidx); + + bool IsAssignment { get; } } } diff --git a/src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs b/src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs index de47d322..6193cf3e 100755 --- a/src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs +++ b/src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs @@ -1,4 +1,6 @@ -using System.Text; +using System; +using System.Collections.Generic; +using System.Text; namespace MoonSharp.Interpreter.Tree { @@ -13,8 +15,11 @@ class Lexer int m_Col = 0; int m_SourceId; bool m_AutoSkipComments = false; + bool m_Extended = false; + private bool m_IncDec; + private HashSet m_Directives; - public Lexer(int sourceID, string scriptContent, bool autoSkipComments) + public Lexer(int sourceID, string scriptContent, bool autoSkipComments, bool extended, bool incdec, HashSet directives) { m_Code = scriptContent; m_SourceId = sourceID; @@ -24,6 +29,9 @@ public Lexer(int sourceID, string scriptContent, bool autoSkipComments) m_Code = m_Code.Substring(1); m_AutoSkipComments = autoSkipComments; + m_Extended = extended; + m_IncDec = incdec; + m_Directives = directives; } public Token Current @@ -55,12 +63,82 @@ public void Next() m_Current = FetchNewToken(); } + private List templateStringState = new List(); + + void PushTemplateString() + { + templateStringState.Add(0); + } + + bool InTemplateString() => templateStringState.Count > 0; + + void TemplateStringAddBracket() + { + if (InTemplateString()) { + templateStringState[templateStringState.Count - 1]++; + } + } + + bool ReturnToTemplateString() + { + var c = templateStringState[templateStringState.Count - 1]; + if (c == 0) return true; + templateStringState[templateStringState.Count - 1]--; + return false; + } + + void PopTemplateString() + { + templateStringState.RemoveAt(templateStringState.Count - 1); + } + + + struct Snapshot + { + public int Cursor; + public Token Current; + public int Line; + public int Col; + public int[] TemplateStringState; + } + + + private Snapshot s; + + + + public void SavePos() + { + s = new Snapshot() { + Cursor = m_Cursor, + Current = m_Current, + Line = m_Line, + Col = m_Col, + TemplateStringState = templateStringState.ToArray(), + }; + } + + public void RestorePos() + { + m_Cursor = s.Cursor; + m_Current = s.Current; + m_Line = s.Line; + m_Col = s.Col; + templateStringState = new List(s.TemplateStringState); + } + public Token PeekNext() { int snapshot = m_Cursor; Token current = m_Current; int line = m_Line; int col = m_Col; + //Save the template string state + int stateC = templateStringState.Count; + int lastC = 0; + if (templateStringState.Count > 0) { + lastC = templateStringState[templateStringState.Count - 1]; + } Next(); Token t = Current; @@ -69,7 +147,19 @@ public Token PeekNext() m_Current = current; m_Line = line; m_Col = col; - + //Restore the template string state + if (templateStringState.Count < stateC) + { + templateStringState.Add(lastC); + } + else if (templateStringState.Count > stateC) + { + templateStringState.RemoveAt(templateStringState.Count - 1); + } + else if (stateC != 0) + { + templateStringState[templateStringState.Count - 1] = lastC; + } return t; } @@ -152,43 +242,204 @@ private Token ReadToken() switch (c) { + case '@' when m_IncDec: + return PotentiallyDoubleCharOperator('@', TokenType.FunctionAnnotation, TokenType.ChunkAnnotation, + fromLine, fromCol); case '|': - CursorCharNext(); - return CreateToken(TokenType.Lambda, fromLine, fromCol, "|"); + if (m_IncDec) + { + var next = CursorCharNext(); + if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_OrEq, fromLine, fromCol, "|="); + } + else if (next == '|') + { + CursorCharNext(); + return CreateToken(TokenType.Or, fromLine, fromCol, "||"); + } + return CreateToken(TokenType.Op_Or, fromLine, fromCol, "|"); + } + else if (m_Extended) { + return PotentiallyDoubleCharOperator('|', TokenType.Lambda, TokenType.Or, fromLine, fromCol); + } + else + { + CursorCharNext(); + return CreateToken(TokenType.Lambda, fromLine, fromCol, "|"); + } case ';': CursorCharNext(); return CreateToken(TokenType.SemiColon, fromLine, fromCol, ";"); + case '&' when m_Extended: + { + var next = CursorCharNext(); + if (next == '&') { + CursorCharNext(); + return CreateToken(TokenType.And, fromLine, fromCol, "&&"); + } + else if (m_IncDec && next == '=') { + CursorCharNext(); + return CreateToken(TokenType.Op_AndEq, fromLine, fromCol, "&="); + } + else if (m_IncDec) { + return CreateToken(TokenType.Op_And, fromLine, fromCol, "&"); + } + else { + throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", CursorChar()); + } + } case '=': - return PotentiallyDoubleCharOperator('=', TokenType.Op_Assignment, TokenType.Op_Equal, fromLine, fromCol); - case '<': + { + if (m_Extended) + { + char next = CursorCharNext(); + if (next == '=') { + CursorCharNext(); + return CreateToken(TokenType.Op_Equal, fromLine, fromCol, "=="); + } else if (next == '>') { + CursorCharNext(); + return CreateToken(TokenType.Arrow, fromLine, fromCol, "=>"); + } + else + { + return CreateToken(TokenType.Op_Assignment, fromLine, fromCol, "="); + } + } + else + { + return PotentiallyDoubleCharOperator('=', TokenType.Op_Assignment, TokenType.Op_Equal, fromLine, + fromCol); + } + } + case '<' when m_IncDec: + { + char next = CursorCharNext(); + if (next == '<') + { + return PotentiallyDoubleCharOperator('=', TokenType.Op_LShift, TokenType.Op_LShiftEq, fromLine, fromCol); + } + if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_LessThanEqual, fromLine, fromCol, "<="); + } + return CreateToken(TokenType.Op_LessThan, fromLine, fromCol, "<"); + } + case '>' when m_IncDec: + { + char next = CursorCharNext(); + if (next == '>') + { + next = CursorCharNext(); + if (next == '>') { + //>>>, >>>= logical shift (zero) + return PotentiallyDoubleCharOperator('=', + TokenType.Op_RShiftLogical, TokenType.Op_RShiftLogicalEq, + fromLine, fromCol + ); + } + //>>, >>= - arithmetic shift (sign bit) + return PotentiallyDoubleCharOperator('=', + TokenType.Op_RShiftArithmetic, TokenType.Op_RShiftArithmeticEq, + fromLine, fromCol + ); + } + else if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_GreaterThanEqual, fromLine, fromCol, ">="); + } + return CreateToken(TokenType.Op_GreaterThan, fromLine, fromCol, ">"); + } + case '<' when !m_IncDec: return PotentiallyDoubleCharOperator('=', TokenType.Op_LessThan, TokenType.Op_LessThanEqual, fromLine, fromCol); - case '>': + case '>' when !m_IncDec: return PotentiallyDoubleCharOperator('=', TokenType.Op_GreaterThan, TokenType.Op_GreaterThanEqual, fromLine, fromCol); - case '~': - case '!': + case '!' when m_Extended: + return PotentiallyDoubleCharOperator('=', TokenType.Not, TokenType.Op_NotEqual, fromLine, fromCol); + case '~' when m_IncDec: + return CreateSingleCharToken(TokenType.Op_Not, fromLine, fromCol); + case '!' when !m_Extended: + case '~' when !m_IncDec: if (CursorCharNext() != '=') throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", c); - CursorCharNext(); return CreateToken(TokenType.Op_NotEqual, fromLine, fromCol, "~="); case '.': { char next = CursorCharNext(); if (next == '.') - return PotentiallyDoubleCharOperator('.', TokenType.Op_Concat, TokenType.VarArgs, fromLine, fromCol); + { + if (m_Extended) + { + next = CursorCharNext(); + if (next == '.') { + CursorCharNext(); + return CreateToken(TokenType.VarArgs, fromLine, fromCol, "..."); + } else if (next == '=') { + CursorCharNext(); + return CreateToken(TokenType.Op_ConcatEq, fromLine, fromCol, "..="); + } + else { + return CreateToken(TokenType.Op_Concat, fromLine, fromCol, ".."); + } + } + else { + return PotentiallyDoubleCharOperator('.', TokenType.Op_Concat, TokenType.VarArgs, + fromLine, + fromCol); + } + } else if (LexerUtils.CharIsDigit(next)) return ReadNumberToken(fromLine, fromCol, true); else return CreateToken(TokenType.Dot, fromLine, fromCol, "."); } case '+': - return CreateSingleCharToken(TokenType.Op_Add, fromLine, fromCol); + { + if (m_Extended) + { + char next = CursorCharNext(); + if (m_IncDec && next == '+') + { + CursorCharNext(); + return CreateToken(TokenType.Op_Inc, fromLine, fromCol, "++"); + } + else if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_AddEq, fromLine, fromCol, "+="); + } + else + { + return CreateToken(TokenType.Op_Add, fromLine, fromCol, "+"); + } + } + else + { + return CreateSingleCharToken(TokenType.Op_Add, fromLine, fromCol); + } + } case '-': { char next = CursorCharNext(); if (next == '-') { - return ReadComment(fromLine, fromCol); + if (m_IncDec) + { + CursorCharNext(); + return CreateToken(TokenType.Op_Dec, fromLine, fromCol, "--"); + } + else + return ReadComment(fromLine, fromCol); + + } + else if (m_Extended && next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_SubEq, fromLine, fromCol, "-="); } else { @@ -196,12 +447,57 @@ private Token ReadToken() } } case '*': - return CreateSingleCharToken(TokenType.Op_Mul, fromLine, fromCol); + if (m_Extended) + { + char next = CursorCharNext(); + if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_MulEq, fromLine, fromCol, "*="); + } + else if (next == '*') + { + return PotentiallyDoubleCharOperator('=', TokenType.Op_Pwr, TokenType.Op_PwrEq, fromLine, + fromCol); + } + else + { + return CreateToken(TokenType.Op_Mul, fromLine, fromCol, "*"); + } + } else { + return CreateSingleCharToken(TokenType.Op_Mul, fromLine, fromCol); + } case '/': + if (m_Extended) + { + char next = CursorCharNext(); + if (next == '/') return ReadComment(fromLine, fromCol); + else if (next == '*') + { + CursorCharNext(); + return ReadCMultilineComment(fromLine, fromCol); + } + else if (next == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_DivEq, fromLine, fromCol, "/="); + } + else { + return CreateToken(TokenType.Op_Div, fromLine, fromCol, "/"); + } + } return CreateSingleCharToken(TokenType.Op_Div, fromLine, fromCol); case '%': + if (m_Extended) + return PotentiallyDoubleCharOperator('=', TokenType.Op_Mod, TokenType.Op_ModEq, fromLine, + fromCol); return CreateSingleCharToken(TokenType.Op_Mod, fromLine, fromCol); case '^': + if (m_IncDec) + { + return PotentiallyDoubleCharOperator('=', TokenType.Op_Xor, TokenType.Op_XorEq, fromLine, + fromCol); + } return CreateSingleCharToken(TokenType.Op_Pwr, fromLine, fromCol); case '$': return PotentiallyDoubleCharOperator('{', TokenType.Op_Dollar, TokenType.Brk_Open_Curly_Shared, fromLine, fromCol); @@ -227,13 +523,74 @@ private Token ReadToken() case ')': return CreateSingleCharToken(TokenType.Brk_Close_Round, fromLine, fromCol); case '{': + TemplateStringAddBracket(); return CreateSingleCharToken(TokenType.Brk_Open_Curly, fromLine, fromCol); - case '}': + case '}' when InTemplateString(): { + if (ReturnToTemplateString()) { + return ReadTemplateString(fromLine, fromCol, false); + } + else { + return CreateSingleCharToken(TokenType.Brk_Close_Curly, fromLine, fromCol); + } + } + case '}' when !InTemplateString(): return CreateSingleCharToken(TokenType.Brk_Close_Curly, fromLine, fromCol); case ',': return CreateSingleCharToken(TokenType.Comma, fromLine, fromCol); + case '?' when m_IncDec: + { + char next = CursorCharNext(); + + if (next == '?') + { + char next2 = CursorCharNext(); + if (next2 == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_NilCoalescingAssignment, fromLine, fromCol, "??="); + } + + return CreateToken(TokenType.Op_NilCoalesce, fromLine, fromCol, "??"); + } + + if (next == '!') + { + char next2 = CursorCharNext(); + if (next2 == '=') + { + CursorCharNext(); + return CreateToken(TokenType.Op_NilCoalescingAssignmentInverse, fromLine, fromCol, "?!="); + } + + return CreateToken(TokenType.Op_NilCoalesceInverse, fromLine, fromCol, "?!"); + } + if (next == '.') + { + CursorCharNext(); + return CreateToken(TokenType.DotNil, fromLine, fromCol, "?."); + } + if (next == '[') + { + CursorCharNext(); + return CreateToken(TokenType.BrkOpenSquareNil, fromLine, fromCol, "?["); + } + return CreateToken(TokenType.Ternary, fromLine, fromCol, "?"); + } case ':': return PotentiallyDoubleCharOperator(':', TokenType.Colon, TokenType.DoubleColon, fromLine, fromCol); + case '`': + { + char next = CursorCharNext(); + if (next == '`') + { + PushTemplateString(); + return ReadTemplateString(fromLine, fromCol, true); + } + throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", CursorChar()) + { + IsPrematureStreamTermination = true + }; + } case '"': case '\'': return ReadSimpleStringToken(fromLine, fromCol); @@ -259,6 +616,69 @@ private Token ReadToken() } } + + Token ReadTemplateString(int fromLine, int fromCol, bool isStart) + { + StringBuilder text = new StringBuilder(32); + + for (char c = CursorCharNext(); CursorNotEof(); c = CursorCharNext()) + { + redo_Loop: + + if (c == '\\') + { + text.Append(c); + c = CursorCharNext(); + text.Append(c); + + if (c == '\r') + { + c = CursorCharNext(); + if (c == '\n') + text.Append(c); + else + goto redo_Loop; + } + else if (c == 'z') + { + c = CursorCharNext(); + + if (char.IsWhiteSpace(c)) + SkipWhiteSpace(); + + c = CursorChar(); + + goto redo_Loop; + } + } + else if (c == '{') + { + CursorCharNext(); + Token t = CreateToken(TokenType.String_TemplateFragment, fromLine, fromCol); + t.Text = LexerUtils.UnescapeLuaString(t, text.ToString()); + return t; + } + else if (c == '`' && CursorMatches("``")) + { + CursorCharNext(); + CursorCharNext(); + PopTemplateString(); + Token t = CreateToken(isStart ? TokenType.String_Long : TokenType.String_EndTemplate, fromLine, fromCol); + t.Text = LexerUtils.UnescapeLuaString(t, text.ToString()); + return t; + } + else + { + text.Append(c); + } + } + + throw new SyntaxErrorException( + CreateToken(TokenType.Invalid, fromLine, fromCol), + "unfinished string near '{0}'", text.ToString()) { IsPrematureStreamTermination = true }; + } + + private string ReadLongString(int fromLine, int fromCol, string startpattern, string subtypeforerrors) { // here we are at the first '=' or second '[' @@ -374,6 +794,7 @@ private Token ReadNumberToken(int fromLine, int fromCol, bool leadingDot) } else if (c == '.' && !dotAdded) { + if (CursorMatches("..")) break; dotAdded = true; text.Append(c); } @@ -432,6 +853,32 @@ private Token ReadHashBang(int fromLine, int fromCol) return CreateToken(TokenType.HashBang, fromLine, fromCol, text.ToString()); } + private Token ReadCMultilineComment(int fromLine, int fromCol) + { + StringBuilder text = new StringBuilder(32); + + for (char c = CursorChar(); ; c = CursorCharNext()) + { + if (c == '\r') continue; + if (c == '\0' || !CursorNotEof()) + { + throw new SyntaxErrorException( + CreateToken(TokenType.Invalid, fromLine, fromCol), + "unfinished multiline comment near '{0}'", text.ToString()) { IsPrematureStreamTermination = true }; + } + else if (c == '*' && CursorMatches("*/")) + { + CursorCharNext(); + CursorCharNext(); + return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString()); + } + else + { + text.Append(c); + } + } + } + private Token ReadComment(int fromLine, int fromCol) { @@ -450,7 +897,6 @@ private Token ReadComment(int fromLine, int fromCol) } else if (c == '\n') { - extraneousFound = true; CursorCharNext(); return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString()); } @@ -545,17 +991,49 @@ private Token PotentiallyDoubleCharOperator(char expectedSecondChar, TokenType s private Token CreateNameToken(string name, int fromLine, int fromCol) { - TokenType? reservedType = Token.GetReservedTokenType(name); + TokenType? reservedType = Token.GetReservedTokenType(name, m_Extended); if (reservedType.HasValue) { return CreateToken(reservedType.Value, fromLine, fromCol, name); } + else if (m_Directives != null && m_Directives.Contains(name)) + { + return ReadDirective(name, fromLine, fromCol); + } else { return CreateToken(TokenType.Name, fromLine, fromCol, name); } } + + Token ReadDirective(string name, int fromLine, int fromCol) + { + //Skip space characters + for (; CursorNotEof() && CursorChar() != '\n' && IsWhiteSpace(CursorChar()); CursorNext()) ; + bool ValidCursorChar() + { + if (!CursorNotEof()) return false; //return on eof + var c = CursorChar(); + return char.IsLetterOrDigit(c) || c == '.' || c == '_'; + } + //Blank directive + if (!ValidCursorChar()) + { + return CreateToken(TokenType.Directive, fromLine, fromCol, name); + } + //Directive with value + //Directive values can contain letters, digits, underscores, or periods. + //They may not contain whitespace or other punctuation/control characters + var builder = new StringBuilder(); + builder.Append(name).Append(" "); + while (ValidCursorChar()) + { + builder.Append(CursorChar()); + CursorCharNext(); + } + return CreateToken(TokenType.Directive, fromLine, fromCol, builder.ToString()); + } private Token CreateToken(TokenType tokenType, int fromLine, int fromCol, string text = null) diff --git a/src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs b/src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs index ea7e18fa..d7802bbb 100755 --- a/src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs +++ b/src/MoonSharp.Interpreter/Tree/Lexer/LexerUtils.cs @@ -2,7 +2,6 @@ using System.Globalization; using System.Linq; using System.Text; -using MoonSharp.Interpreter.Compatibility; namespace MoonSharp.Interpreter.Tree { @@ -138,7 +137,7 @@ public static string AdjustLuaLongString(string str) public static string UnescapeLuaString(Token token, string str) { - if (!Framework.Do.StringContainsChar(str, '\\')) + if (!str.Contains('\\')) return str; StringBuilder sb = new StringBuilder(); @@ -171,6 +170,7 @@ public static string UnescapeLuaString(Token token, string str) else if (c == '\'') { sb.Append('\''); escape = false; zmode = false; } else if (c == '[') { sb.Append('['); escape = false; zmode = false; } else if (c == ']') { sb.Append(']'); escape = false; zmode = false; } + else if (c == '{') { sb.Append('{'); escape = false; zmode = false; } else if (c == 'x') { hex = true; } else if (c == 'u') { unicode_state = 1; } else if (c == 'z') { zmode = true; escape = false; } @@ -284,11 +284,7 @@ public static string UnescapeLuaString(Token token, string str) private static string ConvertUtf32ToChar(int i) { -#if PCL || ENABLE_DOTNET - return ((char)i).ToString(); -#else return char.ConvertFromUtf32(i); -#endif } } diff --git a/src/MoonSharp.Interpreter/Tree/Lexer/Token.cs b/src/MoonSharp.Interpreter/Tree/Lexer/Token.cs index 287fedc9..275135a9 100644 --- a/src/MoonSharp.Interpreter/Tree/Lexer/Token.cs +++ b/src/MoonSharp.Interpreter/Tree/Lexer/Token.cs @@ -35,57 +35,50 @@ public override string ToString() return string.Format("{0} - {1} - '{2}'", tokenTypeString, location, this.Text ?? ""); } - public static TokenType? GetReservedTokenType(string reservedWord) + public static TokenType? GetReservedTokenType(string reservedWord, bool extended) { - switch (reservedWord) + if (extended) { - case "and": - return TokenType.And; - case "break": - return TokenType.Break; - case "do": - return TokenType.Do; - case "else": - return TokenType.Else; - case "elseif": - return TokenType.ElseIf; - case "end": - return TokenType.End; - case "false": - return TokenType.False; - case "for": - return TokenType.For; - case "function": - return TokenType.Function; - case "goto": - return TokenType.Goto; - case "if": - return TokenType.If; - case "in": - return TokenType.In; - case "local": - return TokenType.Local; - case "nil": - return TokenType.Nil; - case "not": - return TokenType.Not; - case "or": - return TokenType.Or; - case "repeat": - return TokenType.Repeat; - case "return": - return TokenType.Return; - case "then": - return TokenType.Then; - case "true": - return TokenType.True; - case "until": - return TokenType.Until; - case "while": - return TokenType.While; - default: - return null; + switch (reservedWord) + { + case "let": + case "var": + return TokenType.Local; + case "of": + return TokenType.In; + case "continue": + return TokenType.Continue; + case "null": + return TokenType.Nil; + } } + + return reservedWord switch + { + "and" => TokenType.And, + "break" => TokenType.Break, + "do" => TokenType.Do, + "else" => TokenType.Else, + "elseif" => TokenType.ElseIf, + "end" => TokenType.End, + "false" => TokenType.False, + "for" => TokenType.For, + "function" => TokenType.Function, + "goto" => TokenType.Goto, + "if" => TokenType.If, + "in" => TokenType.In, + "local" => TokenType.Local, + "nil" => TokenType.Nil, + "not" => TokenType.Not, + "or" => TokenType.Or, + "repeat" => TokenType.Repeat, + "return" => TokenType.Return, + "then" => TokenType.Then, + "true" => TokenType.True, + "until" => TokenType.Until, + "while" => TokenType.While, + _ => null + }; } public double GetNumberValue() @@ -118,7 +111,8 @@ public bool IsEndOfBlock() public bool IsUnaryOperator() { - return Type == TokenType.Op_MinusOrSub || Type == TokenType.Not || Type == TokenType.Op_Len; + return Type == TokenType.Op_MinusOrSub || Type == TokenType.Not || Type == TokenType.Op_Len || + Type == TokenType.Op_Inc || Type == TokenType.Op_Dec || Type == TokenType.Op_Not; } public bool IsBinaryOperator() @@ -140,6 +134,14 @@ public bool IsBinaryOperator() case TokenType.Op_Mul: case TokenType.Op_MinusOrSub: case TokenType.Op_Add: + case TokenType.Op_NilCoalesce: + case TokenType.Op_NilCoalesceInverse: + case TokenType.Op_Or: + case TokenType.Op_And: + case TokenType.Op_Xor: + case TokenType.Op_LShift: + case TokenType.Op_RShiftArithmetic: + case TokenType.Op_RShiftLogical: return true; default: return false; diff --git a/src/MoonSharp.Interpreter/Tree/Lexer/TokenType.cs b/src/MoonSharp.Interpreter/Tree/Lexer/TokenType.cs index e020ca4f..aef1f733 100644 --- a/src/MoonSharp.Interpreter/Tree/Lexer/TokenType.cs +++ b/src/MoonSharp.Interpreter/Tree/Lexer/TokenType.cs @@ -8,6 +8,7 @@ enum TokenType Name, And, Break, + Continue, Do, Else, ElseIf, @@ -49,17 +50,52 @@ enum TokenType Brk_Close_Square, Brk_Open_Square, Op_Len, + //Number arithmetic Op_Pwr, Op_Mod, Op_Div, Op_Mul, Op_MinusOrSub, Op_Add, + Op_AddEq, + Op_SubEq, + Op_DivEq, + Op_ModEq, + Op_MulEq, + Op_PwrEq, + Op_ConcatEq, + Op_Inc, + Op_Dec, + //Bitwise ops + Op_Not, + Op_LShift, + Op_RShiftArithmetic, + Op_RShiftLogical, + Op_And, + Op_Xor, + Op_Or, + Op_LShiftEq, + Op_RShiftArithmeticEq, + Op_RShiftLogicalEq, + Op_AndEq, + Op_XorEq, + Op_OrEq, + //Nil operators + Op_NilCoalesce, + Op_NilCoalesceInverse, + Op_NilCoalescingAssignment, + Op_NilCoalescingAssignmentInverse, + //Nil Accessing + DotNil, + BrkOpenSquareNil, + + Ternary, Comment, String, String_Long, - + String_TemplateFragment, + String_EndTemplate, Number, Number_HexFloat, Number_Hex, @@ -68,6 +104,11 @@ enum TokenType Brk_Open_Curly_Shared, Op_Dollar, + + Arrow, + ChunkAnnotation, + FunctionAnnotation, + Directive, } diff --git a/src/MoonSharp.Interpreter/Tree/Loop.cs b/src/MoonSharp.Interpreter/Tree/Loop.cs index 2a4f1bee..ffd4428d 100644 --- a/src/MoonSharp.Interpreter/Tree/Loop.cs +++ b/src/MoonSharp.Interpreter/Tree/Loop.cs @@ -7,7 +7,8 @@ namespace MoonSharp.Interpreter.Tree internal class Loop : ILoop { public RuntimeScopeBlock Scope; - public List BreakJumps = new List(); + public List BreakJumps = new List(); + public List ContinueJumps = new List(); public void CompileBreak(ByteCode bc) { @@ -15,6 +16,11 @@ public void CompileBreak(ByteCode bc) BreakJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); } + public void CompileContinue(ByteCode bc) + { + ContinueJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); + } + public bool IsBoundary() { return false; @@ -27,6 +33,11 @@ public void CompileBreak(ByteCode bc) { throw new InternalErrorException("CompileBreak called on LoopBoundary"); } + + public void CompileContinue(ByteCode bc) + { + throw new InternalErrorException("CompileBreak called on LoopBoundary"); + } public bool IsBoundary() { diff --git a/src/MoonSharp.Interpreter/Tree/NodeBase.cs b/src/MoonSharp.Interpreter/Tree/NodeBase.cs index f327449a..93b31778 100644 --- a/src/MoonSharp.Interpreter/Tree/NodeBase.cs +++ b/src/MoonSharp.Interpreter/Tree/NodeBase.cs @@ -25,6 +25,21 @@ protected static Token UnexpectedTokenType(Token t) }; } + protected static Token CheckTokenTypeEx(ScriptLoadingContext lcontext, TokenType tokenType1, TokenType tokenType2) + { + if (lcontext.Syntax != ScriptSyntax.Lua) + { + Token t = lcontext.Lexer.Current; + if (t.Type != tokenType1 && + t.Type != tokenType2) + return UnexpectedTokenType(t); + lcontext.Lexer.Next(); + return t; + } + else + return CheckTokenType(lcontext, tokenType1); + } + protected static Token CheckTokenType(ScriptLoadingContext lcontext, TokenType tokenType) { Token t = lcontext.Lexer.Current; diff --git a/src/MoonSharp.Interpreter/Tree/Statement.cs b/src/MoonSharp.Interpreter/Tree/Statement.cs index 1ccadeca..93931779 100644 --- a/src/MoonSharp.Interpreter/Tree/Statement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statement.cs @@ -1,4 +1,5 @@ -using MoonSharp.Interpreter.Execution; +using System; +using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Tree.Expressions; using MoonSharp.Interpreter.Tree.Statements; @@ -9,6 +10,156 @@ abstract class Statement : NodeBase public Statement(ScriptLoadingContext lcontext) : base(lcontext) { } + + protected IVariable CheckVar(ScriptLoadingContext lcontext, Expression firstExpression) + { + IVariable v = firstExpression as IVariable; + + if (v == null) + throw new SyntaxErrorException(lcontext.Lexer.Current, "unexpected symbol near '{0}' - not a l-value", lcontext.Lexer.Current); + + return v; + } + + public abstract void ResolveScope(ScriptLoadingContext lcontext); + + static void ProcessDirective(ScriptLoadingContext lcontext) + { + var str = lcontext.Lexer.Current.Text; + var firstSpace = str.IndexOf(' '); + string name = str; + string value = ""; + if (firstSpace != -1) + { + name = str.Substring(0, firstSpace); + value = str.Substring(firstSpace + 1).Trim(); + } + var check = lcontext.Script.Options.AnnotationPolicy.OnChunkAnnotation(name, DynValue.NewString(value)); + if (check == AnnotationAction.Allow) + { + lcontext.ChunkAnnotations.Add(new Annotation(name, DynValue.NewString(value))); + } + if (check == AnnotationAction.Error) + { + throw new SyntaxErrorException(lcontext.Lexer.Current, "invalid directive '{0}'", name); + } + lcontext.Lexer.Next(); + } + + static Annotation ParseAnnotation(ScriptLoadingContext lcontext) + { + lcontext.Lexer.Next(); //Skip annotation marker + var nameToken = CheckTokenType(lcontext, TokenType.Name); //name + DynValue value = DynValue.Nil; + + DynValue NextPart(bool next) + { + DynValue _value = DynValue.Nil; + if (lcontext.Lexer.Current.Type != TokenType.Brk_Close_Round) + { + if (next) + { + lcontext.Lexer.Next(); + } + + var exprToken = lcontext.Lexer.Current; + var expr = Expression.Expr(lcontext); + if (expr is TableConstructor tbl) + { + if(!tbl.TryGetLiteral(out _value)) + throw new SyntaxErrorException(exprToken, "annotation value must be literal or prime table"); + } + else if (!expr.EvalLiteral(out _value)) + { + throw new SyntaxErrorException(exprToken, "annotation value must be literal or prime table"); + } + } + + return _value; + } + + if (lcontext.Lexer.Current.Type == TokenType.Brk_Open_Round) + { + value = NextPart(true); + + if (lcontext.Script.Options.AnnotationPolicy.AnnotationParsingPolicy == AnnotationValueParsingPolicy.StringOrTable || value.Type == DataType.Table) + { + CheckTokenType(lcontext, TokenType.Brk_Close_Round); + return new Annotation(nameToken.Text, value); + } + + DynValue table = DynValue.NewTable(lcontext.Script); + table.Table.Append(value); + + while (true) + { + if (lcontext.Lexer.Current.Type == TokenType.Brk_Close_Round) + { + break; + } + + CheckTokenType(lcontext, TokenType.Comma); + value = NextPart(false); + table.Table.Append(value); + } + + CheckTokenType(lcontext, TokenType.Brk_Close_Round); + return new Annotation(nameToken.Text, table); + } + + return new Annotation(nameToken.Text, value); + } + + static void ProcessChunkAnnotation(ScriptLoadingContext lcontext) + { + var tkn = lcontext.Lexer.Current; + var ant = ParseAnnotation(lcontext); + var check = lcontext.Script.Options.AnnotationPolicy.OnChunkAnnotation(ant.Name, ant.Value); + if (check == AnnotationAction.Allow) + { + lcontext.ChunkAnnotations.Add(ant); + } + if (check == AnnotationAction.Error) + { + throw new SyntaxErrorException(tkn, "invalid chunk annotation"); + } + } + + static void ProcessFunctionAnnotation(ScriptLoadingContext lcontext) + { + var tkn = lcontext.Lexer.Current; + var ant = ParseAnnotation(lcontext); + var check = lcontext.Script.Options.AnnotationPolicy.OnFunctionAnnotation(ant.Name, ant.Value); + if (check == AnnotationAction.Allow) + { + lcontext.FunctionAnnotations.Add(ant); + } + if (check == AnnotationAction.Error) + { + throw new SyntaxErrorException(tkn, "invalid function annotation"); + } + } + + protected static void ParseAnnotations(ScriptLoadingContext lcontext) + { + //Process Annotations + while (true) + { + switch (lcontext.Lexer.Current.Type) + { + case TokenType.Directive: + ProcessDirective(lcontext); + continue; + case TokenType.ChunkAnnotation: + ProcessChunkAnnotation(lcontext); + continue; + case TokenType.FunctionAnnotation: + ProcessFunctionAnnotation(lcontext); + continue; + } + break; + } + } protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bool forceLast) @@ -17,9 +168,24 @@ protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bo forceLast = false; + if (lcontext.FunctionAnnotations.Count != 0) + { + if (tkn.Type == TokenType.Local) + { + if (lcontext.Lexer.PeekNext().Type != TokenType.Function) + { + throw new SyntaxErrorException(tkn, "function annotations may only be applied to function declarations"); + } + } + else if (tkn.Type != TokenType.Function) + { + throw new SyntaxErrorException(tkn, "function annotations may only be applied to function declarations"); + } + } + switch (tkn.Type) { - case TokenType.DoubleColon: + case TokenType.DoubleColon when lcontext.Syntax != ScriptSyntax.CLike: return new LabelStatement(lcontext); case TokenType.Goto: return new GotoStatement(lcontext); @@ -31,7 +197,7 @@ protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bo case TokenType.While: return new WhileStatement(lcontext); case TokenType.Do: - return new ScopeBlockStatement(lcontext); + return new DoBlockStatement(lcontext); case TokenType.For: return DispatchForLoopStatement(lcontext); case TokenType.Repeat: @@ -46,42 +212,112 @@ protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bo else return new AssignmentStatement(lcontext, localToken); case TokenType.Return: - forceLast = true; + forceLast = (lcontext.Syntax != ScriptSyntax.Lua); //TODO: can we not force this in lua too? return new ReturnStatement(lcontext); case TokenType.Break: return new BreakStatement(lcontext); + case TokenType.Continue: + return new ContinueStatement(lcontext); default: - { + { + //Check for labels in CLike mode + lcontext.Lexer.SavePos(); Token l = lcontext.Lexer.Current; + if (lcontext.Syntax == ScriptSyntax.CLike && l.Type == TokenType.Name) + { + lcontext.Lexer.Next(); + if (lcontext.Lexer.Current.Type == TokenType.Colon) { + lcontext.Lexer.RestorePos(); + return new LabelStatement(lcontext); + } + } + lcontext.Lexer.RestorePos(); + //Regular expression Expression exp = Expression.PrimaryExp(lcontext); FunctionCallExpression fnexp = exp as FunctionCallExpression; - if (fnexp != null) return new FunctionCallStatement(lcontext, fnexp); else return new AssignmentStatement(lcontext, exp, l); - } + } } } + static bool CheckRangeFor(ScriptLoadingContext lcontext) + { + if (lcontext.Syntax == ScriptSyntax.Lua) return false; + try + { + lcontext.Lexer.SavePos(); + if (lcontext.Lexer.Current.Type == TokenType.In) + lcontext.Lexer.Next(); + else return false; + if (lcontext.Lexer.Current.Type == TokenType.Number) + lcontext.Lexer.Next(); + else return false; + if (lcontext.Lexer.Current.Type == TokenType.Op_Concat) + lcontext.Lexer.Next(); + else return false; + return lcontext.Lexer.Current.Type == TokenType.Number; + } + finally + { + lcontext.Lexer.RestorePos(); + } + } + private static Statement DispatchForLoopStatement(ScriptLoadingContext lcontext) { // for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | // for namelist in explist do block end | Token forTkn = CheckTokenType(lcontext, TokenType.For); - + //skip opening paren + bool paren = false; + if (lcontext.Syntax != ScriptSyntax.Lua && lcontext.Lexer.Current.Type == TokenType.Brk_Open_Round) { + paren = true; + lcontext.Lexer.Next(); + } + //Dispatch + lcontext.Lexer.SavePos(); + + if (paren && lcontext.Lexer.Current.Type == TokenType.SemiColon) + { + return new CStyleForStatement(lcontext, forTkn); + } + if (paren && lcontext.Lexer.Current.Type == TokenType.Local) + { + return new CStyleForStatement(lcontext, forTkn); + } + Token name = CheckTokenType(lcontext, TokenType.Name); - - if (lcontext.Lexer.Current.Type == TokenType.Op_Assignment) - return new ForLoopStatement(lcontext, name, forTkn); - else - return new ForEachLoopStatement(lcontext, name, forTkn); + switch (lcontext.Lexer.Current.Type) + { + case TokenType.Dot when paren: + case TokenType.Brk_Open_Round when paren: + lcontext.Lexer.RestorePos(); + return new CStyleForStatement(lcontext, forTkn); + case TokenType.Op_Assignment when paren: + lcontext.Lexer.Next(); + Expression.Expr(lcontext); + if (lcontext.Lexer.Current.Type == TokenType.SemiColon) + { + lcontext.Lexer.RestorePos(); + return new CStyleForStatement(lcontext, forTkn); + } + lcontext.Lexer.RestorePos(); + lcontext.Lexer.Next(); + return new ForLoopStatement(lcontext, name, forTkn, true); + case TokenType.Op_Assignment when !paren: + return new ForLoopStatement(lcontext, name, forTkn, false); + default: + { + if (CheckRangeFor(lcontext)) + return new ForRangeStatement(lcontext, name, forTkn, paren); + return new ForEachLoopStatement(lcontext, name, forTkn, paren); + } + } } - - - - } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/AssignmentStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/AssignmentStatement.cs index a82fe67a..ff2b7e74 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/AssignmentStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/AssignmentStatement.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Execution; @@ -9,22 +10,27 @@ namespace MoonSharp.Interpreter.Tree.Statements { class AssignmentStatement : Statement { - List m_LValues = new List(); + List m_LValues; + List localNames; List m_RValues; SourceRef m_Ref; + public Operator AssignmentOp = Operator.NotAnOperator; + + private bool isIncDec; + public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) : base(lcontext) { - List names = new List(); + localNames = new List(); Token first = startToken; while (true) { Token name = CheckTokenType(lcontext, TokenType.Name); - names.Add(name.Text); + localNames.Add(name.Text); if (lcontext.Lexer.Current.Type != TokenType.Comma) break; @@ -37,17 +43,25 @@ public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) CheckTokenType(lcontext, TokenType.Op_Assignment); m_RValues = Expression.ExprList(lcontext); } - else + else if (lcontext.Syntax == ScriptSyntax.CLike && lcontext.Lexer.Current.Type == TokenType.Op_NilCoalescingAssignment) { - m_RValues = new List(); + CheckTokenType(lcontext, TokenType.Op_NilCoalescingAssignment); + AssignmentOp = Operator.NilCoalescing; + m_RValues = Expression.ExprList(lcontext); } - - foreach (string name in names) + else if (lcontext.Syntax == ScriptSyntax.CLike && lcontext.Lexer.Current.Type == TokenType.Op_NilCoalesceInverse) { - var localVar = lcontext.Scope.TryDefineLocal(name); - var symbol = new SymbolRefExpression(lcontext, localVar); - m_LValues.Add(symbol); + CheckTokenType(lcontext, TokenType.Op_NilCoalesceInverse); + AssignmentOp = Operator.NilCoalescingInverse; + m_RValues = Expression.ExprList(lcontext); } + else + { + if (localNames.Count > 0) + m_RValues = new List(new Expression[] { new LiteralExpression(lcontext, DynValue.Nil) }); + } + + Token last = lcontext.Lexer.Current; m_Ref = first.GetSourceRefUpTo(last); @@ -55,10 +69,37 @@ public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) } + public void DefineLocals(ScriptLoadingContext lcontext) + { + if (localNames != null) + { + m_LValues = new List(); + foreach (string name in localNames) + { + var localVar = lcontext.Scope.TryDefineLocal(name); + var symbol = new SymbolRefExpression(lcontext, localVar); + m_LValues.Add(symbol); + } + } + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + foreach(var l in m_LValues)((Expression)l).ResolveScope(lcontext); + if (localNames != null) // local definitions can't reference themselves + { + lcontext.Scope.BlockResolution(m_LValues.Select(x => ((SymbolRefExpression)x).Symbol)); + } + if(m_RValues != null) + foreach(var r in m_RValues) r.ResolveScope(lcontext); + if(localNames != null) lcontext.Scope.UnblockResolution(); + } + public AssignmentStatement(ScriptLoadingContext lcontext, Expression firstExpression, Token first) : base(lcontext) { + m_LValues = new List(); m_LValues.Add(CheckVar(lcontext, firstExpression)); while (lcontext.Lexer.Current.Type == TokenType.Comma) @@ -68,24 +109,73 @@ public AssignmentStatement(ScriptLoadingContext lcontext, Expression firstExpres m_LValues.Add(CheckVar(lcontext, e)); } - CheckTokenType(lcontext, TokenType.Op_Assignment); + isIncDec = true; + foreach (var v in m_LValues) { + if (!v.IsAssignment) + { + isIncDec = false; + break; + } + } - m_RValues = Expression.ExprList(lcontext); + if (!isIncDec) + { + if (lcontext.Syntax != ScriptSyntax.Lua) { + switch (lcontext.Lexer.Current.Type) { + case TokenType.Op_AddEq: + if (lcontext.Syntax == ScriptSyntax.CLike) + AssignmentOp = Operator.AddConcat; + else + AssignmentOp = Operator.Add; + lcontext.Lexer.Next(); + break; + case TokenType.Op_SubEq: + AssignmentOp = Operator.Sub; + lcontext.Lexer.Next(); + break; + case TokenType.Op_MulEq: + AssignmentOp = Operator.Mul; + lcontext.Lexer.Next(); + break; + case TokenType.Op_DivEq: + AssignmentOp = Operator.Div; + lcontext.Lexer.Next(); + break; + case TokenType.Op_ModEq: + AssignmentOp = Operator.Mod; + lcontext.Lexer.Next(); + break; + case TokenType.Op_PwrEq: + AssignmentOp = Operator.Power; + lcontext.Lexer.Next(); + break; + case TokenType.Op_ConcatEq: + AssignmentOp = Operator.StrConcat; + lcontext.Lexer.Next(); + break; + case TokenType.Op_NilCoalescingAssignment: + AssignmentOp = Operator.NilCoalescing; + lcontext.Lexer.Next(); + break; + case TokenType.Op_NilCoalescingAssignmentInverse: + AssignmentOp = Operator.NilCoalescingInverse; + lcontext.Lexer.Next(); + break; + default: + CheckTokenType(lcontext, TokenType.Op_Assignment); + break; + } + } + else { + CheckTokenType(lcontext, TokenType.Op_Assignment); + } + m_RValues = Expression.ExprList(lcontext); + } + Token last = lcontext.Lexer.Current; m_Ref = first.GetSourceRefUpTo(last); lcontext.Source.Refs.Add(m_Ref); - - } - - private IVariable CheckVar(ScriptLoadingContext lcontext, Expression firstExpression) - { - IVariable v = firstExpression as IVariable; - - if (v == null) - throw new SyntaxErrorException(lcontext.Lexer.Current, "unexpected symbol near '{0}' - not a l-value", lcontext.Lexer.Current); - - return v; } @@ -93,17 +183,28 @@ public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_Ref)) { - foreach (var exp in m_RValues) + if (isIncDec) { - exp.Compile(bc); + foreach (var v in m_LValues) + { + (v as Expression).Compile(bc); + bc.Emit_Pop(); + } } + else + { + foreach (var exp in m_RValues) + { + exp.CompilePossibleLiteral(bc); + } - for (int i = 0; i < m_LValues.Count; i++) - m_LValues[i].CompileAssignment(bc, + for (int i = 0; i < m_LValues.Count; i++) + m_LValues[i].CompileAssignment(bc, AssignmentOp, Math.Max(m_RValues.Count - 1 - i, 0), // index of r-value i - Math.Min(i, m_RValues.Count - 1)); // index in last tuple - bc.Emit_Pop(m_RValues.Count); + bc.Emit_Pop(m_RValues.Count); + } } } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/BreakStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/BreakStatement.cs index 66c6be2d..9d7685cc 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/BreakStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/BreakStatement.cs @@ -16,6 +16,10 @@ public BreakStatement(ScriptLoadingContext lcontext) lcontext.Source.Refs.Add(m_Ref); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + //no-op + } public override void Compile(ByteCode bc) diff --git a/src/MoonSharp.Interpreter/Tree/Statements/CStyleForStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/CStyleForStatement.cs new file mode 100644 index 00000000..d46b6ef3 --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Statements/CStyleForStatement.cs @@ -0,0 +1,157 @@ +using System.Runtime.Serialization; +using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; +using MoonSharp.Interpreter.Tree.Expressions; + +namespace MoonSharp.Interpreter.Tree.Statements +{ + class CStyleForStatement : Statement, IBlockStatement + { + private Expression initExpression; + private Expression condition; + private Statement modify; + private IVariable initAssignee; + private Statement block; + private bool isDefLocal; + + SourceRef refBegin; + SourceRef refEnd; + RuntimeScopeBlock stackFrame; + + private RuntimeScopeBlock iteratorFrame; + public SourceRef End => refEnd; + + private string localDefName; + + public CStyleForStatement(ScriptLoadingContext lcontext, Token forTok) : base(lcontext) + { + //Init + if (lcontext.Lexer.Current.Type != TokenType.SemiColon) + { + if (lcontext.Lexer.Current.Type == TokenType.Local) + { + isDefLocal = true; + lcontext.Lexer.Next(); + localDefName = CheckTokenType(lcontext, TokenType.Name).Text; + CheckTokenType(lcontext, TokenType.Op_Assignment); + initExpression = Expression.Expr(lcontext); + CheckTokenType(lcontext, TokenType.SemiColon); + } + else + { + var exp = Expression.Expr(lcontext); + initAssignee = CheckVar(lcontext, exp); + CheckTokenType(lcontext, TokenType.Op_Assignment); + initExpression = Expression.Expr(lcontext); + CheckTokenType(lcontext, TokenType.SemiColon); + } + } + else { + lcontext.Lexer.Next(); + } + //Condition + if (lcontext.Lexer.Current.Type != TokenType.SemiColon) { + condition = Expression.Expr(lcontext); + CheckTokenType(lcontext, TokenType.SemiColon); + } + else { + lcontext.Lexer.Next(); + condition = new LiteralExpression(lcontext, DynValue.NewBoolean(true)); + } + //Modify + if (lcontext.Lexer.Current.Type != TokenType.Brk_Close_Round) + { + modify = Statement.CreateStatement(lcontext, out _); + if (modify is IBlockStatement) + { + throw new SyntaxErrorException(forTok, "for conditions cannot contain a block"); + } + } + else + { + modify = new EmptyStatement(lcontext); + } + + CheckTokenType(lcontext, TokenType.Brk_Close_Round); + refBegin = forTok.GetSourceRef(lcontext.Lexer.Current); + if (lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) + { + lcontext.Lexer.Next(); + block = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + refEnd = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + } + else + { + refEnd = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } + + lcontext.Source.Refs.Add(refBegin); + lcontext.Source.Refs.Add(refEnd); + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); + if (isDefLocal) { + var lcl = lcontext.Scope.TryDefineLocal(localDefName); + initAssignee = new SymbolRefExpression(lcontext, lcl); + } + (initAssignee as Expression)?.ResolveScope(lcontext); + initExpression?.ResolveScope(lcontext); + condition?.ResolveScope(lcontext); + modify?.ResolveScope(lcontext); + lcontext.Scope.PushBlock(); + block.ResolveScope(lcontext); + stackFrame = lcontext.Scope.PopBlock(); + iteratorFrame = lcontext.Scope.PopBlock(); + } + + public override void Compile(ByteCode bc) + { + //TODO: There are scope issues which mean we have to copy + //the defined local to-from the stack a few times + //- figure out what on earth is going on there? + + Loop L = new Loop() + { + Scope = stackFrame + }; + bc.PushSourceRef(refBegin); + + bc.LoopTracker.Loops.Push(L); + bc.Emit_Enter(iteratorFrame); + if (initExpression != null) { + initExpression.Compile(bc); + initAssignee.CompileAssignment(bc, Operator.NotAnOperator, 0, 0); + bc.Emit_Pop(); + } + int start = bc.GetJumpPointForNextInstruction(); + condition.Compile(bc); + var jumpend = bc.Emit_Jump(OpCode.Jf, -1); + bc.Emit_Enter(stackFrame); + block.Compile(bc); + int continuePoint = bc.GetJumpPointForNextInstruction(); + if(isDefLocal) bc.Emit_CloseUp((initAssignee as SymbolRefExpression).Symbol); + modify.Compile(bc); + bc.Emit_Leave(stackFrame); + bc.Emit_Jump(OpCode.Jump, start); + bc.LoopTracker.Loops.Pop(); + bc.PopSourceRef(); + bc.PushSourceRef(refEnd); + + int exitpoint = bc.GetJumpPointForNextInstruction(); + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); + + bc.SetNumVal(jumpend, exitpoint); + + bc.Emit_Leave(iteratorFrame); + bc.PopSourceRef(); + + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ChunkStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ChunkStatement.cs index b9968b0f..c0da8055 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/ChunkStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/ChunkStatement.cs @@ -1,4 +1,5 @@ -using MoonSharp.Interpreter.Execution; +using System; +using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; namespace MoonSharp.Interpreter.Tree.Statements @@ -9,28 +10,38 @@ class ChunkStatement : Statement, IClosureBuilder RuntimeScopeFrame m_StackFrame; SymbolRef m_Env; SymbolRef m_VarArgs; + private Annotation[] annotations; public ChunkStatement(ScriptLoadingContext lcontext) : base(lcontext) { - lcontext.Scope.PushFunction(this, true); - m_Env = lcontext.Scope.DefineLocal(WellKnownSymbols.ENV); - m_VarArgs = lcontext.Scope.DefineLocal(WellKnownSymbols.VARARGS); - - m_Block = new CompositeStatement(lcontext); + m_Block = new CompositeStatement(lcontext, BlockEndType.Normal); if (lcontext.Lexer.Current.Type != TokenType.Eof) throw new SyntaxErrorException(lcontext.Lexer.Current, " expected near '{0}'", lcontext.Lexer.Current.Text); + + annotations = lcontext.ChunkAnnotations.ToArray(); + } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushFunction(this); + lcontext.Scope.SetHasVarArgs(); + m_Env = lcontext.Scope.DefineLocal(WellKnownSymbols.ENV); + m_VarArgs = lcontext.Scope.DefineLocal(WellKnownSymbols.VARARGS); + + m_Block.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopFunction(); } public override void Compile(Execution.VM.ByteCode bc) { - Instruction meta = bc.Emit_Meta("", OpCodeMetadataType.ChunkEntrypoint); - int metaip = bc.GetJumpPointForLastInstruction(); - + int meta = bc.Emit_Meta("", OpCodeMetadataType.ChunkEntrypoint); + if (annotations.Length != 0) { + bc.Emit_Annot(annotations); + } bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); @@ -41,7 +52,9 @@ public override void Compile(Execution.VM.ByteCode bc) m_Block.Compile(bc); bc.Emit_Ret(0); - meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; + var ins = bc.Code[meta]; + ins.NumVal = bc.GetJumpPointForLastInstruction() - meta; + bc.Code[meta] = ins; } public SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol) diff --git a/src/MoonSharp.Interpreter/Tree/Statements/CompositeStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/CompositeStatement.cs index 2d0b1eec..e3673e48 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/CompositeStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/CompositeStatement.cs @@ -1,34 +1,143 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using MoonSharp.Interpreter.Execution; namespace MoonSharp.Interpreter.Tree.Statements { + enum BlockEndType + { + Normal, + CloseCurly + } class CompositeStatement : Statement { List m_Statements = new List(); - public CompositeStatement(ScriptLoadingContext lcontext) + public CompositeStatement(ScriptLoadingContext lcontext, BlockEndType endType) : base(lcontext) { while (true) { - Token t = lcontext.Lexer.Current; - if (t.IsEndOfBlock()) break; - - bool forceLast; - - Statement s = Statement.CreateStatement(lcontext, out forceLast); - m_Statements.Add(s); + try + { + ParseAnnotations(lcontext); + Token t = lcontext.Lexer.Current; + if (t.IsEndOfBlock()) break; + if (endType == BlockEndType.CloseCurly && t.Type == TokenType.Brk_Close_Curly) break; - if (forceLast) break; + Statement s = CreateStatement(lcontext, out bool forceLast); + m_Statements.Add(s); + if (forceLast) break; + } + catch (InterpreterException e) + { + if (lcontext.Script.Options.ParserErrorMode == ScriptOptions.ParserErrorModes.Report) + { + Token token = null; + if (e is SyntaxErrorException se) + { + token = se.Token; + } + + lcontext.Script.i_ParserMessages.Add(new Script.ScriptParserMessage(token, e.Message)); + Synchronize(lcontext); + + if (lcontext.Lexer.PeekNext().Type == TokenType.Eof) + { + lcontext.Lexer.Next(); + break; + } + } + else + { + throw; + } + } } // eat away all superfluos ';'s while (lcontext.Lexer.Current.Type == TokenType.SemiColon) lcontext.Lexer.Next(); } + + private void Synchronize(ScriptLoadingContext lcontext) + { + while (lcontext.Lexer.PeekNext().Type != TokenType.Eof) + { + lcontext.Lexer.Next(); + Token tkn = lcontext.Lexer.Current; + + switch (tkn.Type) + { + case TokenType.ChunkAnnotation: + case TokenType.Local: + case TokenType.Until: + case TokenType.Break: + case TokenType.Continue: + case TokenType.While: + case TokenType.For: + case TokenType.ElseIf: + case TokenType.Else: + case TokenType.Function: + case TokenType.Goto: + case TokenType.Directive: + case TokenType.Do: + case TokenType.If: + { + goto endSynchronize; + } + } + } + + endSynchronize: ; + } + + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + if (lcontext.Syntax == ScriptSyntax.CLike) + { + //Perform declaration hoisting. + //Define all locals upfront, then bring function definitions up + List reordered = new List(m_Statements.Count); + foreach (var s in m_Statements) + { + if (s is AssignmentStatement a) + { + a.DefineLocals(lcontext); + reordered.Add(a); + } + else if (s is FunctionDefinitionStatement fd) + { + fd.DefineLocals(lcontext); + if(fd.CanHoist) + reordered.Insert(0, fd); + else + reordered.Add(fd); + } + else + { + reordered.Add(s); + } + } + m_Statements = reordered; + foreach(var s in m_Statements) s.ResolveScope(lcontext); + + } + else + { + foreach (var s in m_Statements) + { + if(s is AssignmentStatement a) a.DefineLocals(lcontext); + if(s is FunctionDefinitionStatement fd) fd.DefineLocals(lcontext); + s.ResolveScope(lcontext); + } + + } + + } public override void Compile(Execution.VM.ByteCode bc) diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ContinueStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ContinueStatement.cs new file mode 100644 index 00000000..51248b7d --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Statements/ContinueStatement.cs @@ -0,0 +1,41 @@ +using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; + + +namespace MoonSharp.Interpreter.Tree.Statements +{ + class ContinueStatement : Statement + { + SourceRef m_Ref; + + public ContinueStatement(ScriptLoadingContext lcontext) + : base(lcontext) + { + m_Ref = CheckTokenType(lcontext, TokenType.Continue).GetSourceRef(); + lcontext.Source.Refs.Add(m_Ref); + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + //No-op + } + + + public override void Compile(ByteCode bc) + { + using (bc.EnterSource(m_Ref)) + { + if (bc.LoopTracker.Loops.Count == 0) + throw new SyntaxErrorException(this.Script, m_Ref, " at line {0} not inside a loop", m_Ref.FromLine); + + ILoop loop = bc.LoopTracker.Loops.Peek(); + + if (loop.IsBoundary()) + throw new SyntaxErrorException(this.Script, m_Ref, " at line {0} not inside a loop", m_Ref.FromLine); + + loop.CompileContinue(bc); + } + } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Statements/DoBlockStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/DoBlockStatement.cs new file mode 100644 index 00000000..175790c0 --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Statements/DoBlockStatement.cs @@ -0,0 +1,106 @@ +using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; + +namespace MoonSharp.Interpreter.Tree.Statements +{ + class DoBlockStatement : Statement, IBlockStatement + { + Statement m_Block; + RuntimeScopeBlock m_StackFrame; + SourceRef m_Do, m_End; + Expression m_Condition; + + public SourceRef End => m_End; + + public DoBlockStatement(ScriptLoadingContext lcontext) + : base(lcontext) + { + + m_Do = CheckTokenType(lcontext, TokenType.Do).GetSourceRef(); + + + if (lcontext.Syntax != ScriptSyntax.Lua && + lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) + { + lcontext.Lexer.Next(); + m_Block = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + CheckTokenType(lcontext, TokenType.Brk_Close_Curly); + Token cond = CheckTokenType(lcontext, TokenType.While); + m_Condition = Expression.Expr(lcontext); + m_End = cond.GetSourceRefUpTo(lcontext.Lexer.Current); + } + else + { + m_Block = new CompositeStatement(lcontext, BlockEndType.Normal); + m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); + } + lcontext.Source.Refs.Add(m_Do); + lcontext.Source.Refs.Add(m_End); + + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); + m_Block.ResolveScope(lcontext); + m_Condition?.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopBlock(); + } + + + public override void Compile(Execution.VM.ByteCode bc) + { + if(m_Condition != null) CompileLoop(bc); + else CompileScopeBlock(bc); + } + + void CompileLoop(Execution.VM.ByteCode bc) + { + Loop L = new Loop() + { + Scope = m_StackFrame + }; + + bc.PushSourceRef(m_Do); + + bc.LoopTracker.Loops.Push(L); + + int start = bc.GetJumpPointForNextInstruction(); + + bc.Emit_Enter(m_StackFrame); + m_Block.Compile(bc); + + bc.PopSourceRef(); + bc.PushSourceRef(m_End); + bc.Emit_Debug("..end"); + int continuePoint = bc.GetJumpPointForNextInstruction(); + m_Condition.Compile(bc); + bc.Emit_Leave(m_StackFrame); + bc.Emit_Jump(OpCode.Jt, start); + + bc.LoopTracker.Loops.Pop(); + + int exitpoint = bc.GetJumpPointForNextInstruction(); + + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); + + bc.PopSourceRef(); + } + + void CompileScopeBlock(Execution.VM.ByteCode bc) + { + using(bc.EnterSource(m_Do)) + bc.Emit_Enter(m_StackFrame); + + m_Block.Compile(bc); + + using (bc.EnterSource(m_End)) + bc.Emit_Leave(m_StackFrame); + } + + } +} diff --git a/src/MoonSharp.Interpreter/Tree/Statements/EmptyStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/EmptyStatement.cs index b0076749..6ffdd54d 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/EmptyStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/EmptyStatement.cs @@ -9,6 +9,11 @@ public EmptyStatement(ScriptLoadingContext lcontext) { } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + //No-op + } + public override void Compile(Execution.VM.ByteCode bc) { diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ForEachLoopStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ForEachLoopStatement.cs index b7496871..61284555 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/ForEachLoopStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/ForEachLoopStatement.cs @@ -17,12 +17,14 @@ class ForEachLoopStatement : Statement Statement m_Block; SourceRef m_RefFor, m_RefEnd; - public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, Token forToken) + private List names; + + public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, Token forToken, bool paren) : base(lcontext) { // for namelist in explist do block end | - List names = new List(); + names = new List(); names.Add(firstNameToken.Text); while (lcontext.Lexer.Current.Type == TokenType.Comma) @@ -35,9 +37,40 @@ public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, CheckTokenType(lcontext, TokenType.In); m_RValues = new ExprListExpression(Expression.ExprList(lcontext), lcontext); + + if (paren) CheckTokenType(lcontext, TokenType.Brk_Close_Round); + + if (lcontext.Syntax == ScriptSyntax.Lua || lcontext.Lexer.Current.Type == TokenType.Do) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); + m_Block = new CompositeStatement(lcontext, BlockEndType.Normal); + m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Brk_Open_Curly)); + m_Block = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + m_RefEnd = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + } + else + { + m_RefFor = forToken.GetSourceRef(lcontext.Lexer.Current); + m_Block = CreateStatement(lcontext, out _); + if (m_Block is IBlockStatement block) + m_RefEnd = block.End; + else + m_RefEnd = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } - lcontext.Scope.PushBlock(); + + + lcontext.Source.Refs.Add(m_RefFor); + lcontext.Source.Refs.Add(m_RefEnd); + } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); m_Names = names .Select(n => lcontext.Scope.TryDefineLocal(n)) .ToArray(); @@ -46,17 +79,10 @@ public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, .Select(s => new SymbolRefExpression(lcontext, s)) .Cast() .ToArray(); - - m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); - - m_Block = new CompositeStatement(lcontext); - - m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - + + m_RValues?.ResolveScope(lcontext); + m_Block.ResolveScope(lcontext); m_StackFrame = lcontext.Scope.PopBlock(); - - lcontext.Source.Refs.Add(m_RefFor); - lcontext.Source.Refs.Add(m_RefEnd); } @@ -90,7 +116,7 @@ public override void Compile(ByteCode bc) // perform assignment of iteration result- stack : iterator-tuple, iteration result for (int i = 0; i < m_NameExps.Length; i++) - m_NameExps[i].CompileAssignment(bc, 0, i); + m_NameExps[i].CompileAssignment(bc, Operator.NotAnOperator, 0, i); // pops - stack : iterator-tuple bc.Emit_Pop(); @@ -111,6 +137,7 @@ public override void Compile(ByteCode bc) bc.PushSourceRef(m_RefEnd); // loop back again - stack : iterator-tuple + int continuePoint = bc.GetJumpPointForNextInstruction(); bc.Emit_Leave(m_StackFrame); bc.Emit_Jump(OpCode.Jump, start); @@ -123,10 +150,16 @@ public override void Compile(ByteCode bc) bc.Emit_Pop(); - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpointBreaks; + foreach (int i in L.BreakJumps) + { + bc.SetNumVal(i, exitpointBreaks); + } + + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); - endjump.NumVal = exitpointLoopExit; + bc.SetNumVal(endjump, exitpointLoopExit); + bc.PopSourceRef(); } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ForLoopStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ForLoopStatement.cs index 614c50b3..3c412ca4 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/ForLoopStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/ForLoopStatement.cs @@ -6,7 +6,7 @@ namespace MoonSharp.Interpreter.Tree.Statements { - class ForLoopStatement : Statement + class ForLoopStatement : Statement, IBlockStatement { //for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' RuntimeScopeBlock m_StackFrame; @@ -14,8 +14,11 @@ class ForLoopStatement : Statement SymbolRef m_VarName; Expression m_Start, m_End, m_Step; SourceRef m_RefFor, m_RefEnd; + private Token nameToken; - public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken) + public SourceRef End => m_RefEnd; + + public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken, bool paren) : base(lcontext) { // for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | @@ -37,16 +40,45 @@ public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token fo m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1)); } - lcontext.Scope.PushBlock(); - m_VarName = lcontext.Scope.DefineLocal(nameToken.Text); - m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); - m_InnerBlock = new CompositeStatement(lcontext); - m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - m_StackFrame = lcontext.Scope.PopBlock(); + this.nameToken = nameToken; + if (paren) CheckTokenType(lcontext, TokenType.Brk_Close_Round); + + if (lcontext.Syntax == ScriptSyntax.Lua || lcontext.Lexer.Current.Type == TokenType.Do) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); + m_InnerBlock = new CompositeStatement(lcontext, BlockEndType.Normal); + m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Brk_Open_Curly)); + m_InnerBlock = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + m_RefEnd = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + } + else + { + m_RefFor = forToken.GetSourceRef(lcontext.Lexer.Current); + m_InnerBlock = CreateStatement(lcontext, out _); + if (m_InnerBlock is IBlockStatement block) + m_RefEnd = block.End; + else + m_RefEnd = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } lcontext.Source.Refs.Add(m_RefFor); lcontext.Source.Refs.Add(m_RefEnd); - } + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Start.ResolveScope(lcontext); + m_End.ResolveScope(lcontext); + m_Step.ResolveScope(lcontext); + lcontext.Scope.PushBlock(); + m_VarName = lcontext.Scope.DefineLocal(nameToken.Text); + m_InnerBlock.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopBlock(); + } public override void Compile(ByteCode bc) @@ -60,17 +92,13 @@ public override void Compile(ByteCode bc) bc.LoopTracker.Loops.Push(L); - m_End.Compile(bc); - bc.Emit_ToNum(3); + m_End.CompilePossibleLiteral(bc); m_Step.Compile(bc); - bc.Emit_ToNum(2); - m_Start.Compile(bc); - bc.Emit_ToNum(1); + m_Start.CompilePossibleLiteral(bc); int start = bc.GetJumpPointForNextInstruction(); var jumpend = bc.Emit_Jump(OpCode.JFor, -1); bc.Emit_Enter(m_StackFrame); - //bc.Emit_SymStorN(m_VarName); bc.Emit_Store(m_VarName, 0, 0); @@ -80,6 +108,8 @@ public override void Compile(ByteCode bc) bc.PushSourceRef(m_RefEnd); bc.Emit_Debug("..end"); + + int continuePoint = bc.GetJumpPointForNextInstruction(); bc.Emit_Leave(m_StackFrame); bc.Emit_Incr(1); bc.Emit_Jump(OpCode.Jump, start); @@ -88,10 +118,12 @@ public override void Compile(ByteCode bc) int exitpoint = bc.GetJumpPointForNextInstruction(); - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; - - jumpend.NumVal = exitpoint; + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); + + bc.SetNumVal(jumpend, exitpoint); bc.Emit_Pop(3); bc.PopSourceRef(); diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ForRangeStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ForRangeStatement.cs new file mode 100644 index 00000000..6a82d639 --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Statements/ForRangeStatement.cs @@ -0,0 +1,113 @@ +using MoonSharp.Interpreter.Debugging; +using MoonSharp.Interpreter.Execution; +using MoonSharp.Interpreter.Execution.VM; + +using MoonSharp.Interpreter.Tree.Expressions; + +namespace MoonSharp.Interpreter.Tree.Statements +{ + class ForRangeStatement : Statement, IBlockStatement + { + //for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' + RuntimeScopeBlock m_StackFrame; + Statement m_InnerBlock; + SymbolRef m_VarName; + Expression m_Start, m_End, m_Step; + SourceRef m_RefFor, m_RefEnd; + private Token nameToken; + + public SourceRef End => m_RefEnd; + + public ForRangeStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken, bool paren) : base(lcontext) + { + CheckTokenType(lcontext, TokenType.In); + var startNumber = CheckTokenType(lcontext, TokenType.Number).GetNumberValue(); + CheckTokenType(lcontext, TokenType.Op_Concat); + var endNumber = CheckTokenType(lcontext, TokenType.Number).GetNumberValue(); + m_Start = new LiteralExpression(lcontext, DynValue.NewNumber(startNumber)); + m_End = new LiteralExpression(lcontext, DynValue.NewNumber(endNumber)); + m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(startNumber > endNumber ? -1 : 1)); + if (paren) CheckTokenType(lcontext, TokenType.Brk_Close_Round); + this.nameToken = nameToken; + + if (lcontext.Syntax == ScriptSyntax.Lua || lcontext.Lexer.Current.Type == TokenType.Do) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); + m_InnerBlock = new CompositeStatement(lcontext, BlockEndType.Normal); + m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); + } + else if (lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly) + { + m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Brk_Open_Curly)); + m_InnerBlock = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + m_RefEnd = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + } + else + { + m_RefFor = forToken.GetSourceRef(lcontext.Lexer.Current); + m_InnerBlock = CreateStatement(lcontext, out _); + if (m_InnerBlock is IBlockStatement block) + m_RefEnd = block.End; + else + m_RefEnd = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } + lcontext.Source.Refs.Add(m_RefFor); + lcontext.Source.Refs.Add(m_RefEnd); + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); + m_VarName = lcontext.Scope.DefineLocal(nameToken.Text); + m_InnerBlock.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopBlock(); + } + + public override void Compile(ByteCode bc) + { + bc.PushSourceRef(m_RefFor); + + Loop L = new Loop() + { + Scope = m_StackFrame + }; + + bc.LoopTracker.Loops.Push(L); + + m_End.Compile(bc); + m_Step.Compile(bc); + m_Start.Compile(bc); + + int start = bc.GetJumpPointForNextInstruction(); + var jumpend = bc.Emit_Jump(OpCode.JFor, -1); + bc.Emit_Enter(m_StackFrame); + + bc.Emit_Store(m_VarName, 0, 0); + + m_InnerBlock.Compile(bc); + + bc.PopSourceRef(); + bc.PushSourceRef(m_RefEnd); + + int continuePoint = bc.GetJumpPointForNextInstruction(); + bc.Emit_Leave(m_StackFrame); + bc.Emit_Incr(1); + bc.Emit_Jump(OpCode.Jump, start); + + bc.LoopTracker.Loops.Pop(); + + int exitpoint = bc.GetJumpPointForNextInstruction(); + + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); + + bc.SetNumVal(jumpend, exitpoint); + bc.Emit_Pop(3); + + bc.PopSourceRef(); + } + + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Statements/FunctionCallStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/FunctionCallStatement.cs index c48f5bee..16a30e2f 100755 --- a/src/MoonSharp.Interpreter/Tree/Statements/FunctionCallStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/FunctionCallStatement.cs @@ -16,19 +16,22 @@ public FunctionCallStatement(ScriptLoadingContext lcontext, FunctionCallExpressi lcontext.Source.Refs.Add(m_FunctionCallExpression.SourceRef); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_FunctionCallExpression.ResolveScope(lcontext); + } + public override void Compile(ByteCode bc) { using (bc.EnterSource(m_FunctionCallExpression.SourceRef)) { m_FunctionCallExpression.Compile(bc); - RemoveBreakpointStop(bc.Emit_Pop()); + bc.Emit_Pop(); + bc.SourceRefs[bc.SourceRefs.Count - 1] = null; //Remove breakpoint stop } } - private void RemoveBreakpointStop(Instruction instruction) - { - instruction.SourceCodeRef = null; - } + } } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs index 73fc126f..8c65777d 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs @@ -8,6 +8,29 @@ namespace MoonSharp.Interpreter.Tree.Statements { class FunctionDefinitionStatement : Statement { + internal class FunctionParamRef + { + public string Name { get; set; } + public Expression DefaultValue { get; set; } + + public FunctionParamRef(string name) + { + Name = name; + } + + public FunctionParamRef(string name, Expression defaultValue) + { + Name = name; + DefaultValue = defaultValue; + } + } + + internal class FunctionRef + { + public string Name { get; set; } + public List Params { get; set; } + } + SymbolRef m_FuncSymbol; SourceRef m_SourceRef; @@ -19,6 +42,11 @@ class FunctionDefinitionStatement : Statement List m_TableAccessors; FunctionDefinitionExpression m_FuncDef; + private string m_FuncDefName; + private string m_FuncLookupSymbol; + + public bool CanHoist => m_MethodName == null || m_Local; + public FunctionDefinitionStatement(ScriptLoadingContext lcontext, bool local, Token localToken) : base(lcontext) { @@ -27,22 +55,21 @@ public FunctionDefinitionStatement(ScriptLoadingContext lcontext, bool local, To funcKeyword = localToken ?? funcKeyword; // for debugger purposes m_Local = local; - + Token name = CheckTokenType(lcontext, TokenType.Name); + if (m_Local) { - Token name = CheckTokenType(lcontext, TokenType.Name); - m_FuncSymbol = lcontext.Scope.TryDefineLocal(name.Text); + m_FuncDefName = name.Text; m_FriendlyName = string.Format("{0} (local)", name.Text); m_SourceRef = funcKeyword.GetSourceRef(name); } else { - Token name = CheckTokenType(lcontext, TokenType.Name); string firstName = name.Text; m_SourceRef = funcKeyword.GetSourceRef(name); + m_FuncLookupSymbol = firstName; - m_FuncSymbol = lcontext.Scope.Find(firstName); m_FriendlyName = firstName; if (lcontext.Lexer.Current.Type != TokenType.Brk_Open_Round) @@ -87,6 +114,23 @@ public FunctionDefinitionStatement(ScriptLoadingContext lcontext, bool local, To lcontext.Source.Refs.Add(m_SourceRef); } + public void DefineLocals(ScriptLoadingContext lcontext) + { + if (m_FuncDefName != null) + { + m_FuncSymbol = lcontext.Scope.TryDefineLocal(m_FuncDefName); + } + } + + public override void ResolveScope(ScriptLoadingContext lcontext) + { + if (m_FuncSymbol == null) + { + m_FuncSymbol = lcontext.Scope.Find(m_FuncLookupSymbol); + } + m_FuncDef.ResolveScope(lcontext); + } + public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_SourceRef)) @@ -107,7 +151,7 @@ public override void Compile(Execution.VM.ByteCode bc) } } } - + private int SetMethod(Execution.VM.ByteCode bc) { int cnt = 0; @@ -116,11 +160,11 @@ private int SetMethod(Execution.VM.ByteCode bc) foreach (string str in m_TableAccessors) { - bc.Emit_Index(DynValue.NewString(str), true); + bc.Emit_Index(str, true); cnt += 1; } - bc.Emit_IndexSet(0, 0, DynValue.NewString(m_MethodName), true); + bc.Emit_IndexSet(0, 0, m_MethodName, true); return 1 + cnt; } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/GotoStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/GotoStatement.cs index eac339ad..4449ff6d 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/GotoStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/GotoStatement.cs @@ -13,7 +13,8 @@ class GotoStatement : Statement internal int DefinedVarsCount { get; private set; } internal string LastDefinedVarName { get; private set; } - Instruction m_Jump; + private int m_Jump = -1; + private ByteCode m_bc; int m_LabelAddress = -1; public GotoStatement(ScriptLoadingContext lcontext) @@ -25,13 +26,17 @@ public GotoStatement(ScriptLoadingContext lcontext) SourceRef = GotoToken.GetSourceRef(name); Label = name.Text; + } + public override void ResolveScope(ScriptLoadingContext lcontext) + { lcontext.Scope.RegisterGoto(this); } public override void Compile(ByteCode bc) { m_Jump = bc.Emit_Jump(OpCode.Jump, m_LabelAddress); + m_bc = bc; } internal void SetDefinedVars(int definedVarsCount, string lastDefinedVarsName) @@ -45,8 +50,8 @@ internal void SetAddress(int labelAddress) { m_LabelAddress = labelAddress; - if (m_Jump != null) - m_Jump.NumVal = labelAddress; + if (m_Jump != -1) + m_bc.SetNumVal(m_Jump, labelAddress); } } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/IBlockStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/IBlockStatement.cs new file mode 100644 index 00000000..25bf9ff2 --- /dev/null +++ b/src/MoonSharp.Interpreter/Tree/Statements/IBlockStatement.cs @@ -0,0 +1,9 @@ +using MoonSharp.Interpreter.Debugging; + +namespace MoonSharp.Interpreter.Tree.Statements +{ + interface IBlockStatement + { + SourceRef End { get; } + } +} \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/Tree/Statements/IfStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/IfStatement.cs index 5f5dda5a..6deaf813 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/IfStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/IfStatement.cs @@ -6,7 +6,7 @@ namespace MoonSharp.Interpreter.Tree.Statements { - class IfStatement : Statement + class IfStatement : Statement, IBlockStatement { private class IfBlock { @@ -16,6 +16,8 @@ private class IfBlock public SourceRef Source; } + public SourceRef End => m_End; + List m_Ifs = new List(); IfBlock m_Else = null; SourceRef m_End; @@ -23,67 +25,135 @@ private class IfBlock public IfStatement(ScriptLoadingContext lcontext) : base(lcontext) { - while (lcontext.Lexer.Current.Type != TokenType.Else && lcontext.Lexer.Current.Type != TokenType.End) - { - m_Ifs.Add(CreateIfBlock(lcontext)); + bool cStyle; + bool endBlock; + m_Ifs.Add(CreateIfBlock(lcontext, out cStyle, out endBlock)); + while (!endBlock && lcontext.Lexer.Current.Type == TokenType.ElseIf) { + m_Ifs.Add(CreateIfBlock(lcontext, out cStyle, out endBlock)); } - - if (lcontext.Lexer.Current.Type == TokenType.Else) + if (!endBlock && lcontext.Lexer.Current.Type == TokenType.Else) { - m_Else = CreateElseBlock(lcontext); + m_Else = CreateElseBlock(lcontext, cStyle); } - - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); lcontext.Source.Refs.Add(m_End); } - IfBlock CreateIfBlock(ScriptLoadingContext lcontext) + + IfBlock CreateIfBlock(ScriptLoadingContext lcontext, out bool cstyle, out bool endBlock) { Token type = CheckTokenType(lcontext, TokenType.If, TokenType.ElseIf); - - lcontext.Scope.PushBlock(); - var ifblock = new IfBlock(); - ifblock.Exp = Expression.Expr(lcontext); - ifblock.Source = type.GetSourceRef(CheckTokenType(lcontext, TokenType.Then)); - ifblock.Block = new CompositeStatement(lcontext); - ifblock.StackFrame = lcontext.Scope.PopBlock(); + cstyle = false; + endBlock = false; + if (lcontext.Syntax == ScriptSyntax.Lua) + { + ifblock.Source = type.GetSourceRef(CheckTokenType(lcontext, TokenType.Then)); + ifblock.Block = new CompositeStatement(lcontext, BlockEndType.Normal); + if (lcontext.Lexer.Current.Type == TokenType.End) { + m_End = lcontext.Lexer.Current.GetSourceRef(); + lcontext.Lexer.Next(); + endBlock = true; + } + } + else + { + Token open = lcontext.Lexer.Current; + ifblock.Source = type.GetSourceRef(open); + if (open.Type == TokenType.Brk_Open_Curly) { + lcontext.Lexer.Next(); + ifblock.Block = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + m_End = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + cstyle = true; + } + else if (open.Type == TokenType.Then) { + lcontext.Lexer.Next(); + ifblock.Block = new CompositeStatement(lcontext, BlockEndType.Normal); + if (lcontext.Lexer.Current.Type == TokenType.End) { + m_End = lcontext.Lexer.Current.GetSourceRef(); + lcontext.Lexer.Next(); + endBlock = true; + } + } + else + { + ifblock.Source = type.GetSourceRef(lcontext.Lexer.Current); + ifblock.Block = Statement.CreateStatement(lcontext, out _); + if (ifblock.Block is IBlockStatement block) + m_End = block.End; + else + m_End = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + cstyle = true; + } + } lcontext.Source.Refs.Add(ifblock.Source); - - return ifblock; } + - IfBlock CreateElseBlock(ScriptLoadingContext lcontext) + IfBlock CreateElseBlock(ScriptLoadingContext lcontext, bool cstyle) { Token type = CheckTokenType(lcontext, TokenType.Else); - - lcontext.Scope.PushBlock(); - var ifblock = new IfBlock(); - ifblock.Block = new CompositeStatement(lcontext); - ifblock.StackFrame = lcontext.Scope.PopBlock(); - ifblock.Source = type.GetSourceRef(); + if (cstyle) + { + Token open = lcontext.Lexer.Current; + ifblock.Source = type.GetSourceRef(open); + if (open.Type == TokenType.Brk_Open_Curly) { + lcontext.Lexer.Next(); + ifblock.Block = new CompositeStatement(lcontext, BlockEndType.CloseCurly); + m_End = CheckTokenType(lcontext, TokenType.Brk_Close_Curly).GetSourceRef(); + } + else { + ifblock.Block = CreateStatement(lcontext, out _); + if (ifblock.Block is IBlockStatement block) + m_End = block.End; + else + m_End = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } + } + else + { + ifblock.Source = type.GetSourceRef(); + ifblock.Block = new CompositeStatement(lcontext, BlockEndType.Normal); + m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); + } lcontext.Source.Refs.Add(ifblock.Source); return ifblock; } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + foreach (var block in m_Ifs) + { + lcontext.Scope.PushBlock(); + block.Exp?.ResolveScope(lcontext); + block.Block?.ResolveScope(lcontext); + block.StackFrame = lcontext.Scope.PopBlock(); + } + if (m_Else != null) + { + lcontext.Scope.PushBlock(); + m_Else.Block?.ResolveScope(lcontext); + m_Else.StackFrame = lcontext.Scope.PopBlock(); + } + } + public override void Compile(Execution.VM.ByteCode bc) { - List endJumps = new List(); + List endJumps = new List(); - Instruction lastIfJmp = null; + int lastIfJmp = -1; foreach (var ifblock in m_Ifs) { using (bc.EnterSource(ifblock.Source)) { - if (lastIfJmp != null) - lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); + if (lastIfJmp != -1) + bc.SetNumVal(lastIfJmp, bc.GetJumpPointForNextInstruction()); - ifblock.Exp.Compile(bc); + ifblock.Exp.CompilePossibleLiteral(bc); lastIfJmp = bc.Emit_Jump(OpCode.Jf, -1); bc.Emit_Enter(ifblock.StackFrame); ifblock.Block.Compile(bc); @@ -95,7 +165,7 @@ public override void Compile(Execution.VM.ByteCode bc) endJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); } - lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); + bc.SetNumVal(lastIfJmp, bc.GetJumpPointForNextInstruction()); if (m_Else != null) { @@ -110,7 +180,7 @@ public override void Compile(Execution.VM.ByteCode bc) } foreach(var endjmp in endJumps) - endjmp.NumVal = bc.GetJumpPointForNextInstruction(); + bc.SetNumVal(endjmp, bc.GetJumpPointForNextInstruction()); } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/LabelStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/LabelStatement.cs index 6d562d23..87949e89 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/LabelStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/LabelStatement.cs @@ -21,13 +21,24 @@ class LabelStatement : Statement public LabelStatement(ScriptLoadingContext lcontext) : base(lcontext) { - CheckTokenType(lcontext, TokenType.DoubleColon); - NameToken = CheckTokenType(lcontext, TokenType.Name); - CheckTokenType(lcontext, TokenType.DoubleColon); + if (lcontext.Syntax == ScriptSyntax.CLike) + { + NameToken = CheckTokenType(lcontext, TokenType.Name); + CheckTokenType(lcontext, TokenType.Colon); + } + else + { + CheckTokenType(lcontext, TokenType.DoubleColon); + NameToken = CheckTokenType(lcontext, TokenType.Name); + CheckTokenType(lcontext, TokenType.DoubleColon); + } SourceRef = NameToken.GetSourceRef(); Label = NameToken.Text; + } + public override void ResolveScope(ScriptLoadingContext lcontext) + { lcontext.Scope.DefineLabel(this); } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/RepeatStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/RepeatStatement.cs index 7929ddf5..a9fa75a7 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/RepeatStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/RepeatStatement.cs @@ -5,32 +5,42 @@ namespace MoonSharp.Interpreter.Tree.Statements { - class RepeatStatement : Statement + class RepeatStatement : Statement, IBlockStatement { Expression m_Condition; Statement m_Block; RuntimeScopeBlock m_StackFrame; SourceRef m_Repeat, m_Until; + public SourceRef End => m_Until; + public RepeatStatement(ScriptLoadingContext lcontext) : base(lcontext) { m_Repeat = CheckTokenType(lcontext, TokenType.Repeat).GetSourceRef(); - lcontext.Scope.PushBlock(); - m_Block = new CompositeStatement(lcontext); - + bool openCurly = lcontext.Syntax != ScriptSyntax.Lua && + lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly; + if (openCurly) lcontext.Lexer.Next(); + m_Block = new CompositeStatement(lcontext, openCurly ? BlockEndType.CloseCurly : BlockEndType.Normal); + if (openCurly) CheckTokenType(lcontext, TokenType.Brk_Close_Curly); + Token until = CheckTokenType(lcontext, TokenType.Until); - m_Condition = Expression.Expr(lcontext); - m_Until = until.GetSourceRefUpTo(lcontext.Lexer.Current); - m_StackFrame = lcontext.Scope.PopBlock(); lcontext.Source.Refs.Add(m_Repeat); lcontext.Source.Refs.Add(m_Until); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); + m_Block.ResolveScope(lcontext); + m_Condition.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopBlock(); + } + public override void Compile(ByteCode bc) { Loop L = new Loop() @@ -50,7 +60,7 @@ public override void Compile(ByteCode bc) bc.PopSourceRef(); bc.PushSourceRef(m_Until); bc.Emit_Debug("..end"); - + int continuePoint = bc.GetJumpPointForNextInstruction(); m_Condition.Compile(bc); bc.Emit_Leave(m_StackFrame); bc.Emit_Jump(OpCode.Jf, start); @@ -59,8 +69,10 @@ public override void Compile(ByteCode bc) int exitpoint = bc.GetJumpPointForNextInstruction(); - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); bc.PopSourceRef(); } diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ReturnStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ReturnStatement.cs index e0ab2f98..b7681752 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/ReturnStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/ReturnStatement.cs @@ -18,8 +18,10 @@ public ReturnStatement(ScriptLoadingContext lcontext, Expression e, SourceRef sr lcontext.Source.Refs.Add(sref); } - - + public override void ResolveScope(ScriptLoadingContext lcontext) + { + m_Expression?.ResolveScope(lcontext); + } public ReturnStatement(ScriptLoadingContext lcontext) : base(lcontext) @@ -51,7 +53,7 @@ public override void Compile(Execution.VM.ByteCode bc) { if (m_Expression != null) { - m_Expression.Compile(bc); + m_Expression.CompilePossibleLiteral(bc); bc.Emit_Ret(1); } else diff --git a/src/MoonSharp.Interpreter/Tree/Statements/ScopeBlockStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/ScopeBlockStatement.cs deleted file mode 100644 index cac73104..00000000 --- a/src/MoonSharp.Interpreter/Tree/Statements/ScopeBlockStatement.cs +++ /dev/null @@ -1,42 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ScopeBlockStatement : Statement - { - Statement m_Block; - RuntimeScopeBlock m_StackFrame; - SourceRef m_Do, m_End; - - public ScopeBlockStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - lcontext.Scope.PushBlock(); - - m_Do = CheckTokenType(lcontext, TokenType.Do).GetSourceRef(); - - m_Block = new CompositeStatement(lcontext); - - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - - m_StackFrame = lcontext.Scope.PopBlock(); - lcontext.Source.Refs.Add(m_Do); - lcontext.Source.Refs.Add(m_End); - } - - - - public override void Compile(Execution.VM.ByteCode bc) - { - using(bc.EnterSource(m_Do)) - bc.Emit_Enter(m_StackFrame); - - m_Block.Compile(bc); - - using (bc.EnterSource(m_End)) - bc.Emit_Leave(m_StackFrame); - } - - } -} diff --git a/src/MoonSharp.Interpreter/Tree/Statements/WhileStatement.cs b/src/MoonSharp.Interpreter/Tree/Statements/WhileStatement.cs index 39bcfd70..632c4a1a 100644 --- a/src/MoonSharp.Interpreter/Tree/Statements/WhileStatement.cs +++ b/src/MoonSharp.Interpreter/Tree/Statements/WhileStatement.cs @@ -5,13 +5,16 @@ namespace MoonSharp.Interpreter.Tree.Statements { - class WhileStatement : Statement + class WhileStatement : Statement, IBlockStatement { Expression m_Condition; Statement m_Block; RuntimeScopeBlock m_StackFrame; SourceRef m_Start, m_End; + + public SourceRef End => m_End; + public WhileStatement(ScriptLoadingContext lcontext) : base(lcontext) { @@ -21,19 +24,39 @@ public WhileStatement(ScriptLoadingContext lcontext) m_Start = whileTk.GetSourceRefUpTo(lcontext.Lexer.Current); - //m_Start = BuildSourceRef(context.Start, exp.Stop); - //m_End = BuildSourceRef(context.Stop, context.END()); + + + if (lcontext.Syntax != ScriptSyntax.Lua && + lcontext.Lexer.Current.Type != TokenType.Do && + lcontext.Lexer.Current.Type != TokenType.Brk_Open_Curly) + { + m_Block = CreateStatement(lcontext, out _); + if (m_Block is IBlockStatement block) + m_End = block.End; + else + m_End = CheckTokenType(lcontext, TokenType.SemiColon).GetSourceRef(); + } + else + { + var tk = CheckTokenTypeEx(lcontext, TokenType.Do, TokenType.Brk_Open_Curly); + m_Block = new CompositeStatement(lcontext, + tk.Type == TokenType.Brk_Open_Curly ? BlockEndType.CloseCurly : BlockEndType.Normal); + m_End = CheckTokenTypeEx(lcontext, TokenType.End, TokenType.Brk_Close_Curly).GetSourceRef(); + } - lcontext.Scope.PushBlock(); - CheckTokenType(lcontext, TokenType.Do); - m_Block = new CompositeStatement(lcontext); - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - m_StackFrame = lcontext.Scope.PopBlock(); lcontext.Source.Refs.Add(m_Start); lcontext.Source.Refs.Add(m_End); } + public override void ResolveScope(ScriptLoadingContext lcontext) + { + lcontext.Scope.PushBlock(); + m_Condition.ResolveScope(lcontext); + m_Block.ResolveScope(lcontext); + m_StackFrame = lcontext.Scope.PopBlock(); + } + public override void Compile(ByteCode bc) { @@ -60,6 +83,7 @@ public override void Compile(ByteCode bc) bc.Emit_Debug("..end"); bc.PushSourceRef(m_End); + int continuePoint = bc.GetJumpPointForNextInstruction(); bc.Emit_Leave(m_StackFrame); bc.Emit_Jump(OpCode.Jump, start); @@ -67,10 +91,12 @@ public override void Compile(ByteCode bc) int exitpoint = bc.GetJumpPointForNextInstruction(); - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; - - jumpend.NumVal = exitpoint; + foreach (int i in L.BreakJumps) + bc.SetNumVal(i, exitpoint); + foreach (int i in L.ContinueJumps) + bc.SetNumVal(i, continuePoint); + + bc.SetNumVal(jumpend, exitpoint); bc.PopSourceRef(); } diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/MoonSharp.Interpreter.net40-client.csproj b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/MoonSharp.Interpreter.net40-client.csproj deleted file mode 100755 index e5ea7555..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/MoonSharp.Interpreter.net40-client.csproj +++ /dev/null @@ -1,829 +0,0 @@ - - - - - Debug - AnyCPU - {88D2880C-A863-4B16-ABEF-F67BD1E98BD1} - Library - Properties - MoonSharp.Interpreter.net40_client - MoonSharp.Interpreter - v4.0 - 512 - Client - true - ..\..\..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG;HASDYNAMIC - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;HASDYNAMIC - prompt - 4 - bin\Release\MoonSharp.Interpreter.XML - - - true - bin\Dev\ - TRACE;DEBUG;HASDYNAMIC - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG;HASDYNAMIC - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - AsyncExtensions.cs - - - AstNode.cs - - - Framework.cs - - - FrameworkBase.cs - - - FrameworkCLR.cs - - - FrameworkReflectionBase.cs - - - FrameworkClrBase.cs - - - FrameworkCore.cs - - - FrameworkPCL.cs - - - FrameworkWin8.cs - - - CoroutineModule.cs - - - BasicModule.cs - - - DebugModule.cs - - - DynamicModule.cs - - - ErrorHandlingModule.cs - - - BinaryEncoding.cs - - - FileUserData.cs - - - IoModule.cs - - - FileUserDataBase.cs - - - StandardIOFileUserDataBase.cs - - - StreamFileUserDataBase.cs - - - JsonModule.cs - - - LoadModule.cs - - - Bit32Module.cs - - - MathModule.cs - - - MetaTableModule.cs - - - OsSystemModule.cs - - - OsTimeModule.cs - - - KopiLua_StrLib.cs - - - MultiDictionary.cs - - - ReferenceEqualityComparer.cs - - - DebuggerCaps.cs - - - DebugService.cs - - - OpCodeMetadataType.cs - - - MoonSharpPropertyAttribute.cs - - - MoonSharpUserDataMetamethodAttribute.cs - - - MoonSharpHideMemberAttribute.cs - - - MoonSharpHiddenAttribute.cs - - - IMemberDescriptor.cs - - - IOptimizableDescriptor.cs - - - IOverloadableMemberDescriptor.cs - - - IWireableDescriptor.cs - - - MemberDescriptorAccess.cs - - - ParameterDescriptor.cs - - - ClrToScriptConversions.cs - - - NumericConversions.cs - - - ScriptToClrConversions.cs - - - StringConversions.cs - - - TableConversions.cs - - - CustomConvertersCollection.cs - - - DescriptorHelpers.cs - - - DispatchingUserDataDescriptor.cs - - - IGeneratorUserDataDescriptor.cs - - - PropertyTableAssigner.cs - - - DelegateProxyFactory.cs - - - IProxyFactory.cs - - - ReflectionSpecialNames.cs - - - AutomaticRegistrationPolicy.cs - - - DefaultRegistrationPolicy.cs - - - PermanentRegistrationPolicy.cs - - - IRegistrationPolicy.cs - - - EventFacade.cs - - - DefaultValue.cs - - - HardwiredMemberDescriptor.cs - - - HardwiredMethodMemberDescriptor.cs - - - HardwiredUserDataDescriptor.cs - - - ArrayMemberDescriptor.cs - - - ProxyUserDataDescriptor.cs - - - ObjectCallbackMemberDescriptor.cs - - - FunctionMemberDescriptorBase.cs - - - StandardEnumUserDataDescriptor.cs - - - DynValueMemberDescriptor.cs - - - EventMemberDescriptor.cs - - - OverloadedMethodMemberDescriptor.cs - - - FieldMemberDescriptor.cs - - - ValueTypeDefaultCtorMemberDescriptor.cs - - - StandardGenericsUserDataDescriptor.cs - - - ExtensionMethodsRegistry.cs - - - TypeDescriptorRegistry.cs - - - BinDumpBinaryReader.cs - - - Code - BinDumpBinaryWriter.cs - - - UndisposableStream.cs - - - InstructionFieldUsage.cs - - - Processor_BinaryDump.cs - - - InteropRegistrationPolicy.cs - - - IUserDataType.cs - - - ScriptFunctionDelegate.cs - - - TypeValidationFlags.cs - - - DynamicExpressionException.cs - - - DynamicExpression.cs - - - CallStackItemFlags.cs - - - AnonWrapper.cs - - - IUserDataDescriptor.cs - - - CharPtr.cs - - - LuaBase.cs - - - StringRange.cs - - - Tools.cs - - - StringModule.cs - - - TableIteratorsModule.cs - - - TableModule.cs - - - Extension_Methods.cs - - - FastStackDynamic.cs - - - LinkedListIndex.cs - - - Slice.cs - - - Coroutine.cs - - - IScriptPrivateResource.cs - - - RefIdObject.cs - - - TailCallData.cs - - - Code - UserData.cs - - - WellKnownSymbols.cs - - - YieldRequest.cs - - - DebuggerAction.cs - - - IDebugger.cs - - - SourceRef.cs - - - WatchItem.cs - - - WatchType.cs - - - DummyPerformanceStopwatch.cs - - - IPerformanceStopwatch.cs - - - PerformanceCounter.cs - - - GlobalPerformanceStopwatch.cs - - - PerformanceCounterType.cs - - - PerformanceStatistics.cs - - - PerformanceResult.cs - - - PerformanceStopwatch.cs - - - Code - ScriptRuntimeException.cs - - - InternalErrorException.cs - - - InterpreterException.cs - - - SyntaxErrorException.cs - - - CallbackArguments.cs - - - Closure.cs - - - CallbackFunction.cs - - - Code - DynValue.cs - - - TablePair.cs - - - Code - ScriptExecutionContext.cs - - - SourceCode.cs - - - CoroutineState.cs - - - ExecutionState.cs - - - DebugContext.cs - - - Processor_Coroutines.cs - - - Processor_Errors.cs - - - EnumerableWrapper.cs - - - LinqHelpers.cs - - - LuaBase_CLib.cs - - - LuaLBuffer.cs - - - LuaState.cs - - - MoonSharpUserDataAttribute.cs - - - MoonSharpVisibleAttribute.cs - - - Code - AutoDescribingUserDataDescriptor.cs - - - Code - CompositeUserDataDescriptor.cs - - - StandardUserDataDescriptor.cs - - - InteropAccessMode.cs - - - MethodMemberDescriptor.cs - - - Code - PropertyMemberDescriptor.cs - - - ClosureContext.cs - - - LoopTracker.cs - - - IClosureBuilder.cs - - - SymbolRefType.cs - - - SymbolRef.cs - - - BuildTimeScope.cs - - - BuildTimeScopeBlock.cs - - - BuildTimeScopeFrame.cs - - - RuntimeScopeBlock.cs - - - RuntimeScopeFrame.cs - - - ScriptLoadingContext.cs - - - DataType.cs - - - EmbeddedResourcesScriptLoader.cs - - - FileSystemScriptLoader.cs - - - InvalidScriptLoader.cs - - - ColonOperatorBehaviour.cs - - - FuzzySymbolMatchingBehaviour.cs - - - DotNetCorePlatformAccessor.cs - - - ReplHistoryNavigator.cs - - - ReplInterpreterScriptLoader.cs - - - ScriptLoaderBase.cs - - - IScriptLoader.cs - - - UnityAssetsScriptLoader.cs - - - MoonSharpModuleConstantAttribute.cs - - - NameSpace_XmlHelp.cs - - - IPlatformAccessor.cs - - - PlatformAccessorBase.cs - - - PlatformAutoDetector.cs - - - LimitedPlatformAccessor.cs - - - StandardFileType.cs - - - StandardPlatformAccessor.cs - - - Attributes.cs - - - Stopwatch.cs - - - ReplInterpreter.cs - - - Script.cs - - - Table.cs - - - ByteCode.cs - - - FastStack.cs - - - Instruction.cs - - - OpCode.cs - - - CallStackItem.cs - - - Code - Processor.cs - - - Processor_Debugger.cs - - - Processor_IExecutionContext.cs - - - Processor_InstructionLoop.cs - - - Processor_Scope.cs - - - Processor_UtilityFunctions.cs - - - CoreModules.cs - - - Code - ModuleRegister.cs - - - MoonSharpModuleMethodAttribute.cs - - - Code - MoonSharpModuleAttribute.cs - - - ScriptGlobalOptions.cs - - - ScriptOptions.cs - - - JsonNull.cs - - - JsonTableConverter.cs - - - ObjectValueConverter.cs - - - SerializationExtensions.cs - - - AdjustmentExpression.cs - - - BinaryOperatorExpression.cs - - - DynamicExprExpression.cs - - - FunctionCallExpression.cs - - - FunctionDefinitionExpression.cs - - - LiteralExpression.cs - - - UnaryOperatorExpression.cs - - - Loader_Fast.cs - - - GotoStatement.cs - - - IVariable.cs - - - AssemblyInfo.cs - - - ExprListExpression.cs - - - IndexExpression.cs - - - LexerUtils.cs - - - EmptyStatement.cs - - - FunctionCallStatement.cs - - - FunctionDefinitionStatement.cs - - - Expression_.cs - - - SymbolRefExpression.cs - - - Lexer.cs - - - Token.cs - - - TokenType.cs - - - Loop.cs - - - NodeBase.cs - - - AssignmentStatement.cs - - - Code - ChunkStatement.cs - - - CompositeStatement.cs - - - BreakStatement.cs - - - ForEachLoopStatement.cs - - - ForLoopStatement.cs - - - IfStatement.cs - - - Statement.cs - - - LabelStatement.cs - - - RepeatStatement.cs - - - ReturnStatement.cs - - - TableConstructor.cs - - - ScopeBlockStatement.cs - - - WhileStatement.cs - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/Properties/AssemblyInfo.cs deleted file mode 100644 index 4b45c75c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.net40-client/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Interpreter.net40-client")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.net40-client")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("eb83d8ed-c31a-4c98-94f3-ca5a0f192867")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/MoonSharp.Interpreter.netcore.csproj b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/MoonSharp.Interpreter.netcore.csproj deleted file mode 100644 index 844a45aa..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/MoonSharp.Interpreter.netcore.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - http://www.moonsharp.org - (C) 2014-2016 Marco Mastropaolo - MoonSharp.Interpreter - 2.0.0 - netstandard1.6 - $(DefineConstants);DOTNET_CORE;NETFX_CORE - MoonSharp.Interpreter - MoonSharp.Interpreter.netcore - 1.6.0 - $(PackageTargetFallback);dnxcore50 - false - false - false - - - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/Properties/AssemblyInfo.cs deleted file mode 100755 index f8962244..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Interpreter.netcore")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cb2cb168-36c8-4d55-809c-7061cf4f6854")] diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/AsyncExtensions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/AsyncExtensions.cs deleted file mode 100755 index eb0055c5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/AsyncExtensions.cs +++ /dev/null @@ -1,421 +0,0 @@ -#if HASDYNAMIC -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using MoonSharp.Interpreter.REPL; - -namespace MoonSharp.Interpreter -{ - /// - /// This class contains extension methods providing async wrappers of many methods. - /// Asynchronous execution is performed by scheduling the method on the thread pool (through a Task.Factory.StartNew). - /// - /// This type is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - public static class AsyncExtensions - { - private static Task ExecAsync(Func func) - { - return Task.Factory.StartNew(func); - } - - private static Task ExecAsyncVoid(Action func) - { - return Task.Factory.StartNew(func); - } - - - - /// - /// Asynchronously calls this function with the specified args - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The function. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Closure function) - { - return ExecAsync(() => function.Call()); - } - - /// - /// Asynchronously calls this function with the specified args - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The function. - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Closure function, params object[] args) - { - return ExecAsync(() => function.Call(args)); - } - - /// - /// Asynchronously calls this function with the specified args - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The function. - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Closure function, params DynValue[] args) - { - return ExecAsync(() => function.Call(args)); - } - - /// - /// Asynchronously loads and executes a string containing a Lua/MoonSharp script. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The code. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public static Task DoStringAsync(this Script script, string code, Table globalContext = null, string codeFriendlyName = null) - { - return ExecAsync(() => script.DoString(code, globalContext, codeFriendlyName)); - } - - - /// - /// Asynchronously loads and executes a stream containing a Lua/MoonSharp script. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The stream. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public static Task DoStreamAsync(this Script script, Stream stream, Table globalContext = null, string codeFriendlyName = null) - { - return ExecAsync(() => script.DoStream(stream, globalContext, codeFriendlyName)); - } - - - /// - /// Asynchronously loads and executes a file containing a Lua/MoonSharp script. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The filename. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public static Task DoFileAsync(this Script script, string filename, Table globalContext = null, string codeFriendlyName = null) - { - return ExecAsync(() => script.DoFile(filename, globalContext, codeFriendlyName)); - } - - /// - /// Asynchronously loads a string containing a Lua/MoonSharp function. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The code. - /// The global table to bind to this chunk. - /// Name of the function used to report errors, etc. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public static Task LoadFunctionAsync(this Script script, string code, Table globalTable = null, string funcFriendlyName = null) - { - return ExecAsync(() => script.LoadFunction(code, globalTable, funcFriendlyName)); - } - - - - /// - /// Asynchronously loads a string containing a Lua/MoonSharp script. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The code. - /// The global table to bind to this chunk. - /// Name of the code - used to report errors, etc. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public static Task LoadStringAsync(this Script script, string code, Table globalTable = null, string codeFriendlyName = null) - { - return ExecAsync(() => script.LoadString(code, globalTable, codeFriendlyName)); - } - - - - /// - /// Asynchronously loads a Lua/MoonSharp script from a System.IO.Stream. NOTE: This will *NOT* close the stream! - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The stream containing code. - /// The global table to bind to this chunk. - /// Name of the code - used to report errors, etc. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public static Task LoadStreamAsync(this Script script, Stream stream, Table globalTable = null, string codeFriendlyName = null) - { - return ExecAsync(() => script.LoadStream(stream, globalTable, codeFriendlyName)); - } - - - /// - /// Asynchronously dumps a function on the specified stream. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The function. - /// The stream. - /// - /// function arg is not a function! - /// or - /// stream is readonly! - /// or - /// function arg has upvalues other than _ENV - public static Task DumpAsync(this Script script, DynValue function, Stream stream) - { - return ExecAsyncVoid(() => script.Dump(function, stream)); - } - - - - /// - /// Asynchronously loads a string containing a Lua/MoonSharp script. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The code. - /// The global table to bind to this chunk. - /// The filename to be used in error messages. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public static Task LoadFileAsync(this Script script, string filename, Table globalContext = null, string friendlyFilename = null) - { - return ExecAsync(() => script.LoadFile(filename, globalContext, friendlyFilename)); - } - - - - /// - /// Calls the specified function. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The Lua/MoonSharp function to be called - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Script script, DynValue function) - { - return ExecAsync(() => script.Call(function)); - } - - - /// - /// Asynchronously calls the specified function. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Script script, DynValue function, params DynValue[] args) - { - return ExecAsync(() => script.Call(function, args)); - } - - - - /// - /// Asynchronously calls the specified function. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Script script, DynValue function, params object[] args) - { - return ExecAsync(() => script.Call(function, args)); - } - - - - /// - /// Asynchronously calls the specified function. - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The Lua/MoonSharp function to be called - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Script script, object function) - { - return ExecAsync(() => script.Call(function)); - } - - - /// - /// Asynchronously calls the specified function. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public static Task CallAsync(this Script script, object function, params object[] args) - { - return ExecAsync(() => script.Call(function, args)); - } - - /// - /// Asynchronously creates a new dynamic expression. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The script. - /// The code of the expression. - /// - public static Task CreateDynamicExpressionAsync(this Script script, string code) - { - return ExecAsync(() => script.CreateDynamicExpression(code)); - } - - /// - /// Asynchronously evaluates a REPL command. - /// This method returns the result of the computation, or null if more input is needed for having valid code. - /// In case of errors, exceptions are propagated to the caller. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The interpreter. - /// The input. - /// - /// This method returns the result of the computation, or null if more input is needed for a computation. - /// - public static Task EvaluateAsync(this ReplInterpreter interpreter, string input) - { - return ExecAsync(() => interpreter.Evaluate(input)); - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// The arguments. - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public static Task ResumeAsync(this Coroutine cor, params DynValue[] args) - { - return ExecAsync(() => cor.Resume(args)); - } - - - /// - /// Resumes the coroutine. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// The ScriptExecutionContext. - /// The arguments. - /// - public static Task ResumeAsync(this Coroutine cor, ScriptExecutionContext context, params DynValue[] args) - { - return ExecAsync(() => cor.Resume(context, args)); - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public static Task ResumeAsync(this Coroutine cor) - { - return ExecAsync(() => cor.Resume()); - } - - - /// - /// Resumes the coroutine. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// The ScriptExecutionContext. - /// - public static Task ResumeAsync(this Coroutine cor, ScriptExecutionContext context) - { - return ExecAsync(() => cor.Resume(context)); - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// The arguments. - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - public static Task ResumeAsync(this Coroutine cor, params object[] args) - { - return ExecAsync(() => cor.Resume(args)); - } - - - /// - /// Resumes the coroutine - /// - /// This method is supported only on .NET 4.x and .NET 4.x PCL targets. - /// - /// The coroutine - /// The ScriptExecutionContext. - /// The arguments. - /// - public static Task ResumeAsync(this Coroutine cor, ScriptExecutionContext context, params object[] args) - { - return ExecAsync(() => cor.Resume(context, args)); - } - } -} -#endif diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CodeAnalysis/AstNode.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CodeAnalysis/AstNode.cs deleted file mode 100644 index 0d098766..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CodeAnalysis/AstNode.cs +++ /dev/null @@ -1,7 +0,0 @@ - -namespace MoonSharp.Interpreter.CodeAnalysis -{ - class AstNode - { - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Attributes.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Attributes.cs deleted file mode 100755 index a53bc57c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Attributes.cs +++ /dev/null @@ -1,21 +0,0 @@ -#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System.Reflection -{ - internal class ComVisibleAttribute : Attribute - { - public ComVisibleAttribute(bool dummy) - { } - } - internal class GuidAttribute : Attribute - { - public GuidAttribute(string dummy) - { } - } -} -#endif - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Framework.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Framework.cs deleted file mode 100755 index 5961fd1e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Framework.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility.Frameworks; - -namespace MoonSharp.Interpreter.Compatibility -{ - public static class Framework - { - static FrameworkCurrent s_FrameworkCurrent = new FrameworkCurrent(); - - public static FrameworkBase Do { get { return s_FrameworkCurrent; } } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkBase.cs deleted file mode 100755 index fd60c9db..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkBase.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - public abstract class FrameworkBase - { - public abstract bool StringContainsChar(string str, char chr); - - public abstract bool IsValueType(Type t); - - public abstract Assembly GetAssembly(Type t); - - public abstract Type GetBaseType(Type t); - - public abstract bool IsGenericType(Type t); - - public abstract bool IsGenericTypeDefinition(Type t); - - public abstract bool IsEnum(Type t); - - public abstract bool IsNestedPublic(Type t); - - public abstract bool IsAbstract(Type t); - - public abstract bool IsInterface(Type t); - - public abstract Attribute[] GetCustomAttributes(Type t, bool inherit); - - public abstract Attribute[] GetCustomAttributes(Type t, Type at, bool inherit); - - public abstract Type[] GetInterfaces(Type t); - - public abstract bool IsInstanceOfType(Type t, object o); - - public abstract MethodInfo GetAddMethod(EventInfo ei); - - public abstract MethodInfo GetRemoveMethod(EventInfo ei); - - public abstract MethodInfo GetGetMethod(PropertyInfo pi); - - public abstract MethodInfo GetSetMethod(PropertyInfo pi); - - public abstract Type GetInterface(Type type, string name); - - public abstract PropertyInfo[] GetProperties(Type type); - - public abstract PropertyInfo GetProperty(Type type, string name); - - public abstract Type[] GetNestedTypes(Type type); - - public abstract EventInfo[] GetEvents(Type type); - - public abstract ConstructorInfo[] GetConstructors(Type type); - - public abstract Type[] GetAssemblyTypes(Assembly asm); - - public abstract MethodInfo[] GetMethods(Type type); - - public abstract FieldInfo[] GetFields(Type t); - - public abstract MethodInfo GetMethod(Type type, string name); - - public abstract Type[] GetGenericArguments(Type t); - - public abstract bool IsAssignableFrom(Type current, Type toCompare); - - public abstract bool IsDbNull(object o); - - public abstract MethodInfo GetMethod(Type resourcesType, string v, Type[] type); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkClrBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkClrBase.cs deleted file mode 100755 index 1391755b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkClrBase.cs +++ /dev/null @@ -1,111 +0,0 @@ -#if !NETFX_CORE || DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkClrBase : FrameworkReflectionBase - { - BindingFlags BINDINGFLAGS_MEMBER = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - BindingFlags BINDINGFLAGS_INNERCLASS = BindingFlags.Public | BindingFlags.NonPublic; - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.GetAddMethod(true); - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return GetTypeInfoFromType(type).GetConstructors(BINDINGFLAGS_MEMBER); - } - - public override EventInfo[] GetEvents(Type type) - { - return GetTypeInfoFromType(type).GetEvents(BINDINGFLAGS_MEMBER); - } - - public override FieldInfo[] GetFields(Type type) - { - return GetTypeInfoFromType(type).GetFields(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetGenericArguments(Type type) - { - return GetTypeInfoFromType(type).GetGenericArguments(); - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetGetMethod(true); - } - - public override Type[] GetInterfaces(Type t) - { - return GetTypeInfoFromType(t).GetInterfaces(); - } - - public override MethodInfo GetMethod(Type type, string name) - { - return GetTypeInfoFromType(type).GetMethod(name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return GetTypeInfoFromType(type).GetMethods(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetNestedTypes(Type type) - { - return GetTypeInfoFromType(type).GetNestedTypes(BINDINGFLAGS_INNERCLASS); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return GetTypeInfoFromType(type).GetProperties(BINDINGFLAGS_MEMBER); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return GetTypeInfoFromType(type).GetProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.GetRemoveMethod(true); - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.GetSetMethod(true); - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return GetTypeInfoFromType(current).IsAssignableFrom(toCompare); - } - - public override bool IsInstanceOfType(Type t, object o) - { - return GetTypeInfoFromType(t).IsInstanceOfType(o); - } - - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return GetTypeInfoFromType(resourcesType).GetMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return asm.GetTypes(); - } - - } -} - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs deleted file mode 100755 index 10913658..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -#if DOTNET_CORE - using TTypeInfo = System.Reflection.TypeInfo; -#elif NETFX_CORE - using TTypeInfo = System.Reflection.TypeInfo; -#else - using TTypeInfo = System.Type; -#endif - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkReflectionBase : FrameworkBase - { - public abstract TTypeInfo GetTypeInfoFromType(Type t); - - public override Assembly GetAssembly(Type t) - { - return GetTypeInfoFromType(t).Assembly; - } - - public override Type GetBaseType(Type t) - { - return GetTypeInfoFromType(t).BaseType; - } - - - public override bool IsValueType(Type t) - { - return GetTypeInfoFromType(t).IsValueType; - } - - public override bool IsInterface(Type t) - { - return GetTypeInfoFromType(t).IsInterface; - } - - public override bool IsNestedPublic(Type t) - { - return GetTypeInfoFromType(t).IsNestedPublic; - } - public override bool IsAbstract(Type t) - { - return GetTypeInfoFromType(t).IsAbstract; - } - - public override bool IsEnum(Type t) - { - return GetTypeInfoFromType(t).IsEnum; - } - - public override bool IsGenericTypeDefinition(Type t) - { - return GetTypeInfoFromType(t).IsGenericTypeDefinition; - } - - public override bool IsGenericType(Type t) - { - return GetTypeInfoFromType(t).IsGenericType; - } - - public override Attribute[] GetCustomAttributes(Type t, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(inherit).OfType().ToArray(); - } - - public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType().ToArray(); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCLR.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCLR.cs deleted file mode 100755 index a362eb02..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCLR.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if !(DOTNET_CORE || NETFX_CORE) && !PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetTypeInfoFromType(Type t) - { - return t; - } - - public override bool IsDbNull(object o) - { - return o != null && Convert.IsDBNull(o); - } - - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterface(name); - } - } -} - -#endif diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCore.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCore.cs deleted file mode 100755 index c8c0b39a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkCore.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetInterface(Type type, string name) - { - return type.GetTypeInfo().GetInterface(name); - } - - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - } -} -#endif diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkPCL.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkPCL.cs deleted file mode 100755 index c3bcc58b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkPCL.cs +++ /dev/null @@ -1,35 +0,0 @@ -#if !(DOTNET_CORE || NETFX_CORE) && PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override Type GetTypeInfoFromType(Type t) - { - return t; - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr.ToString()); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterfaces(). - FirstOrDefault(t => t.Name == name); - } - } -} - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkWin8.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkWin8.cs deleted file mode 100755 index 7fd903b2..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Frameworks/FrameworkWin8.cs +++ /dev/null @@ -1,134 +0,0 @@ -#if NETFX_CORE && !DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkReflectionBase - { - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - private T[] SafeArray(IEnumerable prop) - { - return prop != null ? prop.ToArray() : new T[0]; - } - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.AddMethod; - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); - } - - public override EventInfo[] GetEvents(Type type) - { - return SafeArray(type.GetRuntimeEvents()); - } - - public override FieldInfo[] GetFields(Type type) - { - return SafeArray(type.GetRuntimeFields()); - } - - public override Type[] GetGenericArguments(Type type) - { - return type.GetTypeInfo().GenericTypeArguments; - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetMethod; - } - - public override Type GetInterface(Type type, string name) - { - return type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(t => t.Name == name); - } - - public override Type[] GetInterfaces(Type t) - { - return SafeArray(GetTypeInfoFromType(t).ImplementedInterfaces); - } - - public override MethodInfo GetMethod(Type type, string name) - { - return type.GetRuntimeMethods().FirstOrDefault(mi => mi.Name == name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return SafeArray(type.GetRuntimeMethods()); - } - - public override Type[] GetNestedTypes(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return SafeArray(type.GetRuntimeProperties()); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return type.GetRuntimeProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.RemoveMethod; - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.SetMethod; - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); - } - - public override bool IsDbNull(object o) - { - return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool IsInstanceOfType(Type t, object o) - { - if (o == null) - return false; - - return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo()); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return resourcesType.GetRuntimeMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return SafeArray(asm.DefinedTypes.Select(ti => ti.AsType())); - } - - } -} -#endif diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Stopwatch.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Stopwatch.cs deleted file mode 100755 index 0655757f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Compatibility/Stopwatch.cs +++ /dev/null @@ -1,41 +0,0 @@ -#if PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace System.Diagnostics -{ - internal class Stopwatch - { - DateTime startTime, stopTime; - - public void Start() - { - startTime = DateTime.UtcNow; - } - - public void Stop() - { - stopTime = DateTime.UtcNow; - } - - public static Stopwatch StartNew() - { - Stopwatch sw = new Stopwatch(); - sw.Start(); - return sw; - } - - public long ElapsedMilliseconds - { - get - { - return (long)((stopTime - startTime).TotalMilliseconds); - } - } - - - } -} -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/BasicModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/BasicModule.cs deleted file mode 100755 index 9e93ae3d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/BasicModule.cs +++ /dev/null @@ -1,273 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing basic Lua functions (print, type, tostring, etc) as a MoonSharp module. - /// - [MoonSharpModule] - public class BasicModule - { - //type (v) - //---------------------------------------------------------------------------------------------------------------- - //Returns the type of its only argument, coded as a string. The possible results of this function are "nil" - //(a string, not the value nil), "number", "string", "boolean", "table", "function", "thread", and "userdata". - [MoonSharpModuleMethod] - public static DynValue type(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args.Count < 1) throw ScriptRuntimeException.BadArgumentValueExpected(0, "type"); - - DynValue v = args[0]; - return DynValue.NewString(v.Type.ToLuaTypeString()); - } - - - - //assert (v [, message]) - //---------------------------------------------------------------------------------------------------------------- - //Issues an error when the value of its argument v is false (i.e., nil or false); - //otherwise, returns all its arguments. message is an error message; when absent, it defaults to "assertion failed!" - [MoonSharpModuleMethod] - public static DynValue assert(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args[0]; - DynValue message = args[1]; - - if (!v.CastToBool()) - { - if (message.IsNil()) - throw new ScriptRuntimeException("assertion failed!"); // { DoNotDecorateMessage = true }; - else - throw new ScriptRuntimeException(message.ToPrintString()); // { DoNotDecorateMessage = true }; - } - - return DynValue.NewTupleNested(args.GetArray()); - } - - // collectgarbage ([opt [, arg]]) - // ---------------------------------------------------------------------------------------------------------------- - // This function is mostly a stub towards the CLR GC. If mode is nil, "collect" or "restart", a GC is forced. - [MoonSharpModuleMethod] - public static DynValue collectgarbage(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue opt = args[0]; - - string mode = opt.CastToString(); - - if (mode == null || mode == "collect" || mode == "restart") - { -#if PCL || ENABLE_DOTNET - GC.Collect(); -#else - GC.Collect(2, GCCollectionMode.Forced); -#endif - } - - return DynValue.Nil; - } - - // error (message [, level]) - // ---------------------------------------------------------------------------------------------------------------- - // Terminates the last protected function called and returns message as the error message. Function error never returns. - // Usually, error adds some information about the error position at the beginning of the message. - // The level argument specifies how to get the error position. - // With level 1 (the default), the error position is where the error function was called. - // Level 2 points the error to where the function that called error was called; and so on. - // Passing a level 0 avoids the addition of error position information to the message. - [MoonSharpModuleMethod] - public static DynValue error(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue message = args.AsType(0, "error", DataType.String, false); - throw new ScriptRuntimeException(message.String); // { DoNotDecorateMessage = true }; - } - - - // tostring (v) - // ---------------------------------------------------------------------------------------------------------------- - // Receives a value of any type and converts it to a string in a reasonable format. (For complete control of how - // numbers are converted, use string.format.) - // - // If the metatable of v has a "__tostring" field, then tostring calls the corresponding value with v as argument, - // and uses the result of the call as its result. - [MoonSharpModuleMethod] - public static DynValue tostring(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args.Count < 1) throw ScriptRuntimeException.BadArgumentValueExpected(0, "tostring"); - - DynValue v = args[0]; - DynValue tail = executionContext.GetMetamethodTailCall(v, "__tostring", v); - - if (tail == null || tail.IsNil()) - return DynValue.NewString(v.ToPrintString()); - - tail.TailCallData.Continuation = new CallbackFunction(__tostring_continuation, "__tostring"); - - return tail; - } - - private static DynValue __tostring_continuation(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue b = args[0].ToScalar(); - - if (b.IsNil()) - return b; - - if (b.Type != DataType.String) - throw new ScriptRuntimeException("'tostring' must return a string"); - - - return b; - } - - // select (index, ...) - // ----------------------------------------------------------------------------- - // If index is a number, returns all arguments after argument number index; a negative number indexes from - // the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total - // number of extra arguments it received. - [MoonSharpModuleMethod] - public static DynValue select(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args[0].Type == DataType.String && args[0].String == "#") - { - if (args[args.Count - 1].Type == DataType.Tuple) - { - return DynValue.NewNumber(args.Count - 1 + args[args.Count - 1].Tuple.Length); - } - else - { - return DynValue.NewNumber(args.Count - 1); - } - } - - DynValue v_num = args.AsType(0, "select", DataType.Number, false); - int num = (int)v_num.Number; - - List values = new List(); - - if (num > 0) - { - for (int i = num; i < args.Count; i++) - values.Add(args[i]); - } - else if (num < 0) - { - num = args.Count + num; - - if (num < 1) - throw ScriptRuntimeException.BadArgumentIndexOutOfRange("select", 0); - - for (int i = num; i < args.Count; i++) - values.Add(args[i]); - } - else - { - throw ScriptRuntimeException.BadArgumentIndexOutOfRange("select", 0); - } - - return DynValue.NewTupleNested(values.ToArray()); - } - - - - - // tonumber (e [, base]) - // ---------------------------------------------------------------------------------------------------------------- - // When called with no base, tonumber tries to convert its argument to a number. If the argument is already - // a number or a string convertible to a number (see §3.4.2), then tonumber returns this number; otherwise, - // it returns nil. - // - // When called with base, then e should be a string to be interpreted as an integer numeral in that base. - // The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either - // upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. If the - // string e is not a valid numeral in the given base, the function returns nil. - [MoonSharpModuleMethod] - public static DynValue tonumber(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args.Count < 1) throw ScriptRuntimeException.BadArgumentValueExpected(0, "tonumber"); - - DynValue e = args[0]; - DynValue b = args.AsType(1, "tonumber", DataType.Number, true); - - if (b.IsNil()) - { - if (e.Type == DataType.Number) - return e; - - if (e.Type != DataType.String) - return DynValue.Nil; - - double d; - if (double.TryParse(e.String, NumberStyles.Any, CultureInfo.InvariantCulture, out d)) - { - return DynValue.NewNumber(d); - } - return DynValue.Nil; - } - else - { - //!COMPAT: tonumber supports only 2,8,10 or 16 as base - //UPDATE: added support for 3-9 base numbers - DynValue ee; - - if (args[0].Type != DataType.Number) - ee = args.AsType(0, "tonumber", DataType.String, false); - else - ee = DynValue.NewString(args[0].Number.ToString(CultureInfo.InvariantCulture)); ; - - int bb = (int)b.Number; - - uint uiv = 0; - if (bb == 2 || bb == 8 || bb == 10 || bb == 16) - { - uiv = Convert.ToUInt32(ee.String.Trim(), bb); - } - else if (bb < 10 && bb > 2) // Support for 3, 4, 5, 6, 7 and 9 based numbers - { - foreach (char digit in ee.String.Trim()) - { - int value = digit - 48; - if (value < 0 || value >= bb) - { - throw new ScriptRuntimeException("bad argument #1 to 'tonumber' (invalid character)"); - } - - uiv = (uint)(uiv * bb) + (uint)value; - } - } - else - { - throw new ScriptRuntimeException("bad argument #2 to 'tonumber' (base out of range)"); - } - - return DynValue.NewNumber(uiv); - } - } - - [MoonSharpModuleMethod] - public static DynValue print(ScriptExecutionContext executionContext, CallbackArguments args) - { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < args.Count; i++) - { - if (args[i].IsVoid()) - break; - - if (i != 0) - sb.Append('\t'); - - sb.Append(args.AsStringUsingMeta(executionContext, i, "print")); - } - - executionContext.GetScript().Options.DebugPrint(sb.ToString()); - - return DynValue.Nil; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/Bit32Module.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/Bit32Module.cs deleted file mode 100755 index bb877efc..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/Bit32Module.cs +++ /dev/null @@ -1,245 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing bit32 Lua functions - /// - [MoonSharpModule(Namespace = "bit32")] - public class Bit32Module - { - static readonly uint[] MASKS = new uint[] { - 0x1, 0x3, 0x7, 0xF, - 0x1F, 0x3F, 0x7F, 0xFF, - 0x1FF, 0x3FF, 0x7FF, 0xFFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, - 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, - 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, - 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, - 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF, }; - - static uint ToUInt32(DynValue v) - { - double d = v.Number; - d = Math.IEEERemainder(d, Math.Pow(2.0, 32.0)); - return (uint)d; - } - - static int ToInt32(DynValue v) - { - double d = v.Number; - d = Math.IEEERemainder(d, Math.Pow(2.0, 32.0)); - return (int)d; - } - - static uint NBitMask(int bits) - { - - if (bits <= 0) - return 0; - if (bits >= 32) - return MASKS[31]; - - return MASKS[bits - 1]; - } - - public static uint Bitwise(string funcName, CallbackArguments args, Func accumFunc) - { - uint accum = ToUInt32(args.AsType(0, funcName, DataType.Number, false)); - - for (int i = 1; i < args.Count; i++) - { - uint vv = ToUInt32(args.AsType(i, funcName, DataType.Number, false)); - accum = accumFunc(accum, vv); - } - - return accum; - } - - - [MoonSharpModuleMethod] - public static DynValue extract(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "extract", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_pos = args.AsType(1, "extract", DataType.Number); - DynValue v_width = args.AsType(2, "extract", DataType.Number, true); - - int pos = (int)v_pos.Number; - int width = (v_width).IsNilOrNan() ? 1 : (int)v_width.Number; - - ValidatePosWidth("extract", 2, pos, width); - - uint res = (v >> pos) & NBitMask(width); - return DynValue.NewNumber(res); - } - - - [MoonSharpModuleMethod] - public static DynValue replace(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "replace", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_u = args.AsType(1, "replace", DataType.Number); - uint u = ToUInt32(v_u); - DynValue v_pos = args.AsType(2, "replace", DataType.Number); - DynValue v_width = args.AsType(3, "replace", DataType.Number, true); - - int pos = (int)v_pos.Number; - int width = (v_width).IsNilOrNan() ? 1 : (int)v_width.Number; - - ValidatePosWidth("replace", 3, pos, width); - - uint mask = NBitMask(width) << pos; - v = v & (~mask); - u = u & (mask); - v = v | u; - - return DynValue.NewNumber(v); - } - - - private static void ValidatePosWidth(string func, int argPos, int pos, int width) - { - if (pos > 31 || (pos + width) > 31) - throw new ScriptRuntimeException("trying to access non-existent bits"); - - if (pos < 0) - throw new ScriptRuntimeException("bad argument #{1} to '{0}' (field cannot be negative)", func, argPos); - - if (width <= 0) - throw new ScriptRuntimeException("bad argument #{1} to '{0}' (width must be positive)", func, argPos+1); - } - - - [MoonSharpModuleMethod] - public static DynValue arshift(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "arshift", DataType.Number); - int v = ToInt32(v_v); - - DynValue v_a = args.AsType(1, "arshift", DataType.Number); - - int a = (int)v_a.Number; - - if (a < 0) - v = v << -a; - else - v = v >> a; - - return DynValue.NewNumber(v); - } - - - [MoonSharpModuleMethod] - public static DynValue rshift(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "rshift", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_a = args.AsType(1, "rshift", DataType.Number); - - int a = (int)v_a.Number; - - if (a < 0) - v = v << -a; - else - v = v >> a; - - return DynValue.NewNumber(v); - } - - - [MoonSharpModuleMethod] - public static DynValue lshift(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "lshift", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_a = args.AsType(1, "lshift", DataType.Number); - - int a = (int)v_a.Number; - - if (a < 0) - v = v >> -a; - else - v = v << a; - - return DynValue.NewNumber(v); - } - - [MoonSharpModuleMethod] - public static DynValue band(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewNumber(Bitwise("band", args, (x, y) => x & y)); - } - - [MoonSharpModuleMethod] - public static DynValue btest(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewBoolean(0 != Bitwise("btest", args, (x, y) => x & y)); - } - - [MoonSharpModuleMethod] - public static DynValue bor(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewNumber(Bitwise("bor", args, (x, y) => x | y)); - } - - [MoonSharpModuleMethod] - public static DynValue bnot(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "bnot", DataType.Number); - uint v = ToUInt32(v_v); - return DynValue.NewNumber(~v); - } - - [MoonSharpModuleMethod] - public static DynValue bxor(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewNumber(Bitwise("bxor", args, (x, y) => x ^ y)); - } - - [MoonSharpModuleMethod] - public static DynValue lrotate(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "lrotate", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_a = args.AsType(1, "lrotate", DataType.Number); - - int a = ((int)v_a.Number) % 32; - - if (a < 0) - v = (v >> (-a)) | (v << (32 + a)); - else - v = (v << a) | (v >> (32 - a)); - - return DynValue.NewNumber(v); - } - - [MoonSharpModuleMethod] - public static DynValue rrotate(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_v = args.AsType(0, "rrotate", DataType.Number); - uint v = ToUInt32(v_v); - - DynValue v_a = args.AsType(1, "rrotate", DataType.Number); - - int a = ((int)v_a.Number) % 32; - - if (a < 0) - v = (v << (-a)) | (v >> (32 + a)); - else - v = (v >> a) | (v << (32 - a)); - - return DynValue.NewNumber(v); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/CoroutineModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/CoroutineModule.cs deleted file mode 100644 index d405a88e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/CoroutineModule.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing coroutine Lua functions - /// - [MoonSharpModule(Namespace = "coroutine")] - public class CoroutineModule - { - [MoonSharpModuleMethod] - public static DynValue create(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args[0].Type != DataType.Function && args[0].Type != DataType.ClrFunction) - args.AsType(0, "create", DataType.Function); // this throws - - return executionContext.GetScript().CreateCoroutine(args[0]); - } - - [MoonSharpModuleMethod] - public static DynValue wrap(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args[0].Type != DataType.Function && args[0].Type != DataType.ClrFunction) - args.AsType(0, "wrap", DataType.Function); // this throws - - DynValue v = create(executionContext, args); - DynValue c = DynValue.NewCallback(__wrap_wrapper); - c.Callback.AdditionalData = v; - return c; - } - - public static DynValue __wrap_wrapper(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue handle = (DynValue)executionContext.AdditionalData; - return handle.Coroutine.Resume(args.GetArray()); - } - - [MoonSharpModuleMethod] - public static DynValue resume(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue handle = args.AsType(0, "resume", DataType.Thread); - - try - { - DynValue ret = handle.Coroutine.Resume(args.GetArray(1)); - - List retval = new List(); - retval.Add(DynValue.True); - - if (ret.Type == DataType.Tuple) - { - for (int i = 0; i < ret.Tuple.Length; i++) - { - var v = ret.Tuple[i]; - - if ((i == ret.Tuple.Length - 1) && (v.Type == DataType.Tuple)) - { - retval.AddRange(v.Tuple); - } - else - { - retval.Add(v); - } - } - } - else - { - retval.Add(ret); - } - - return DynValue.NewTuple(retval.ToArray()); - } - catch (ScriptRuntimeException ex) - { - return DynValue.NewTuple( - DynValue.False, - DynValue.NewString(ex.Message)); - } - } - - [MoonSharpModuleMethod] - public static DynValue yield(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewYieldReq(args.GetArray()); - } - - - - [MoonSharpModuleMethod] - public static DynValue running(ScriptExecutionContext executionContext, CallbackArguments args) - { - Coroutine C = executionContext.GetCallingCoroutine(); - return DynValue.NewTuple(DynValue.NewCoroutine(C), DynValue.NewBoolean(C.State == CoroutineState.Main)); - } - - [MoonSharpModuleMethod] - public static DynValue status(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue handle = args.AsType(0, "status", DataType.Thread); - Coroutine running = executionContext.GetCallingCoroutine(); - CoroutineState cs = handle.Coroutine.State; - - switch (cs) - { - case CoroutineState.Main: - case CoroutineState.Running: - return (handle.Coroutine == running) ? - DynValue.NewString("running") : - DynValue.NewString("normal"); - case CoroutineState.NotStarted: - case CoroutineState.Suspended: - case CoroutineState.ForceSuspended: - return DynValue.NewString("suspended"); - case CoroutineState.Dead: - return DynValue.NewString("dead"); - default: - throw new InternalErrorException("Unexpected coroutine state {0}", cs); - } - - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DebugModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DebugModule.cs deleted file mode 100644 index c61d30ba..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DebugModule.cs +++ /dev/null @@ -1,343 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.Text; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.REPL; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing debug Lua functions. Support for the debug module is partial. - /// - [MoonSharpModule(Namespace = "debug")] - public class DebugModule - { - [MoonSharpModuleMethod] - public static DynValue debug(ScriptExecutionContext executionContext, CallbackArguments args) - { - Script script = executionContext.GetScript(); - - if (script.Options.DebugInput == null) - throw new ScriptRuntimeException("debug.debug not supported on this platform/configuration"); - - ReplInterpreter interpreter = new ReplInterpreter(script) - { - HandleDynamicExprs = false, - HandleClassicExprsSyntax = true - }; - - while (true) - { - string s = script.Options.DebugInput(interpreter.ClassicPrompt + " "); - - try - { - DynValue result = interpreter.Evaluate(s); - - if (result != null && result.Type != DataType.Void) - script.Options.DebugPrint(string.Format("{0}", result)); - } - catch (InterpreterException ex) - { - script.Options.DebugPrint(string.Format("{0}", ex.DecoratedMessage ?? ex.Message)); - } - catch (Exception ex) - { - script.Options.DebugPrint(string.Format("{0}", ex.Message)); - } - } - } - - [MoonSharpModuleMethod] - public static DynValue getuservalue(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args[0]; - - if (v.Type != DataType.UserData) - return DynValue.Nil; - - return v.UserData.UserValue ?? DynValue.Nil; - } - - [MoonSharpModuleMethod] - public static DynValue setuservalue(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args.AsType(0, "setuservalue", DataType.UserData, false); - DynValue t = args.AsType(0, "setuservalue", DataType.Table, true); - - return v.UserData.UserValue = t; - } - - [MoonSharpModuleMethod] - public static DynValue getregistry(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewTable(executionContext.GetScript().Registry); - } - - [MoonSharpModuleMethod] - public static DynValue getmetatable(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args[0]; - Script S = executionContext.GetScript(); - - if (v.Type.CanHaveTypeMetatables()) - return DynValue.NewTable(S.GetTypeMetatable(v.Type)); - else if (v.Type == DataType.Table) - return DynValue.NewTable(v.Table.MetaTable); - else - return DynValue.Nil; - } - - [MoonSharpModuleMethod] - public static DynValue setmetatable(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args[0]; - DynValue t = args.AsType(1, "setmetatable", DataType.Table, true); - Table m = (t.IsNil()) ? null : t.Table; - Script S = executionContext.GetScript(); - - if (v.Type.CanHaveTypeMetatables()) - S.SetTypeMetatable(v.Type, m); - else if (v.Type == DataType.Table) - v.Table.MetaTable = m; - else - throw new ScriptRuntimeException("cannot debug.setmetatable on type {0}", v.Type.ToErrorTypeString()); - - return v; - } - - [MoonSharpModuleMethod] - public static DynValue getupvalue(ScriptExecutionContext executionContext, CallbackArguments args) - { - var index = (int)args.AsType(1, "getupvalue", DataType.Number, false).Number - 1; - - if (args[0].Type == DataType.ClrFunction) - return DynValue.Nil; - - var fn = args.AsType(0, "getupvalue", DataType.Function, false).Function; - - var closure = fn.ClosureContext; - - if (index < 0 || index >= closure.Count) - return DynValue.Nil; - - return DynValue.NewTuple( - DynValue.NewString(closure.Symbols[index]), - closure[index]); - } - - - [MoonSharpModuleMethod] - public static DynValue upvalueid(ScriptExecutionContext executionContext, CallbackArguments args) - { - var index = (int)args.AsType(1, "getupvalue", DataType.Number, false).Number - 1; - - if (args[0].Type == DataType.ClrFunction) - return DynValue.Nil; - - var fn = args.AsType(0, "getupvalue", DataType.Function, false).Function; - - var closure = fn.ClosureContext; - - if (index < 0 || index >= closure.Count) - return DynValue.Nil; - - return DynValue.NewNumber(closure[index].ReferenceID); - } - - - [MoonSharpModuleMethod] - public static DynValue setupvalue(ScriptExecutionContext executionContext, CallbackArguments args) - { - var index = (int)args.AsType(1, "setupvalue", DataType.Number, false).Number - 1; - - if (args[0].Type == DataType.ClrFunction) - return DynValue.Nil; - - var fn = args.AsType(0, "setupvalue", DataType.Function, false).Function; - - var closure = fn.ClosureContext; - - if (index < 0 || index >= closure.Count) - return DynValue.Nil; - - closure[index].Assign(args[2]); - - return DynValue.NewString(closure.Symbols[index]); - } - - - [MoonSharpModuleMethod] - public static DynValue upvaluejoin(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue f1 = args.AsType(0, "upvaluejoin", DataType.Function, false); - DynValue f2 = args.AsType(2, "upvaluejoin", DataType.Function, false); - int n1 = args.AsInt(1, "upvaluejoin") - 1; - int n2 = args.AsInt(3, "upvaluejoin") - 1; - - Closure c1 = f1.Function; - Closure c2 = f2.Function; - - if (n1 < 0 || n1 >= c1.ClosureContext.Count) - throw ScriptRuntimeException.BadArgument(1, "upvaluejoin", "invalid upvalue index"); - - if (n2 < 0 || n2 >= c2.ClosureContext.Count) - throw ScriptRuntimeException.BadArgument(3, "upvaluejoin", "invalid upvalue index"); - - c2.ClosureContext[n2] = c1.ClosureContext[n1]; - - return DynValue.Void; - } - - - [MoonSharpModuleMethod] - public static DynValue traceback(ScriptExecutionContext executionContext, CallbackArguments args) - { - StringBuilder sb = new StringBuilder(); - - DynValue vmessage = args[0]; - DynValue vlevel = args[1]; - - double defaultSkip = 1.0; - - Coroutine cor = executionContext.GetCallingCoroutine(); - - if (vmessage.Type == DataType.Thread) - { - cor = vmessage.Coroutine; - vmessage = args[1]; - vlevel = args[2]; - defaultSkip = 0.0; - } - - if (vmessage.IsNotNil() && vmessage.Type != DataType.String && vmessage.Type != DataType.Number) - { - return vmessage; - } - - string message = vmessage.CastToString(); - - int skip = (int)((vlevel.CastToNumber()) ?? defaultSkip); - - WatchItem[] stacktrace = cor.GetStackTrace(Math.Max(0, skip)); - - if (message != null) - sb.AppendLine(message); - - sb.AppendLine("stack traceback:"); - - foreach (WatchItem wi in stacktrace) - { - string name; - - if (wi.Name == null) - if (wi.RetAddress < 0) - name = "main chunk"; - else - name = "?"; - else - name = "function '" + wi.Name + "'"; - - string loc = wi.Location != null ? wi.Location.FormatLocation(executionContext.GetScript()) : "[clr]"; - sb.AppendFormat("\t{0}: in {1}\n", loc, name); - } - - return DynValue.NewString(sb); - } - - //[MoonSharpModuleMethod] - //public static DynValue getlocal(ScriptExecutionContext executionContext, CallbackArguments args) - //{ - // Coroutine c; - // int funcIdx; - // Closure f; - // int nextArg = ParseComplexArgs("getlocal", executionContext, args, out c, out f, out funcIdx); - - // int localIdx = args.AsInt(nextArg, "getlocal"); - - // if (f != null) - // { - - // } - // else - // { - - // } - - - - //} - - //private static int ParseComplexArgs(string funcname, ScriptExecutionContext executionContext, CallbackArguments args, out Coroutine c, out Closure f, out int funcIdx) - //{ - // DynValue arg1 = args[0]; - // int argbase = 0; - // c = null; - - // if (arg1.Type == DataType.Thread) - // { - // c = arg1.Coroutine; - // argbase = 1; - // } - - // if (args[argbase].Type == DataType.Number) - // { - // funcIdx = (int)args[argbase].Number; - // f = null; - // } - // else - // { - // funcIdx = -1; - // f = args.AsType(argbase, funcname, DataType.Function, false).Function; - // } - - // return argbase + 1; - //} - - - //[MoonSharpMethod] - //public static DynValue getinfo(ScriptExecutionContext executionContext, CallbackArguments args) - //{ - // Coroutine cor = executionContext.GetCallingCoroutine(); - // int vfArgIdx = 0; - - // if (args[0].Type == DataType.Thread) - // cor = args[0].Coroutine; - - // DynValue vf = args[vfArgIdx+0]; - // DynValue vwhat = args[vfArgIdx+1]; - - // args.AsType(vfArgIdx + 1, "getinfo", DataType.String, true); - - // string what = vwhat.CastToString() ?? "nfSlu"; - - // DynValue vt = DynValue.NewTable(executionContext.GetScript()); - // Table t = vt.Table; - - // if (vf.Type == DataType.Function) - // { - // Closure f = vf.Function; - // executionContext.GetInfoForFunction - // } - // else if (vf.Type == DataType.ClrFunction) - // { - - // } - // else if (vf.Type == DataType.Number || vf.Type == DataType.String) - // { - - // } - // else - // { - // args.AsType(vfArgIdx + 0, "getinfo", DataType.Number, true); - // } - - // return vt; - - - //} - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DynamicModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DynamicModule.cs deleted file mode 100644 index 1da38eee..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/DynamicModule.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing dynamic expression evaluations at runtime (a MoonSharp addition). - /// - [MoonSharpModule(Namespace = "dynamic")] - public class DynamicModule - { - private class DynamicExprWrapper - { - public DynamicExpression Expr; - } - - public static void MoonSharpInit(Table globalTable, Table stringTable) - { - UserData.RegisterType(InteropAccessMode.HideMembers); - } - - [MoonSharpModuleMethod] - public static DynValue eval(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - if (args[0].Type == DataType.UserData) - { - UserData ud = args[0].UserData; - if (ud.Object is DynamicExprWrapper) - { - return ((DynamicExprWrapper)ud.Object).Expr.Evaluate(executionContext); - } - else - { - throw ScriptRuntimeException.BadArgument(0, "dynamic.eval", "A userdata was passed, but was not a previously prepared expression."); - } - } - else - { - DynValue vs = args.AsType(0, "dynamic.eval", DataType.String, false); - DynamicExpression expr = executionContext.GetScript().CreateDynamicExpression(vs.String); - return expr.Evaluate(executionContext); - } - } - catch (SyntaxErrorException ex) - { - throw new ScriptRuntimeException(ex); - } - } - - [MoonSharpModuleMethod] - public static DynValue prepare(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - DynValue vs = args.AsType(0, "dynamic.prepare", DataType.String, false); - DynamicExpression expr = executionContext.GetScript().CreateDynamicExpression(vs.String); - return UserData.Create(new DynamicExprWrapper() { Expr = expr }); - } - catch (SyntaxErrorException ex) - { - throw new ScriptRuntimeException(ex); - } - } - - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/ErrorHandlingModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/ErrorHandlingModule.cs deleted file mode 100644 index ffa21d03..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/ErrorHandlingModule.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing error handling Lua functions (pcall and xpcall) - /// - [MoonSharpModule] - public class ErrorHandlingModule - { - [MoonSharpModuleMethod] - public static DynValue pcall(ScriptExecutionContext executionContext, CallbackArguments args) - { - return SetErrorHandlerStrategy("pcall", executionContext, args, null); - } - - - private static DynValue SetErrorHandlerStrategy(string funcName, - ScriptExecutionContext executionContext, - CallbackArguments args, - DynValue handlerBeforeUnwind) - { - DynValue v = args[0]; - DynValue[] a = new DynValue[args.Count - 1]; - - for (int i = 1; i < args.Count; i++) - a[i - 1] = args[i]; - - if (args[0].Type == DataType.ClrFunction) - { - try - { - DynValue ret = args[0].Callback.Invoke(executionContext, a); - if (ret.Type == DataType.TailCallRequest) - { - if (ret.TailCallData.Continuation != null || ret.TailCallData.ErrorHandler != null) - throw new ScriptRuntimeException("the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.", funcName); - - return DynValue.NewTailCallReq(new TailCallData() - { - Args = ret.TailCallData.Args, - Function = ret.TailCallData.Function, - Continuation = new CallbackFunction(pcall_continuation, funcName), - ErrorHandler = new CallbackFunction(pcall_onerror, funcName), - ErrorHandlerBeforeUnwind = handlerBeforeUnwind - }); - } - else if (ret.Type == DataType.YieldRequest) - { - throw new ScriptRuntimeException("the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.", funcName); - } - else - { - return DynValue.NewTupleNested(DynValue.True, ret); - } - } - catch (ScriptRuntimeException ex) - { - executionContext.PerformMessageDecorationBeforeUnwind(handlerBeforeUnwind, ex); - return DynValue.NewTupleNested(DynValue.False, DynValue.NewString(ex.DecoratedMessage)); - } - } - else if (args[0].Type != DataType.Function) - { - return DynValue.NewTupleNested(DynValue.False, DynValue.NewString("attempt to " + funcName + " a non-function")); - } - else - { - return DynValue.NewTailCallReq(new TailCallData() - { - Args = a, - Function = v, - Continuation = new CallbackFunction(pcall_continuation, funcName), - ErrorHandler = new CallbackFunction(pcall_onerror, funcName), - ErrorHandlerBeforeUnwind = handlerBeforeUnwind - }); - } - } - - private static DynValue MakeReturnTuple(bool retstatus, CallbackArguments args) - { - DynValue[] rets = new DynValue[args.Count + 1]; - - for (int i = 0; i < args.Count; i++) - rets[i + 1] = args[i]; - - rets[0] = DynValue.NewBoolean(retstatus); - - return DynValue.NewTuple(rets); - } - - - public static DynValue pcall_continuation(ScriptExecutionContext executionContext, CallbackArguments args) - { - return MakeReturnTuple(true, args); - } - - public static DynValue pcall_onerror(ScriptExecutionContext executionContext, CallbackArguments args) - { - return MakeReturnTuple(false, args); - } - - - [MoonSharpModuleMethod] - public static DynValue xpcall(ScriptExecutionContext executionContext, CallbackArguments args) - { - List a = new List(); - - for (int i = 0; i < args.Count; i++) - { - if (i != 1) - a.Add(args[i]); - } - - DynValue handler = null; - if (args[1].Type == DataType.Function || args[1].Type == DataType.ClrFunction) - { - handler = args[1]; - } - else if (args[1].Type != DataType.Nil) - { - args.AsType(1, "xpcall", DataType.Function, false); - } - - return SetErrorHandlerStrategy("xpcall", executionContext, new CallbackArguments(a, false), handler); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/BinaryEncoding.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/BinaryEncoding.cs deleted file mode 100644 index 9f4e84d2..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/BinaryEncoding.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Text; - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - class BinaryEncoding : Encoding - { - public BinaryEncoding() - : base() - { - - } - - public override int GetByteCount(char[] chars, int index, int count) - { - return count; - } - - public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) - { - for (int i = 0; i < charCount; i++) - { - bytes[byteIndex + i] = (byte)((int)chars[charIndex + i]); - } - - return charCount; - } - - public override int GetCharCount(byte[] bytes, int index, int count) - { - return count; - } - - public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) - { - for (int i = 0; i < byteCount; i++) - { - chars[charIndex + i] = (char)((int)bytes[byteIndex + i]); - } - - return byteCount; - } - - public override int GetMaxByteCount(int charCount) - { - return charCount; - } - - public override int GetMaxCharCount(int byteCount) - { - return byteCount; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserData.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserData.cs deleted file mode 100644 index 0f466389..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserData.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - /// - /// Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - /// - internal class FileUserData : StreamFileUserDataBase - { - public FileUserData(Script script, string filename, Encoding encoding, string mode) - { - Stream stream = Script.GlobalOptions.Platform.IO_OpenFile(script, filename, encoding, mode); - - StreamReader reader = (stream.CanRead) ? new StreamReader(stream, encoding) : null; - StreamWriter writer = (stream.CanWrite) ? new StreamWriter(stream, encoding) : null; - - base.Initialize(stream, reader, writer); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserDataBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserDataBase.cs deleted file mode 100755 index 3b751476..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/FileUserDataBase.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - /// - /// Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - /// - internal abstract class FileUserDataBase : RefIdObject - { - public DynValue lines(ScriptExecutionContext executionContext, CallbackArguments args) - { - List readLines = new List(); - - DynValue readValue = null; - - do - { - readValue = read(executionContext, args); - readLines.Add(readValue); - - } while (readValue.IsNotNil()); - - return DynValue.FromObject(executionContext.GetScript(), readLines.Select(s => s)); - } - - public DynValue read(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args.Count == 0) - { - string str = ReadLine(); - - if (str == null) - return DynValue.Nil; - - str = str.TrimEnd('\n', '\r'); - return DynValue.NewString(str); - } - else - { - List rets = new List(); - - for (int i = 0; i < args.Count; i++) - { - DynValue v; - - if (args[i].Type == DataType.Number) - { - if (Eof()) - return DynValue.Nil; - - int howmany = (int)args[i].Number; - - string str = ReadBuffer(howmany); - v = DynValue.NewString(str); - } - else - { - string opt = args.AsType(i, "read", DataType.String, false).String; - - if (Eof()) - { - v = opt.StartsWith("*a") ? DynValue.NewString("") : DynValue.Nil; - } - else if (opt.StartsWith("*n")) - { - double? d = ReadNumber(); - - if (d.HasValue) - v = DynValue.NewNumber(d.Value); - else - v = DynValue.Nil; - } - else if (opt.StartsWith("*a")) - { - string str = ReadToEnd(); - v = DynValue.NewString(str); - } - else if (opt.StartsWith("*l")) - { - string str = ReadLine(); - str = str.TrimEnd('\n', '\r'); - v = DynValue.NewString(str); - } - else if (opt.StartsWith("*L")) - { - string str = ReadLine(); - - str = str.TrimEnd('\n', '\r'); - str += "\n"; - - v = DynValue.NewString(str); - } - else - { - throw ScriptRuntimeException.BadArgument(i, "read", "invalid option"); - } - } - - rets.Add(v); - } - - return DynValue.NewTuple(rets.ToArray()); - } - } - - - public DynValue write(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - for (int i = 0; i < args.Count; i++) - { - //string str = args.AsStringUsingMeta(executionContext, i, "file:write"); - string str = args.AsType(i, "write", DataType.String, false).String; - Write(str); - } - - return UserData.Create(this); - } - catch (ScriptRuntimeException) - { - throw; - } - catch (Exception ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.Message)); - } - } - - public DynValue close(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - string msg = Close(); - if (msg == null) - return DynValue.True; - else - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(msg)); - } - catch (ScriptRuntimeException) - { - throw; - } - catch (Exception ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.Message)); - } - } - - - double? ReadNumber() - { - string chr = ""; - - while (!Eof()) - { - char c = Peek(); - if (char.IsWhiteSpace(c)) - { - ReadBuffer(1); - } - else if (IsNumericChar(c, chr)) - { - ReadBuffer(1); - chr += c; - } - else break; - } - - double d; - - if (double.TryParse(chr, out d)) - { - return d; - } - else - { - return null; - } - } - - private bool IsNumericChar(char c, string numAsFar) - { - if (char.IsDigit(c)) - return true; - - if (c == '-') - return numAsFar.Length == 0; - - if (c == '.') - return !Framework.Do.StringContainsChar(numAsFar, '.'); - - if (c == 'E' || c == 'e') - return !(Framework.Do.StringContainsChar(numAsFar, 'E') || Framework.Do.StringContainsChar(numAsFar, 'e')); - - return false; - } - - protected abstract bool Eof(); - protected abstract string ReadLine(); - protected abstract string ReadBuffer(int p); - protected abstract string ReadToEnd(); - protected abstract char Peek(); - protected abstract void Write(string value); - - - protected internal abstract bool isopen(); - protected abstract string Close(); - - public abstract bool flush(); - public abstract long seek(string whence, long offset); - public abstract bool setvbuf(string mode); - - public override string ToString() - { - if (isopen()) - return string.Format("file ({0:X8})", base.ReferenceID); - else - return "file (closed)"; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StandardIOFileUserDataBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StandardIOFileUserDataBase.cs deleted file mode 100644 index de00ec50..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StandardIOFileUserDataBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.IO; - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - /// - /// Abstract class implementing an unclosable file Lua userdata. Methods are meant to be called by Lua code. - /// - internal class StandardIOFileUserDataBase : StreamFileUserDataBase - { - protected override string Close() - { - return ("cannot close standard file"); - } - - public static StandardIOFileUserDataBase CreateInputStream(Stream stream) - { - var f = new StandardIOFileUserDataBase(); - f.Initialize(stream, new StreamReader(stream), null); - return f; - } - - public static StandardIOFileUserDataBase CreateOutputStream(Stream stream) - { - var f = new StandardIOFileUserDataBase(); - f.Initialize(stream, null, new StreamWriter(stream)); - return f; - } - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StreamFileUserDataBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StreamFileUserDataBase.cs deleted file mode 100644 index 0690a4de..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IO/StreamFileUserDataBase.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System.IO; - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - /// - /// Abstract class implementing a file Lua userdata. Methods are meant to be called by Lua code. - /// - internal abstract class StreamFileUserDataBase : FileUserDataBase - { - protected Stream m_Stream; - protected StreamReader m_Reader; - protected StreamWriter m_Writer; - protected bool m_Closed = false; - - - protected void Initialize(Stream stream, StreamReader reader, StreamWriter writer) - { - m_Stream = stream; - m_Reader = reader; - m_Writer = writer; - } - - - private void CheckFileIsNotClosed() - { - if (m_Closed) - throw new ScriptRuntimeException("attempt to use a closed file"); - } - - - protected override bool Eof() - { - CheckFileIsNotClosed(); - - if (m_Reader != null) - return m_Reader.EndOfStream; - else - return false; - } - - protected override string ReadLine() - { - CheckFileIsNotClosed(); - return m_Reader.ReadLine(); - } - - protected override string ReadToEnd() - { - CheckFileIsNotClosed(); - return m_Reader.ReadToEnd(); - } - - protected override string ReadBuffer(int p) - { - CheckFileIsNotClosed(); - char[] buffer = new char[p]; - int length = m_Reader.ReadBlock(buffer, 0, p); - return new string(buffer, 0, length); - } - - protected override char Peek() - { - CheckFileIsNotClosed(); - return (char)m_Reader.Peek(); - } - - protected override void Write(string value) - { - CheckFileIsNotClosed(); - m_Writer.Write(value); - } - - protected override string Close() - { - CheckFileIsNotClosed(); - - if (m_Writer != null) - m_Writer.Dispose(); - - if (m_Reader != null) - m_Reader.Dispose(); - - m_Stream.Dispose(); - - m_Closed = true; - - return null; - } - - public override bool flush() - { - CheckFileIsNotClosed(); - - if (m_Writer != null) - m_Writer.Flush(); - - return true; - } - - public override long seek(string whence, long offset) - { - CheckFileIsNotClosed(); - if (whence != null) - { - if (whence == "set") - { - m_Stream.Seek(offset, SeekOrigin.Begin); - } - else if (whence == "cur") - { - m_Stream.Seek(offset, SeekOrigin.Current); - } - else if (whence == "end") - { - m_Stream.Seek(offset, SeekOrigin.End); - } - else - { - throw ScriptRuntimeException.BadArgument(0, "seek", "invalid option '" + whence + "'"); - } - } - - return m_Stream.Position; - } - - public override bool setvbuf(string mode) - { - CheckFileIsNotClosed(); - if (m_Writer != null) - m_Writer.AutoFlush = (mode == "no" || mode == "line"); - return true; - } - - protected internal override bool isopen() - { - return !m_Closed; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IoModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IoModule.cs deleted file mode 100755 index f7b1cd2d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/IoModule.cs +++ /dev/null @@ -1,309 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.CoreLib.IO; -using MoonSharp.Interpreter.Platforms; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing io Lua functions. Proper support requires a compatible IPlatformAccessor - /// - [MoonSharpModule(Namespace = "io")] - public class IoModule - { - public static void MoonSharpInit(Table globalTable, Table ioTable) - { - UserData.RegisterType(InteropAccessMode.Default, "file"); - - Table meta = new Table(ioTable.OwnerScript); - DynValue __index = DynValue.NewCallback(new CallbackFunction(__index_callback, "__index_callback")); - meta.Set("__index", __index); - ioTable.MetaTable = meta; - - SetStandardFile(globalTable.OwnerScript, StandardFileType.StdIn, globalTable.OwnerScript.Options.Stdin); - SetStandardFile(globalTable.OwnerScript, StandardFileType.StdOut, globalTable.OwnerScript.Options.Stdout); - SetStandardFile(globalTable.OwnerScript, StandardFileType.StdErr, globalTable.OwnerScript.Options.Stderr); - } - - private static DynValue __index_callback(ScriptExecutionContext executionContext, CallbackArguments args) - { - string name = args[1].CastToString(); - - if (name == "stdin") - return GetStandardFile(executionContext.GetScript(), StandardFileType.StdIn); - else if (name == "stdout") - return GetStandardFile(executionContext.GetScript(), StandardFileType.StdOut); - else if (name == "stderr") - return GetStandardFile(executionContext.GetScript(), StandardFileType.StdErr); - else - return DynValue.Nil; - } - - private static DynValue GetStandardFile(Script S, StandardFileType file) - { - Table R = S.Registry; - - DynValue ff = R.Get("853BEAAF298648839E2C99D005E1DF94_STD_" + file.ToString()); - return ff; - } - - private static void SetStandardFile(Script S, StandardFileType file, Stream optionsStream) - { - Table R = S.Registry; - - optionsStream = optionsStream ?? Script.GlobalOptions.Platform.IO_GetStandardStream(file); - - FileUserDataBase udb = null; - - if (file == StandardFileType.StdIn) - udb = StandardIOFileUserDataBase.CreateInputStream(optionsStream); - else - udb = StandardIOFileUserDataBase.CreateOutputStream(optionsStream); - - R.Set("853BEAAF298648839E2C99D005E1DF94_STD_" + file.ToString(), UserData.Create(udb)); - } - - - static FileUserDataBase GetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file) - { - Table R = executionContext.GetScript().Registry; - - DynValue ff = R.Get("853BEAAF298648839E2C99D005E1DF94_" + file.ToString()); - - if (ff.IsNil()) - { - ff = GetStandardFile(executionContext.GetScript(), file); - } - - return ff.CheckUserDataType("getdefaultfile(" + file.ToString() + ")"); - } - - - static void SetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file, FileUserDataBase fileHandle) - { - SetDefaultFile(executionContext.GetScript(), file, fileHandle); - } - - internal static void SetDefaultFile(Script script, StandardFileType file, FileUserDataBase fileHandle) - { - Table R = script.Registry; - R.Set("853BEAAF298648839E2C99D005E1DF94_" + file.ToString(), UserData.Create(fileHandle)); - } - - public static void SetDefaultFile(Script script, StandardFileType file, Stream stream) - { - if (file == StandardFileType.StdIn) - SetDefaultFile(script, file, StandardIOFileUserDataBase.CreateInputStream(stream)); - else - SetDefaultFile(script, file, StandardIOFileUserDataBase.CreateOutputStream(stream)); - } - - - [MoonSharpModuleMethod] - public static DynValue close(ScriptExecutionContext executionContext, CallbackArguments args) - { - FileUserDataBase outp = args.AsUserData(0, "close", true) ?? GetDefaultFile(executionContext, StandardFileType.StdOut); - return outp.close(executionContext, args); - } - - [MoonSharpModuleMethod] - public static DynValue flush(ScriptExecutionContext executionContext, CallbackArguments args) - { - FileUserDataBase outp = args.AsUserData(0, "close", true) ?? GetDefaultFile(executionContext, StandardFileType.StdOut); - outp.flush(); - return DynValue.True; - } - - - [MoonSharpModuleMethod] - public static DynValue input(ScriptExecutionContext executionContext, CallbackArguments args) - { - return HandleDefaultStreamSetter(executionContext, args, StandardFileType.StdIn); - } - - [MoonSharpModuleMethod] - public static DynValue output(ScriptExecutionContext executionContext, CallbackArguments args) - { - return HandleDefaultStreamSetter(executionContext, args, StandardFileType.StdOut); - } - - private static DynValue HandleDefaultStreamSetter(ScriptExecutionContext executionContext, CallbackArguments args, StandardFileType defaultFiles) - { - if (args.Count == 0 || args[0].IsNil()) - { - var file = GetDefaultFile(executionContext, defaultFiles); - return UserData.Create(file); - } - - FileUserDataBase inp = null; - - if (args[0].Type == DataType.String || args[0].Type == DataType.Number) - { - string fileName = args[0].CastToString(); - inp = Open(executionContext, fileName, GetUTF8Encoding(), defaultFiles == StandardFileType.StdIn ? "r" : "w"); - } - else - { - inp = args.AsUserData(0, defaultFiles == StandardFileType.StdIn ? "input" : "output", false); - } - - SetDefaultFile(executionContext, defaultFiles, inp); - - return UserData.Create(inp); - } - - private static Encoding GetUTF8Encoding() - { - return new System.Text.UTF8Encoding(false); - } - - [MoonSharpModuleMethod] - public static DynValue lines(ScriptExecutionContext executionContext, CallbackArguments args) - { - string filename = args.AsType(0, "lines", DataType.String, false).String; - - try - { - List readLines = new List(); - - using (var stream = Script.GlobalOptions.Platform.IO_OpenFile(executionContext.GetScript(), filename, null, "r")) - { - using (var reader = new System.IO.StreamReader(stream)) - { - while (!reader.EndOfStream) - { - string line = reader.ReadLine(); - readLines.Add(DynValue.NewString(line)); - } - } - } - - readLines.Add(DynValue.Nil); - - return DynValue.FromObject(executionContext.GetScript(), readLines.Select(s => s)); - } - catch (Exception ex) - { - throw new ScriptRuntimeException(IoExceptionToLuaMessage(ex, filename)); - } - } - - [MoonSharpModuleMethod] - public static DynValue open(ScriptExecutionContext executionContext, CallbackArguments args) - { - string filename = args.AsType(0, "open", DataType.String, false).String; - DynValue vmode = args.AsType(1, "open", DataType.String, true); - DynValue vencoding = args.AsType(2, "open", DataType.String, true); - - string mode = vmode.IsNil() ? "r" : vmode.String; - - string invalidChars = mode.Replace("+", "") - .Replace("r", "") - .Replace("a", "") - .Replace("w", "") - .Replace("b", "") - .Replace("t", ""); - - if (invalidChars.Length > 0) - throw ScriptRuntimeException.BadArgument(1, "open", "invalid mode"); - - - try - { - string encoding = vencoding.IsNil() ? null : vencoding.String; - - // list of codes: http://msdn.microsoft.com/en-us/library/vstudio/system.text.encoding%28v=vs.90%29.aspx. - // In addition, "binary" is available. - Encoding e = null; - bool isBinary = Framework.Do.StringContainsChar(mode, 'b'); - - if (encoding == "binary") - { - isBinary = true; - e = new BinaryEncoding(); - } - else if (encoding == null) - { - if (!isBinary) e = GetUTF8Encoding(); - else e = new BinaryEncoding(); - } - else - { - if (isBinary) - throw new ScriptRuntimeException("Can't specify encodings other than nil or 'binary' for binary streams."); - - e = Encoding.GetEncoding(encoding); - } - - return UserData.Create(Open(executionContext, filename, e, mode)); - } - catch (Exception ex) - { - return DynValue.NewTuple(DynValue.Nil, - DynValue.NewString(IoExceptionToLuaMessage(ex, filename))); - } - - } - - public static string IoExceptionToLuaMessage(Exception ex, string filename) - { - if (ex is System.IO.FileNotFoundException) - return string.Format("{0}: No such file or directory", filename); - else - return ex.Message; - } - - [MoonSharpModuleMethod] - public static DynValue type(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args[0].Type != DataType.UserData) - return DynValue.Nil; - - FileUserDataBase file = args[0].UserData.Object as FileUserDataBase; - - if (file == null) - return DynValue.Nil; - else if (file.isopen()) - return DynValue.NewString("file"); - else - return DynValue.NewString("closed file"); - } - - [MoonSharpModuleMethod] - public static DynValue read(ScriptExecutionContext executionContext, CallbackArguments args) - { - FileUserDataBase file = GetDefaultFile(executionContext, StandardFileType.StdIn); - return file.read(executionContext, args); - } - - [MoonSharpModuleMethod] - public static DynValue write(ScriptExecutionContext executionContext, CallbackArguments args) - { - FileUserDataBase file = GetDefaultFile(executionContext, StandardFileType.StdOut); - return file.write(executionContext, args); - } - - [MoonSharpModuleMethod] - public static DynValue tmpfile(ScriptExecutionContext executionContext, CallbackArguments args) - { - string tmpfilename = Script.GlobalOptions.Platform.IO_OS_GetTempFilename(); - FileUserDataBase file = Open(executionContext, tmpfilename, GetUTF8Encoding(), "w"); - return UserData.Create(file); - } - - private static FileUserDataBase Open(ScriptExecutionContext executionContext, string filename, Encoding encoding, string mode) - { - return new FileUserData(executionContext.GetScript(), filename, encoding, mode); - } - - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/JsonModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/JsonModule.cs deleted file mode 100755 index d4f8c0f1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/JsonModule.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Serialization.Json; - -namespace MoonSharp.Interpreter.CoreLib -{ - [MoonSharpModule(Namespace = "json")] - public class JsonModule - { - [MoonSharpModuleMethod] - public static DynValue parse(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - DynValue vs = args.AsType(0, "parse", DataType.String, false); - Table t = JsonTableConverter.JsonToTable(vs.String, executionContext.GetScript()); - return DynValue.NewTable(t); - } - catch (SyntaxErrorException ex) - { - throw new ScriptRuntimeException(ex); - } - } - - [MoonSharpModuleMethod] - public static DynValue serialize(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - DynValue vt = args.AsType(0, "serialize", DataType.Table, false); - string s = JsonTableConverter.TableToJson(vt.Table); - return DynValue.NewString(s); - } - catch (SyntaxErrorException ex) - { - throw new ScriptRuntimeException(ex); - } - } - - [MoonSharpModuleMethod] - public static DynValue isnull(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vs = args[0]; - return DynValue.NewBoolean((JsonNull.IsJsonNull(vs)) || (vs.IsNil())); - } - - [MoonSharpModuleMethod] - public static DynValue @null(ScriptExecutionContext executionContext, CallbackArguments args) - { - return JsonNull.Create(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/LoadModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/LoadModule.cs deleted file mode 100755 index 3aaf96a4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/LoadModule.cs +++ /dev/null @@ -1,248 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing loading Lua functions like 'require', 'load', etc. - /// - [MoonSharpModule] - public class LoadModule - { - public static void MoonSharpInit(Table globalTable, Table ioTable) - { - DynValue package = globalTable.Get("package"); - - if (package.IsNil()) - { - package = DynValue.NewTable(globalTable.OwnerScript); - globalTable["package"] = package; - } - else if (package.Type != DataType.Table) - { - throw new InternalErrorException("'package' global variable was found and it is not a table"); - } - -#if PCL || ENABLE_DOTNET || NETFX_CORE - string cfg = "\\\n;\n?\n!\n-\n"; -#else - string cfg = System.IO.Path.DirectorySeparatorChar + "\n;\n?\n!\n-\n"; -#endif - - package.Table.Set("config", DynValue.NewString(cfg)); - } - - - - // load (ld [, source [, mode [, env]]]) - // ---------------------------------------------------------------- - // Loads a chunk. - // - // If ld is a string, the chunk is this string. - // - // If there are no syntactic errors, returns the compiled chunk as a function; - // otherwise, returns nil plus the error message. - // - // source is used as the source of the chunk for error messages and debug - // information (see §4.9). When absent, it defaults to ld, if ld is a string, - // or to "=(load)" otherwise. - // - // The string mode is ignored, and assumed to be "t"; - [MoonSharpModuleMethod] - public static DynValue load(ScriptExecutionContext executionContext, CallbackArguments args) - { - return load_impl(executionContext, args, null); - } - - // loadsafe (ld [, source [, mode [, env]]]) - // ---------------------------------------------------------------- - // Same as load, except that "env" defaults to the current environment of the function - // calling load, instead of the actual global environment. - [MoonSharpModuleMethod] - public static DynValue loadsafe(ScriptExecutionContext executionContext, CallbackArguments args) - { - return load_impl(executionContext, args, GetSafeDefaultEnv(executionContext)); - } - - public static DynValue load_impl(ScriptExecutionContext executionContext, CallbackArguments args, Table defaultEnv) - { - try - { - Script S = executionContext.GetScript(); - DynValue ld = args[0]; - string script = ""; - - if (ld.Type == DataType.Function) - { - while (true) - { - DynValue ret = executionContext.GetScript().Call(ld); - if (ret.Type == DataType.String && ret.String.Length > 0) - script += ret.String; - else if (ret.IsNil()) - break; - else - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString("reader function must return a string")); - } - } - else if (ld.Type == DataType.String) - { - script = ld.String; - } - else - { - args.AsType(0, "load", DataType.Function, false); - } - - DynValue source = args.AsType(1, "load", DataType.String, true); - DynValue env = args.AsType(3, "load", DataType.Table, true); - - DynValue fn = S.LoadString(script, - !env.IsNil() ? env.Table : defaultEnv, - !source.IsNil() ? source.String : "=(load)"); - - return fn; - } - catch (SyntaxErrorException ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.DecoratedMessage ?? ex.Message)); - } - } - - // loadfile ([filename [, mode [, env]]]) - // ---------------------------------------------------------------- - // Similar to load, but gets the chunk from file filename or from the standard input, - // if no file name is given. INCOMPAT: stdin not supported, mode ignored - [MoonSharpModuleMethod] - public static DynValue loadfile(ScriptExecutionContext executionContext, CallbackArguments args) - { - return loadfile_impl(executionContext, args, null); - } - - // loadfile ([filename [, mode [, env]]]) - // ---------------------------------------------------------------- - // Same as loadfile, except that "env" defaults to the current environment of the function - // calling load, instead of the actual global environment. - [MoonSharpModuleMethod] - public static DynValue loadfilesafe(ScriptExecutionContext executionContext, CallbackArguments args) - { - return loadfile_impl(executionContext, args, GetSafeDefaultEnv(executionContext)); - } - - - - private static DynValue loadfile_impl(ScriptExecutionContext executionContext, CallbackArguments args, Table defaultEnv) - { - try - { - Script S = executionContext.GetScript(); - DynValue filename = args.AsType(0, "loadfile", DataType.String, false); - DynValue env = args.AsType(2, "loadfile", DataType.Table, true); - - DynValue fn = S.LoadFile(filename.String, env.IsNil() ? defaultEnv : env.Table); - - return fn; - } - catch (SyntaxErrorException ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.DecoratedMessage ?? ex.Message)); - } - } - - - private static Table GetSafeDefaultEnv(ScriptExecutionContext executionContext) - { - Table env = executionContext.CurrentGlobalEnv; - - if (env == null) - throw new ScriptRuntimeException("current environment cannot be backtracked."); - - return env; - } - - //dofile ([filename]) - //-------------------------------------------------------------------------------------------------------------- - //Opens the named file and executes its contents as a Lua chunk. When called without arguments, - //dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. - //In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode). - [MoonSharpModuleMethod] - public static DynValue dofile(ScriptExecutionContext executionContext, CallbackArguments args) - { - try - { - Script S = executionContext.GetScript(); - DynValue v = args.AsType(0, "dofile", DataType.String, false); - - DynValue fn = S.LoadFile(v.String); - - return DynValue.NewTailCallReq(fn); // tail call to dofile - } - catch (SyntaxErrorException ex) - { - throw new ScriptRuntimeException(ex); - } - } - - //require (modname) - //---------------------------------------------------------------------------------------------------------------- - //Loads the given module. The function starts by looking into the package.loaded table to determine whether - //modname is already loaded. If it is, then require returns the value stored at package.loaded[modname]. - //Otherwise, it tries to find a loader for the module. - // - //To find a loader, require is guided by the package.loaders array. By changing this array, we can change - //how require looks for a module. The following explanation is based on the default configuration for package.loaders. - // - //First require queries package.preload[modname]. If it has a value, this value (which should be a function) - //is the loader. Otherwise require searches for a Lua loader using the path stored in package.path. - //If that also fails, it searches for a C loader using the path stored in package.cpath. If that also fails, - //it tries an all-in-one loader (see package.loaders). - // - //Once a loader is found, require calls the loader with a single argument, modname. If the loader returns any value, - //require assigns the returned value to package.loaded[modname]. If the loader returns no value and has not assigned - //any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the - //final value of package.loaded[modname]. - // - //If there is any error loading or running the module, or if it cannot find any loader for the module, then require - //signals an error. - [MoonSharpModuleMethod] - public static DynValue __require_clr_impl(ScriptExecutionContext executionContext, CallbackArguments args) - { - Script S = executionContext.GetScript(); - DynValue v = args.AsType(0, "__require_clr_impl", DataType.String, false); - - DynValue fn = S.RequireModule(v.String); - - return fn; // tail call to dofile - } - - - [MoonSharpModuleMethod] - public const string require = @" -function(modulename) - if (package == nil) then package = { }; end - if (package.loaded == nil) then package.loaded = { }; end - - local m = package.loaded[modulename]; - - if (m ~= nil) then - return m; - end - - local func = __require_clr_impl(modulename); - - local res = func(modulename); - - if (res == nil) then - res = true; - end - - package.loaded[modulename] = res; - - return res; -end"; - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MathModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MathModule.cs deleted file mode 100644 index 352f81ca..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MathModule.cs +++ /dev/null @@ -1,324 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using MoonSharp.Interpreter.Interop; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing math Lua functions - /// - [MoonSharpModule(Namespace = "math")] - public class MathModule - { - [MoonSharpModuleConstant] - public const double pi = Math.PI; - [MoonSharpModuleConstant] - public const double huge = double.MaxValue; - - private static Random GetRandom(Script s) - { - DynValue rr = s.Registry.Get("F61E3AA7247D4D1EB7A45430B0C8C9BB_MATH_RANDOM"); - return (rr.UserData.Object as AnonWrapper).Value; - } - - private static void SetRandom(Script s, Random random) - { - DynValue rr = UserData.Create(new AnonWrapper(random)); - s.Registry.Set("F61E3AA7247D4D1EB7A45430B0C8C9BB_MATH_RANDOM", rr); - } - - - public static void MoonSharpInit(Table globalTable, Table ioTable) - { - SetRandom(globalTable.OwnerScript, new Random()); - } - - - - private static DynValue exec1(CallbackArguments args, string funcName, Func func) - { - DynValue arg = args.AsType(0, funcName, DataType.Number, false); - return DynValue.NewNumber(func(arg.Number)); - } - - private static DynValue exec2(CallbackArguments args, string funcName, Func func) - { - DynValue arg = args.AsType(0, funcName, DataType.Number, false); - DynValue arg2 = args.AsType(1, funcName, DataType.Number, false); - return DynValue.NewNumber(func(arg.Number, arg2.Number)); - } - private static DynValue exec2n(CallbackArguments args, string funcName, double defVal, Func func) - { - DynValue arg = args.AsType(0, funcName, DataType.Number, false); - DynValue arg2 = args.AsType(1, funcName, DataType.Number, true); - - return DynValue.NewNumber(func(arg.Number, arg2.IsNil() ? defVal : arg2.Number)); - } - private static DynValue execaccum(CallbackArguments args, string funcName, Func func) - { - double accum = double.NaN; - - if (args.Count == 0) - { - throw new ScriptRuntimeException("bad argument #1 to '{0}' (number expected, got no value)", funcName); - } - - for (int i = 0; i < args.Count; i++) - { - DynValue arg = args.AsType(i, funcName, DataType.Number, false); - - if (i == 0) - accum = arg.Number; - else - accum = func(accum, arg.Number); - } - - return DynValue.NewNumber(accum); - } - - - [MoonSharpModuleMethod] - public static DynValue abs(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "abs", d => Math.Abs(d)); - } - - [MoonSharpModuleMethod] - public static DynValue acos(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "acos", d => Math.Acos(d)); - } - - [MoonSharpModuleMethod] - public static DynValue asin(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "asin", d => Math.Asin(d)); - } - - [MoonSharpModuleMethod] - public static DynValue atan(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "atan", d => Math.Atan(d)); - } - - [MoonSharpModuleMethod] - public static DynValue atan2(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec2(args, "atan2", (d1, d2) => Math.Atan2(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue ceil(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "ceil", d => Math.Ceiling(d)); - } - - [MoonSharpModuleMethod] - public static DynValue cos(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "cos", d => Math.Cos(d)); - } - - [MoonSharpModuleMethod] - public static DynValue cosh(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "cosh", d => Math.Cosh(d)); - } - - [MoonSharpModuleMethod] - public static DynValue deg(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "deg", d => d * 180.0 / Math.PI); - } - - [MoonSharpModuleMethod] - public static DynValue exp(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "exp", d => Math.Exp(d)); - } - - [MoonSharpModuleMethod] - public static DynValue floor(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "floor", d => Math.Floor(d)); - } - - [MoonSharpModuleMethod] - public static DynValue fmod(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec2(args, "fmod", (d1, d2) => Math.IEEERemainder(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue frexp(ScriptExecutionContext executionContext, CallbackArguments args) - { - // http://stackoverflow.com/questions/389993/extracting-mantissa-and-exponent-from-double-in-c-sharp - - DynValue arg = args.AsType(0, "frexp", DataType.Number, false); - - double d = arg.Number; - - // Translate the double into sign, exponent and mantissa. - long bits = BitConverter.DoubleToInt64Bits(d); - // Note that the shift is sign-extended, hence the test against -1 not 1 - bool negative = (bits < 0); - int exponent = (int) ((bits >> 52) & 0x7ffL); - long mantissa = bits & 0xfffffffffffffL; - - // Subnormal numbers; exponent is effectively one higher, - // but there's no extra normalisation bit in the mantissa - if (exponent==0) - { - exponent++; - } - // Normal numbers; leave exponent as it is but add extra - // bit to the front of the mantissa - else - { - mantissa = mantissa | (1L<<52); - } - - // Bias the exponent. It's actually biased by 1023, but we're - // treating the mantissa as m.0 rather than 0.m, so we need - // to subtract another 52 from it. - exponent -= 1075; - - if (mantissa == 0) - { - return DynValue.NewTuple(DynValue.NewNumber(0), DynValue.NewNumber(0)); - } - - /* Normalize */ - while((mantissa & 1) == 0) - { /* i.e., Mantissa is even */ - mantissa >>= 1; - exponent++; - } - - double m = (double)mantissa; - double e = (double)exponent; - while( m >= 1 ) - { - m /= 2.0; - e += 1.0; - } - - if( negative ) m = -m; - - return DynValue.NewTuple(DynValue.NewNumber(m), DynValue.NewNumber(e)); - } - - [MoonSharpModuleMethod] - public static DynValue ldexp(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec2(args, "ldexp", (d1, d2) => d1 * Math.Pow(2, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue log(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec2n(args, "log", Math.E, (d1, d2) => Math.Log(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue max(ScriptExecutionContext executionContext, CallbackArguments args) - { - return execaccum(args, "max", (d1, d2) => Math.Max(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue min(ScriptExecutionContext executionContext, CallbackArguments args) - { - return execaccum(args, "min", (d1, d2) => Math.Min(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue modf(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg = args.AsType(0, "modf", DataType.Number, false); - return DynValue.NewTuple(DynValue.NewNumber(Math.Floor(arg.Number)), DynValue.NewNumber(arg.Number - Math.Floor(arg.Number))); - } - - - [MoonSharpModuleMethod] - public static DynValue pow(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec2(args, "pow", (d1, d2) => Math.Pow(d1, d2)); - } - - [MoonSharpModuleMethod] - public static DynValue rad(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "rad", d => d * Math.PI / 180.0); - } - - [MoonSharpModuleMethod] - public static DynValue random(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue m = args.AsType(0, "random", DataType.Number, true); - DynValue n = args.AsType(1, "random", DataType.Number, true); - Random R = GetRandom(executionContext.GetScript()); - double d; - - if (m.IsNil() && n.IsNil()) - { - d = R.NextDouble(); - } - else - { - int a = n.IsNil() ? 1 : (int)n.Number; - int b = (int)m.Number; - - if (a < b) - d = R.Next(a, b + 1); - else - d = R.Next(b, a + 1); - } - - return DynValue.NewNumber(d); - } - - [MoonSharpModuleMethod] - public static DynValue randomseed(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg = args.AsType(0, "randomseed", DataType.Number, false); - var script = executionContext.GetScript(); - SetRandom(script, new Random((int)arg.Number)); - return DynValue.Nil; - } - - [MoonSharpModuleMethod] - public static DynValue sin(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "sin", d => Math.Sin(d)); - } - - [MoonSharpModuleMethod] - public static DynValue sinh(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "sinh", d => Math.Sinh(d)); - } - - [MoonSharpModuleMethod] - public static DynValue sqrt(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "sqrt", d => Math.Sqrt(d)); - } - - [MoonSharpModuleMethod] - public static DynValue tan(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "tan", d => Math.Tan(d)); - } - - [MoonSharpModuleMethod] - public static DynValue tanh(ScriptExecutionContext executionContext, CallbackArguments args) - { - return exec1(args, "tanh", d => Math.Tanh(d)); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MetaTableModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MetaTableModule.cs deleted file mode 100644 index 6ba58cc3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/MetaTableModule.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing metatable related Lua functions (xxxmetatable and rawxxx). - /// - [MoonSharpModule] - public class MetaTableModule - { - // setmetatable (table, metatable) - // ------------------------------------------------------------------------------------------------------------------- - // Sets the metatable for the given table. (You cannot change the metatable of other - // types from Lua, only from C.) If metatable is nil, removes the metatable of the given table. - // If the original metatable has a "__metatable" field, raises an error ("cannot change a protected metatable"). - // This function returns table. - [MoonSharpModuleMethod] - public static DynValue setmetatable(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args.AsType(0, "setmetatable", DataType.Table); - DynValue metatable = args.AsType(1, "setmetatable", DataType.Table, true); - - DynValue curmeta = executionContext.GetMetamethod(table, "__metatable"); - - if (curmeta != null) - { - throw new ScriptRuntimeException("cannot change a protected metatable"); - } - - table.Table.MetaTable = metatable.Table; - return table; - } - - // getmetatable (object) - // ------------------------------------------------------------------------------------------------------------------- - // If object does not have a metatable, returns nil. Otherwise, if the object's metatable - // has a "__metatable" field, returns the associated value. Otherwise, returns the metatable of the given object. - [MoonSharpModuleMethod] - public static DynValue getmetatable(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue obj = args[0]; - Table meta = null; - - if (obj.Type.CanHaveTypeMetatables()) - { - meta = executionContext.GetScript().GetTypeMetatable(obj.Type); - } - - - if (obj.Type == DataType.Table) - { - meta = obj.Table.MetaTable; - } - - if (meta == null) - return DynValue.Nil; - else if (meta.RawGet("__metatable") != null) - return meta.Get("__metatable"); - else - return DynValue.NewTable(meta); - } - - // rawget (table, index) - // ------------------------------------------------------------------------------------------------------------------- - // Gets the real value of table[index], without invoking any metamethod. table must be a table; index may be any value. - [MoonSharpModuleMethod] - public static DynValue rawget(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args.AsType(0, "rawget", DataType.Table); - DynValue index = args[1]; - - return table.Table.Get(index); - } - - // rawset (table, index, value) - // ------------------------------------------------------------------------------------------------------------------- - // Sets the real value of table[index] to value, without invoking any metamethod. table must be a table, - // index any value different from nil and NaN, and value any Lua value. - // This function returns table. - [MoonSharpModuleMethod] - public static DynValue rawset(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args.AsType(0, "rawset", DataType.Table); - DynValue index = args[1]; - - table.Table.Set(index, args[2]); - - return table; - } - - // rawequal (v1, v2) - // ------------------------------------------------------------------------------------------------------------------- - // Checks whether v1 is equal to v2, without invoking any metamethod. Returns a boolean. - [MoonSharpModuleMethod] - public static DynValue rawequal(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v1 = args[0]; - DynValue v2 = args[1]; - - return DynValue.NewBoolean(v1.Equals(v2)); - } - - //rawlen (v) - // ------------------------------------------------------------------------------------------------------------------- - //Returns the length of the object v, which must be a table or a string, without invoking any metamethod. Returns an integer number. - [MoonSharpModuleMethod] - public static DynValue rawlen(ScriptExecutionContext executionContext, CallbackArguments args) - { - if (args[0].Type != DataType.String && args[0].Type != DataType.Table) - { - throw ScriptRuntimeException.BadArgument(0, "rawlen", "table or string", args[0].Type.ToErrorTypeString(), false); - } - - return args[0].GetLength(); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsSystemModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsSystemModule.cs deleted file mode 100644 index 96edab57..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsSystemModule.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing system related Lua functions from the 'os' module. - /// Proper support requires a compatible IPlatformAccessor - /// - [MoonSharpModule(Namespace = "os")] - public class OsSystemModule - { - [MoonSharpModuleMethod] - public static DynValue execute(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v = args.AsType(0, "execute", DataType.String, true); - - if (v.IsNil()) - { - return DynValue.NewBoolean(true); - } - else - { - try - { - int exitCode = Script.GlobalOptions.Platform.OS_Execute(v.String); - - return DynValue.NewTuple( - DynValue.Nil, - DynValue.NewString("exit"), - DynValue.NewNumber(exitCode)); - } - catch (Exception) - { - // +++ bad to swallow.. - return DynValue.Nil; - } - } - } - - [MoonSharpModuleMethod] - public static DynValue exit(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue v_exitCode = args.AsType(0, "exit", DataType.Number, true); - int exitCode = 0; - - if (v_exitCode.IsNotNil()) - exitCode = (int)v_exitCode.Number; - - Script.GlobalOptions.Platform.OS_ExitFast(exitCode); - - throw new InvalidOperationException("Unreachable code.. reached."); - } - - [MoonSharpModuleMethod] - public static DynValue getenv(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue varName = args.AsType(0, "getenv", DataType.String, false); - - string val = Script.GlobalOptions.Platform.GetEnvironmentVariable(varName.String); - - if (val == null) - return DynValue.Nil; - else - return DynValue.NewString(val); - } - - [MoonSharpModuleMethod] - public static DynValue remove(ScriptExecutionContext executionContext, CallbackArguments args) - { - string fileName = args.AsType(0, "remove", DataType.String, false).String; - - try - { - if (Script.GlobalOptions.Platform.OS_FileExists(fileName)) - { - Script.GlobalOptions.Platform.OS_FileDelete(fileName); - return DynValue.True; - } - else - { - return DynValue.NewTuple( - DynValue.Nil, - DynValue.NewString("{0}: No such file or directory.", fileName), - DynValue.NewNumber(-1)); - } - } - catch (Exception ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.Message), DynValue.NewNumber(-1)); - } - } - - [MoonSharpModuleMethod] - public static DynValue rename(ScriptExecutionContext executionContext, CallbackArguments args) - { - string fileNameOld = args.AsType(0, "rename", DataType.String, false).String; - string fileNameNew = args.AsType(1, "rename", DataType.String, false).String; - - try - { - if (!Script.GlobalOptions.Platform.OS_FileExists(fileNameOld)) - { - return DynValue.NewTuple(DynValue.Nil, - DynValue.NewString("{0}: No such file or directory.", fileNameOld), - DynValue.NewNumber(-1)); - } - - Script.GlobalOptions.Platform.OS_FileMove(fileNameOld, fileNameNew); - return DynValue.True; - } - catch (Exception ex) - { - return DynValue.NewTuple(DynValue.Nil, DynValue.NewString(ex.Message), DynValue.NewNumber(-1)); - } - } - - [MoonSharpModuleMethod] - public static DynValue setlocale(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewString("n/a"); - } - - [MoonSharpModuleMethod] - public static DynValue tmpname(ScriptExecutionContext executionContext, CallbackArguments args) - { - return DynValue.NewString(Script.GlobalOptions.Platform.IO_OS_GetTempFilename()); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsTimeModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsTimeModule.cs deleted file mode 100755 index 762632fa..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/OsTimeModule.cs +++ /dev/null @@ -1,287 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.Collections.Generic; -using System.Text; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing time related Lua functions from the 'os' module. - /// - [MoonSharpModule(Namespace = "os")] - public class OsTimeModule - { - static DateTime Time0 = DateTime.UtcNow; - static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - private static DynValue GetUnixTime(DateTime dateTime, DateTime? epoch = null) - { - double time = (dateTime - (epoch ?? Epoch)).TotalSeconds; - - if (time < 0.0) - return DynValue.Nil; - - return DynValue.NewNumber(time); - } - - private static DateTime FromUnixTime(double unixtime) - { - TimeSpan ts = TimeSpan.FromSeconds(unixtime); - return Epoch + ts; - } - - [MoonSharpModuleMethod] - public static DynValue clock(ScriptExecutionContext executionContext, CallbackArguments args) - { - return GetUnixTime(DateTime.UtcNow, Time0); - } - - [MoonSharpModuleMethod] - public static DynValue difftime(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue t2 = args.AsType(0, "difftime", DataType.Number, false); - DynValue t1 = args.AsType(1, "difftime", DataType.Number, true); - - if (t1.IsNil()) - return DynValue.NewNumber(t2.Number); - - return DynValue.NewNumber(t2.Number - t1.Number); - } - - [MoonSharpModuleMethod] - public static DynValue time(ScriptExecutionContext executionContext, CallbackArguments args) - { - DateTime date = DateTime.UtcNow; - - if (args.Count > 0) - { - DynValue vt = args.AsType(0, "time", DataType.Table, true); - if (vt.Type == DataType.Table) - date = ParseTimeTable(vt.Table); - } - - return GetUnixTime(date); - } - - static DateTime ParseTimeTable(Table t) - { - int sec = GetTimeTableField(t, "sec") ?? 0; - int min = GetTimeTableField(t, "min") ?? 0; - int hour = GetTimeTableField(t, "hour") ?? 12; - int? day = GetTimeTableField(t, "day"); - int? month = GetTimeTableField(t, "month"); - int? year = GetTimeTableField(t, "year"); - - if (day == null) - throw new ScriptRuntimeException("field 'day' missing in date table"); - - if (month == null) - throw new ScriptRuntimeException("field 'month' missing in date table"); - - if (year == null) - throw new ScriptRuntimeException("field 'year' missing in date table"); - - return new DateTime(year.Value, month.Value, day.Value, hour, min, sec); - } - - - private static int? GetTimeTableField(Table t, string key) - { - DynValue v = t.Get(key); - double? d = v.CastToNumber(); - - if (d.HasValue) - return (int)d.Value; - - return null; - } - - [MoonSharpModuleMethod] - public static DynValue date(ScriptExecutionContext executionContext, CallbackArguments args) - { - DateTime reference = DateTime.UtcNow; - - DynValue vformat = args.AsType(0, "date", DataType.String, true); - DynValue vtime = args.AsType(1, "date", DataType.Number, true); - - string format = (vformat.IsNil()) ? "%c" : vformat.String; - - if (vtime.IsNotNil()) - reference = FromUnixTime(vtime.Number); - - bool isDst = false; - - if (format.StartsWith("!")) - { - format = format.Substring(1); - } - else - { -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) - - try - { - reference = TimeZoneInfo.ConvertTimeFromUtc(reference, TimeZoneInfo.Local); - isDst = reference.IsDaylightSavingTime(); - } - catch (TimeZoneNotFoundException) - { - // this catches a weird mono bug: https://bugzilla.xamarin.com/show_bug.cgi?id=11817 - // however the behavior is definitely not correct. damn. - } -#endif - } - - - if (format == "*t") - { - Table t = new Table(executionContext.GetScript()); - - t.Set("year", DynValue.NewNumber(reference.Year)); - t.Set("month", DynValue.NewNumber(reference.Month)); - t.Set("day", DynValue.NewNumber(reference.Day)); - t.Set("hour", DynValue.NewNumber(reference.Hour)); - t.Set("min", DynValue.NewNumber(reference.Minute)); - t.Set("sec", DynValue.NewNumber(reference.Second)); - t.Set("wday", DynValue.NewNumber(((int)reference.DayOfWeek) + 1)); - t.Set("yday", DynValue.NewNumber(reference.DayOfYear)); - t.Set("isdst", DynValue.NewBoolean(isDst)); - - return DynValue.NewTable(t); - } - - else return DynValue.NewString(StrFTime(format, reference)); - } - - private static string StrFTime(string format, DateTime d) - { - // ref: http://www.cplusplus.com/reference/ctime/strftime/ - - Dictionary STANDARD_PATTERNS = new Dictionary() - { - { 'a', "ddd" }, - { 'A', "dddd" }, - { 'b', "MMM" }, - { 'B', "MMMM" }, - { 'c', "f" }, - { 'd', "dd" }, - { 'D', "MM/dd/yy" }, - { 'F', "yyyy-MM-dd" }, - { 'g', "yy" }, - { 'G', "yyyy" }, - { 'h', "MMM" }, - { 'H', "HH" }, - { 'I', "hh" }, - { 'm', "MM" }, - { 'M', "mm" }, - { 'p', "tt" }, - { 'r', "h:mm:ss tt" }, - { 'R', "HH:mm" }, - { 'S', "ss" }, - { 'T', "HH:mm:ss" }, - { 'y', "yy" }, - { 'Y', "yyyy" }, - { 'x', "d" }, - { 'X', "T" }, - { 'z', "zzz" }, - { 'Z', "zzz" }, - }; - - - StringBuilder sb = new StringBuilder(); - - bool isEscapeSequence = false; - - for (int i = 0; i < format.Length; i++) - { - char c = format[i]; - - if (c == '%') - { - if (isEscapeSequence) - { - sb.Append('%'); - isEscapeSequence = false; - } - else - isEscapeSequence = true; - - continue; - } - - if (!isEscapeSequence) - { - sb.Append(c); - continue; - } - - if (c == 'O' || c == 'E') continue; // no modifiers - - isEscapeSequence = false; - - if (STANDARD_PATTERNS.ContainsKey(c)) - { - sb.Append(d.ToString(STANDARD_PATTERNS[c])); - } - else if (c == 'e') - { - string s = d.ToString("%d"); - if (s.Length < 2) s = " " + s; - sb.Append(s); - } - else if (c == 'n') - { - sb.Append('\n'); - } - else if (c == 't') - { - sb.Append('\t'); - } - else if (c == 'C') - { - sb.Append((int)(d.Year / 100)); - } - else if (c == 'j') - { - sb.Append(d.DayOfYear.ToString("000")); - } - else if (c == 'u') - { - int weekDay = (int)d.DayOfWeek; - if (weekDay == 0) - weekDay = 7; - - sb.Append(weekDay); - } - else if (c == 'w') - { - int weekDay = (int)d.DayOfWeek; - sb.Append(weekDay); - } - else if (c == 'U') - { - // Week number with the first Sunday as the first day of week one (00-53) - sb.Append("??"); - } - else if (c == 'V') - { - // ISO 8601 week number (00-53) - sb.Append("??"); - } - else if (c == 'W') - { - // Week number with the first Monday as the first day of week one (00-53) - sb.Append("??"); - } - else - { - throw new ScriptRuntimeException("bad argument #1 to 'date' (invalid conversion specifier '{0}')", format); - } - } - - return sb.ToString(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/KopiLua_StrLib.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/KopiLua_StrLib.cs deleted file mode 100644 index f9b90cb3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/KopiLua_StrLib.cs +++ /dev/null @@ -1,998 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -// -// This part taken from KopiLua - https://github.com/NLua/KopiLua -// -// ========================================================================================================= -// -// Kopi Lua License -// ---------------- -// MIT License for KopiLua -// Copyright (c) 2012 LoDC -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -// associated documentation files (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// The above copyright notice and this permission notice shall be included in all copies or substantial -// portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// =============================================================================== -// Lua License -// ----------- -// Lua is licensed under the terms of the MIT license reproduced below. -// This means that Lua is free software and can be used for both academic -// and commercial purposes at absolutely no cost. -// For details and rationale, see http://www.lua.org/license.html . -// =============================================================================== -// Copyright (C) 1994-2008 Lua.org, PUC-Rio. -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -using MoonSharp.Interpreter.Interop.LuaStateInterop; -using lua_Integer = System.Int32; -using LUA_INTFRM_T = System.Int64; -using ptrdiff_t = System.Int32; -using UNSIGNED_LUA_INTFRM_T = System.UInt64; - -namespace MoonSharp.Interpreter.CoreLib.StringLib -{ - internal class KopiLua_StringLib : LuaBase - { - public const int LUA_MAXCAPTURES = 32; - - private static ptrdiff_t posrelat(ptrdiff_t pos, uint len) - { - /* relative string position: negative means back from end */ - if (pos < 0) pos += (ptrdiff_t)len + 1; - return (pos >= 0) ? pos : 0; - } - - /* - ** {====================================================== - ** PATTERN MATCHING - ** ======================================================= - */ - - - public const int CAP_UNFINISHED = (-1); - public const int CAP_POSITION = (-2); - - public class MatchState - { - - public MatchState() - { - for (int i = 0; i < LUA_MAXCAPTURES; i++) - capture[i] = new capture_(); - } - - public int matchdepth; /* control for recursive depth (to avoid C stack overflow) */ - public CharPtr src_init; /* init of source string */ - public CharPtr src_end; /* end (`\0') of source string */ - public LuaState L; - public int level; /* total number of captures (finished or unfinished) */ - - public class capture_ - { - public CharPtr init; - public ptrdiff_t len; - }; - public capture_[] capture = new capture_[LUA_MAXCAPTURES]; - }; - - - public const int MAXCCALLS = 200; - public const char L_ESC = '%'; - public const string SPECIALS = "^$*+?.([%-"; - - - private static int check_capture(MatchState ms, int l) - { - l -= '1'; - if (l < 0 || l >= ms.level || ms.capture[l].len == CAP_UNFINISHED) - return LuaLError(ms.L, "invalid capture index {0}", l + 1); - return l; - } - - - - private static int capture_to_close(MatchState ms) - { - int level = ms.level; - for (level--; level >= 0; level--) - if (ms.capture[level].len == CAP_UNFINISHED) return level; - return LuaLError(ms.L, "invalid pattern capture"); - } - - - private static CharPtr classend(MatchState ms, CharPtr p) - { - p = new CharPtr(p); - char c = p[0]; - p = p.next(); - switch (c) - { - case L_ESC: - { - if (p[0] == '\0') - LuaLError(ms.L, "malformed pattern (ends with " + LUA_QL("%") + ")"); - return p + 1; - } - case '[': - { - if (p[0] == '^') p = p.next(); - do - { /* look for a `]' */ - if (p[0] == '\0') - LuaLError(ms.L, "malformed pattern (missing " + LUA_QL("]") + ")"); - c = p[0]; - p = p.next(); - if (c == L_ESC && p[0] != '\0') - p = p.next(); /* skip escapes (e.g. `%]') */ - } while (p[0] != ']'); - return p + 1; - } - default: - { - return p; - } - } - } - - - - private static int match_class(char c, char cl) - { - bool res; - switch (tolower(cl)) - { - case 'a': res = isalpha(c); break; - case 'c': res = iscntrl(c); break; - case 'd': res = isdigit(c); break; - case 'l': res = islower(c); break; - case 'p': res = ispunct(c); break; - case 's': res = isspace(c); break; - case 'g': res = isgraph(c); break; - case 'u': res = isupper(c); break; - case 'w': res = isalnum(c); break; - case 'x': res = isxdigit((char)c); break; - case 'z': res = (c == 0); break; - default: return (cl == c) ? 1 : 0; - } - return (islower(cl) ? (res ? 1 : 0) : ((!res) ? 1 : 0)); - } - - - - private static int matchbracketclass(int c, CharPtr p, CharPtr ec) - { - int sig = 1; - if (p[1] == '^') - { - sig = 0; - p = p.next(); /* skip the `^' */ - } - while ((p = p.next()) < ec) - { - if (p == L_ESC) - { - p = p.next(); - if (match_class((char)c, (char)(p[0])) != 0) - return sig; - } - else if ((p[1] == '-') && (p + 2 < ec)) - { - p += 2; - if ((byte)((p[-2])) <= c && (c <= (byte)p[0])) - return sig; - } - else if ((byte)(p[0]) == c) return sig; - } - return (sig == 0) ? 1 : 0; - } - - - private static int singlematch(int c, CharPtr p, CharPtr ep) - { - switch (p[0]) - { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class((char)c, (char)(p[1])); - case '[': return matchbracketclass(c, p, ep - 1); - default: return ((byte)(p[0]) == c) ? 1 : 0; - } - } - - - private static CharPtr matchbalance(MatchState ms, CharPtr s, - CharPtr p) - { - if ((p[0] == 0) || (p[1] == 0)) - LuaLError(ms.L, "unbalanced pattern"); - if (s[0] != p[0]) return null; - else - { - int b = p[0]; - int e = p[1]; - int cont = 1; - while ((s = s.next()) < ms.src_end) - { - if (s[0] == e) - { - if (--cont == 0) return s + 1; - } - else if (s[0] == b) cont++; - } - } - return null; /* string ends out of balance */ - } - - - private static CharPtr max_expand(MatchState ms, CharPtr s, - CharPtr p, CharPtr ep) - { - ptrdiff_t i = 0; /* counts maximum expand for item */ - while ((s + i < ms.src_end) && (singlematch((byte)(s[i]), p, ep) != 0)) - i++; - /* keeps trying to match with the maximum repetitions */ - while (i >= 0) - { - CharPtr res = match(ms, (s + i), ep + 1); - if (res != null) return res; - i--; /* else didn't match; reduce 1 repetition to try again */ - } - return null; - } - - - private static CharPtr min_expand(MatchState ms, CharPtr s, - CharPtr p, CharPtr ep) - { - for (; ; ) - { - CharPtr res = match(ms, s, ep + 1); - if (res != null) - return res; - else if ((s < ms.src_end) && (singlematch((byte)(s[0]), p, ep) != 0)) - s = s.next(); /* try with one more repetition */ - else return null; - } - } - - - private static CharPtr start_capture(MatchState ms, CharPtr s, - CharPtr p, int what) - { - CharPtr res; - int level = ms.level; - if (level >= LUA_MAXCAPTURES) LuaLError(ms.L, "too many captures"); - ms.capture[level].init = s; - ms.capture[level].len = what; - ms.level = level + 1; - if ((res = match(ms, s, p)) == null) /* match failed? */ - ms.level--; /* undo capture */ - return res; - } - - - private static CharPtr end_capture(MatchState ms, CharPtr s, - CharPtr p) - { - int l = capture_to_close(ms); - CharPtr res; - ms.capture[l].len = s - ms.capture[l].init; /* close capture */ - if ((res = match(ms, s, p)) == null) /* match failed? */ - ms.capture[l].len = CAP_UNFINISHED; /* undo capture */ - return res; - } - - - private static CharPtr match_capture(MatchState ms, CharPtr s, int l) - { - uint len; - l = check_capture(ms, l); - len = (uint)ms.capture[l].len; - if ((uint)(ms.src_end - s) >= len && - memcmp(ms.capture[l].init, s, len) == 0) - return s + len; - else return null; - } - - - - private static CharPtr match(MatchState ms, CharPtr s, CharPtr p) - { - s = new CharPtr(s); - p = new CharPtr(p); - if (ms.matchdepth-- == 0) - LuaLError(ms.L, "pattern too complex"); - init: /* using goto's to optimize tail recursion */ - switch (p[0]) - { - case '(': - { /* start capture */ - if (p[1] == ')') /* position capture? */ - return start_capture(ms, s, p + 2, CAP_POSITION); - else - return start_capture(ms, s, p + 1, CAP_UNFINISHED); - } - case ')': - { /* end capture */ - return end_capture(ms, s, p + 1); - } - case L_ESC: - { - switch (p[1]) - { - case 'b': - { /* balanced string? */ - s = matchbalance(ms, s, p + 2); - if (s == null) return null; - p += 4; goto init; /* else return match(ms, s, p+4); */ - } - case 'f': - { /* frontier? */ - CharPtr ep; char previous; - p += 2; - if (p[0] != '[') - LuaLError(ms.L, "missing " + LUA_QL("[") + " after " + - LUA_QL("%f") + " in pattern"); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms.src_init) ? '\0' : s[-1]; - if ((matchbracketclass((byte)(previous), p, ep - 1) != 0) || - (matchbracketclass((byte)(s[0]), p, ep - 1) == 0)) return null; - p = ep; goto init; /* else return match(ms, s, ep); */ - } - default: - { - if (isdigit((char)(p[1]))) - { /* capture results (%0-%9)? */ - s = match_capture(ms, s, (byte)(p[1])); - if (s == null) return null; - p += 2; goto init; /* else return match(ms, s, p+2) */ - } - //ismeretlen hiba miatt lett ide átmásolva - { /* it is a pattern item */ - CharPtr ep = classend(ms, p); /* points to what is next */ - int m = (s < ms.src_end) && (singlematch((byte)(s[0]), p, ep) != 0) ? 1 : 0; - switch (ep[0]) - { - case '?': - { /* optional */ - CharPtr res; - if ((m != 0) && ((res = match(ms, s + 1, ep + 1)) != null)) - return res; - p = ep + 1; goto init; /* else return match(ms, s, ep+1); */ - } - case '*': - { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); - } - case '+': - { /* 1 or more repetitions */ - return ((m != 0) ? max_expand(ms, s + 1, p, ep) : null); - } - case '-': - { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); - } - default: - { - if (m == 0) return null; - s = s.next(); p = ep; goto init; /* else return match(ms, s+1, ep); */ - } - } - } - //goto dflt; /* case default */ - } - } - } - case '\0': - { /* end of pattern */ - return s; /* match succeeded */ - } - case '$': - { - if (p[1] == '\0') /* is the `$' the last char in pattern? */ - return (s == ms.src_end) ? s : null; /* check end of string */ - else goto dflt; - } - default: - dflt: - { /* it is a pattern item */ - CharPtr ep = classend(ms, p); /* points to what is next */ - int m = (s < ms.src_end) && (singlematch((byte)(s[0]), p, ep) != 0) ? 1 : 0; - switch (ep[0]) - { - case '?': - { /* optional */ - CharPtr res; - if ((m != 0) && ((res = match(ms, s + 1, ep + 1)) != null)) - return res; - p = ep + 1; goto init; /* else return match(ms, s, ep+1); */ - } - case '*': - { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); - } - case '+': - { /* 1 or more repetitions */ - return ((m != 0) ? max_expand(ms, s + 1, p, ep) : null); - } - case '-': - { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); - } - default: - { - if (m == 0) return null; - s = s.next(); p = ep; goto init; /* else return match(ms, s+1, ep); */ - } - } - } - } - } - - - - private static CharPtr lmemfind(CharPtr s1, uint l1, - CharPtr s2, uint l2) - { - if (l2 == 0) return s1; /* empty strings are everywhere */ - else if (l2 > l1) return null; /* avoids a negative `l1' */ - else - { - CharPtr init; /* to search for a `*s2' inside `s1' */ - l2--; /* 1st char will be checked by `memchr' */ - l1 = l1 - l2; /* `s2' cannot be found after that */ - while (l1 > 0 && (init = memchr(s1, s2[0], l1)) != null) - { - init = init.next(); /* 1st char is already checked */ - if (memcmp(init, s2 + 1, l2) == 0) - return init - 1; - else - { /* correct `l1' and `s1' to try again */ - l1 -= (uint)(init - s1); - s1 = init; - } - } - return null; /* not found */ - } - } - - - private static void push_onecapture(MatchState ms, int i, CharPtr s, - CharPtr e) - { - if (i >= ms.level) - { - if (i == 0) /* ms.level == 0, too */ - LuaPushLString(ms.L, s, (uint)(e - s)); /* add whole match */ - else - LuaLError(ms.L, "invalid capture index"); - } - else - { - ptrdiff_t l = ms.capture[i].len; - if (l == CAP_UNFINISHED) LuaLError(ms.L, "unfinished capture"); - if (l == CAP_POSITION) - LuaPushInteger(ms.L, ms.capture[i].init - ms.src_init + 1); - else - LuaPushLString(ms.L, ms.capture[i].init, (uint)l); - } - } - - - private static int push_captures(MatchState ms, CharPtr s, CharPtr e) - { - int i; - int nlevels = ((ms.level == 0) && (s != null)) ? 1 : ms.level; - LuaLCheckStack(ms.L, nlevels, "too many captures"); - for (i = 0; i < nlevels; i++) - push_onecapture(ms, i, s, e); - return nlevels; /* number of strings pushed */ - } - - - private static int str_find_aux(LuaState L, int find) - { - uint l1, l2; - CharPtr s = LuaLCheckLString(L, 1, out l1); - CharPtr p = PatchPattern(LuaLCheckLString(L, 2, out l2)); - - ptrdiff_t init = posrelat(LuaLOptInteger(L, 3, 1), l1) - 1; - if (init < 0) init = 0; - else if ((uint)(init) > l1) init = (ptrdiff_t)l1; - if ((find != 0) && ((LuaToBoolean(L, 4) != 0) || /* explicit request? */ - strpbrk(p, SPECIALS) == null)) - { /* or no special characters? */ - /* do a plain search */ - CharPtr s2 = lmemfind(s + init, (uint)(l1 - init), p, (uint)(l2)); - if (s2 != null) - { - LuaPushInteger(L, s2 - s + 1); - LuaPushInteger(L, (int)(s2 - s + l2)); - return 2; - } - } - else - { - MatchState ms = new MatchState(); - int anchor = 0; - if (p[0] == '^') - { - p = p.next(); - anchor = 1; - } - CharPtr s1 = s + init; - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = s; - ms.src_end = s + l1; - do - { - CharPtr res; - ms.level = 0; - // LuaAssert(ms.matchdepth == MAXCCALLS); - ms.matchdepth = MAXCCALLS; - if ((res = match(ms, s1, p)) != null) - { - if (find != 0) - { - LuaPushInteger(L, s1 - s + 1); /* start */ - LuaPushInteger(L, res - s); /* end */ - return push_captures(ms, null, null) + 2; - } - else - return push_captures(ms, s1, res); - } - } while (((s1 = s1.next()) <= ms.src_end) && (anchor == 0)); - } - LuaPushNil(L); /* not found */ - return 1; - } - - - public static int str_find(LuaState L) - { - return str_find_aux(L, 1); - } - - - public static int str_match(LuaState L) - { - return str_find_aux(L, 0); - } - - private class GMatchAuxData - { - public CharPtr S; - public CharPtr P; - public uint LS; - public uint POS; - } - - - private static int gmatch_aux(LuaState L, GMatchAuxData auxdata) - { - MatchState ms = new MatchState(); - uint ls = auxdata.LS; - CharPtr s = auxdata.S; - CharPtr p = auxdata.P; - CharPtr src; - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = s; - ms.src_end = s + ls; - for (src = s + auxdata.POS; - src <= ms.src_end; - src = src.next()) - { - CharPtr e; - ms.level = 0; - //LuaAssert(ms.matchdepth == MAXCCALLS); - ms.matchdepth = MAXCCALLS; - - if ((e = match(ms, src, p)) != null) - { - lua_Integer newstart = e - s; - if (e == src) newstart++; /* empty match? go at least one position */ - auxdata.POS = (uint)newstart; - return push_captures(ms, src, e); - } - } - return 0; /* not found */ - } - - - private static DynValue gmatch_aux_2(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "gmatch", - L => gmatch_aux(L, (GMatchAuxData)executionContext.AdditionalData)); - } - - - public static int str_gmatch(LuaState L) - { - CallbackFunction C = new CallbackFunction(gmatch_aux_2, "gmatch"); - string s = ArgAsType(L, 1, DataType.String, false).String; - string p = PatchPattern(ArgAsType(L, 2, DataType.String, false).String); - - - C.AdditionalData = new GMatchAuxData() - { - S = new CharPtr(s), - P = new CharPtr(p), - LS = (uint)s.Length, - POS = 0 - }; - - L.Push(DynValue.NewCallback(C)); - - return 1; - } - - - private static int gfind_nodef(LuaState L) - { - return LuaLError(L, LUA_QL("string.gfind") + " was renamed to " + - LUA_QL("string.gmatch")); - } - - - private static void add_s(MatchState ms, LuaLBuffer b, CharPtr s, CharPtr e) - { - uint l, i; - CharPtr news = LuaToLString(ms.L, 3, out l); - for (i = 0; i < l; i++) - { - if (news[i] != L_ESC) - LuaLAddChar(b, news[i]); - else - { - i++; /* skip ESC */ - if (!isdigit((char)(news[i]))) - { - if (news[i] != L_ESC) - { - LuaLError(ms.L, "invalid use of '%' in replacement string"); - } - LuaLAddChar(b, news[i]); - } - else if (news[i] == '0') - LuaLAddLString(b, s, (uint)(e - s)); - else - { - push_onecapture(ms, news[i] - '1', s, e); - LuaLAddValue(b); /* add capture to accumulated result */ - } - } - } - } - - - - - private static void add_value(MatchState ms, LuaLBuffer b, CharPtr s, - CharPtr e) - { - LuaState L = ms.L; - switch (LuaType(L, 3)) - { - case LUA_TNUMBER: - case LUA_TSTRING: - { - add_s(ms, b, s, e); - return; - } - // case LUA_TUSERDATA: /// +++ does this make sense ?? - case LUA_TFUNCTION: - { - int n; - LuaPushValue(L, 3); - n = push_captures(ms, s, e); - LuaCall(L, n, 1); - break; - } - case LUA_TTABLE: - { - push_onecapture(ms, 0, s, e); - LuaGetTable(L, 3); - break; - } - } - if (LuaToBoolean(L, -1) == 0) - { /* nil or false? */ - LuaPop(L, 1); - LuaPushLString(L, s, (uint)(e - s)); /* keep original text */ - } - else if (LuaIsString(L, -1) == 0) - LuaLError(L, "invalid replacement value (a {0})", LuaLTypeName(L, -1)); - - LuaLAddValue(b); /* add result to accumulator */ - } - - - public static int str_gsub(LuaState L) - { - uint srcl; - CharPtr src = LuaLCheckLString(L, 1, out srcl); - CharPtr p = PatchPattern(LuaLCheckStringStr(L, 2)); - int tr = LuaType(L, 3); - int max_s = LuaLOptInt(L, 4, (int)(srcl + 1)); - int anchor = 0; - if (p[0] == '^') - { - p = p.next(); - anchor = 1; - } - int n = 0; - MatchState ms = new MatchState(); - LuaLBuffer b = new LuaLBuffer(L); - LuaLArgCheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || - tr == LUA_TFUNCTION || tr == LUA_TTABLE || - tr == LUA_TUSERDATA, 3, - "string/function/table expected"); - LuaLBuffInit(L, b); - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = src; - ms.src_end = src + srcl; - while (n < max_s) - { - CharPtr e; - ms.level = 0; - //LuaAssert(ms.matchdepth == MAXCCALLS); - ms.matchdepth = MAXCCALLS; - e = match(ms, src, p); - if (e != null) - { - n++; - add_value(ms, b, src, e); - } - if ((e != null) && e > src) /* non empty match? */ - src = e; /* skip it */ - else if (src < ms.src_end) - { - char c = src[0]; - src = src.next(); - LuaLAddChar(b, c); - } - else break; - if (anchor != 0) break; - } - LuaLAddLString(b, src, (uint)(ms.src_end - src)); - LuaLPushResult(b); - LuaPushInteger(L, n); /* number of substitutions */ - return 2; - } - - - /* }====================================================== */ - - - /* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ - public const int MAX_ITEM = 512; - /* valid flags in a format specification */ - public const string FLAGS = "-+ #0"; - /* - ** maximum size of each format specification (such as '%-099.99d') - ** (+10 accounts for %99.99x plus margin of error) - */ - public static readonly int MAX_FORMAT = (FLAGS.Length + 1) + (LUA_INTFRMLEN.Length + 1) + 10; - - - private static void addquoted(LuaState L, LuaLBuffer b, int arg) - { - uint l; - CharPtr s = LuaLCheckLString(L, arg, out l); - LuaLAddChar(b, '"'); - while ((l--) != 0) - { - switch (s[0]) - { - case '"': - case '\\': - case '\n': - { - LuaLAddChar(b, '\\'); - LuaLAddChar(b, s[0]); - break; - } - case '\r': - { - LuaLAddLString(b, "\\r", 2); - break; - } - default: - { - if (s[0] < (char)16) - { - bool isfollowedbynum = false; - - if (l >= 1) - { - if (char.IsNumber(s[1])) - isfollowedbynum = true; - } - - if (isfollowedbynum) - LuaLAddString(b, string.Format("\\{0:000}", (int)s[0])); - else - LuaLAddString(b, string.Format("\\{0}", (int)s[0])); - } - else - { - LuaLAddChar(b, s[0]); - } - break; - } - } - s = s.next(); - } - LuaLAddChar(b, '"'); - } - - private static CharPtr scanformat(LuaState L, CharPtr strfrmt, CharPtr form) - { - CharPtr p = strfrmt; - while (p[0] != '\0' && strchr(FLAGS, p[0]) != null) p = p.next(); /* skip flags */ - if ((uint)(p - strfrmt) >= (FLAGS.Length + 1)) - LuaLError(L, "invalid format (repeated flags)"); - if (isdigit((byte)(p[0]))) p = p.next(); /* skip width */ - if (isdigit((byte)(p[0]))) p = p.next(); /* (2 digits at most) */ - if (p[0] == '.') - { - p = p.next(); - if (isdigit((byte)(p[0]))) p = p.next(); /* skip precision */ - if (isdigit((byte)(p[0]))) p = p.next(); /* (2 digits at most) */ - } - if (isdigit((byte)(p[0]))) - LuaLError(L, "invalid format (width or precision too long)"); - form[0] = '%'; - form = form.next(); - strncpy(form, strfrmt, p - strfrmt + 1); - form += p - strfrmt + 1; - form[0] = '\0'; - return p; - } - - - private static void addintlen(CharPtr form) - { - uint l = (uint)strlen(form); - char spec = form[l - 1]; - strcpy(form + l - 1, LUA_INTFRMLEN); - form[l + (LUA_INTFRMLEN.Length + 1) - 2] = spec; - form[l + (LUA_INTFRMLEN.Length + 1) - 1] = '\0'; - } - - - public static int str_format(LuaState L) - { - int top = LuaGetTop(L); - int arg = 1; - uint sfl; - CharPtr strfrmt = LuaLCheckLString(L, arg, out sfl); - CharPtr strfrmt_end = strfrmt + sfl; - LuaLBuffer b = new LuaLBuffer(L); - LuaLBuffInit(L, b); - while (strfrmt < strfrmt_end) - { - if (strfrmt[0] != L_ESC) - { - LuaLAddChar(b, strfrmt[0]); - strfrmt = strfrmt.next(); - } - else if (strfrmt[1] == L_ESC) - { - LuaLAddChar(b, strfrmt[0]); /* %% */ - strfrmt = strfrmt + 2; - } - else - { /* format item */ - strfrmt = strfrmt.next(); - CharPtr form = new char[MAX_FORMAT]; /* to store the format (`%...') */ - CharPtr buff = new char[MAX_ITEM]; /* to store the formatted item */ - if (++arg > top) - LuaLArgError(L, arg, "no value"); - strfrmt = scanformat(L, strfrmt, form); - char ch = strfrmt[0]; - strfrmt = strfrmt.next(); - switch (ch) - { - case 'c': - { - sprintf(buff, form, (int)LuaLCheckNumber(L, arg)); - break; - } - case 'd': - case 'i': - { - addintlen(form); - sprintf(buff, form, (LUA_INTFRM_T)LuaLCheckNumber(L, arg)); - break; - } - case 'o': - case 'u': - case 'x': - case 'X': - { - addintlen(form); - sprintf(buff, form, (UNSIGNED_LUA_INTFRM_T)LuaLCheckNumber(L, arg)); - break; - } - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - { - sprintf(buff, form, (double)LuaLCheckNumber(L, arg)); - break; - } - case 'q': - { - addquoted(L, b, arg); - continue; /* skip the 'addsize' at the end */ - } - case 's': - { - uint l; - CharPtr s = LuaLCheckLString(L, arg, out l); - if ((strchr(form, '.') == null) && l >= 100) - { - /* no precision and string is too long to be formatted; - keep original string */ - LuaPushValue(L, arg); - LuaLAddValue(b); - continue; /* skip the `addsize' at the end */ - } - else - { - sprintf(buff, form, s); - break; - } - } - default: - { /* also treat cases `pnLlh' */ - return LuaLError(L, "invalid option " + LUA_QL("%" + ch) + " to " + - LUA_QL("format"), strfrmt[-1]); - } - } - LuaLAddLString(b, buff, (uint)strlen(buff)); - } - } - LuaLPushResult(b); - return 1; - } - - - private static string PatchPattern(string charPtr) - { - return charPtr.Replace("\0", "%z"); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/StringRange.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/StringRange.cs deleted file mode 100644 index 34169fc7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringLib/StringRange.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - - -namespace MoonSharp.Interpreter.CoreLib.StringLib -{ - internal class StringRange - { - public int Start { get; set; } - public int End { get; set; } - - public StringRange() - { - Start = 0; - End = 0; - } - - public StringRange(int start, int end) - { - Start = start; - End = end; - } - - public static StringRange FromLuaRange(DynValue start, DynValue end, int? defaultEnd = null) - { - int i = start.IsNil() ? 1 : (int)start.Number; - int j = end.IsNil() ? (defaultEnd ?? i) : (int)end.Number; - - return new StringRange(i, j); - } - - - // Returns the substring of s that starts at i and continues until j; i and j can be negative. - // If, after the translation of negative indices, i is less than 1, it is corrected to 1. - // If j is greater than the string length, it is corrected to that length. - // If, after these corrections, i is greater than j, the function returns the empty string. - public string ApplyToString(string value) - { - int i = Start < 0 ? Start + value.Length + 1 : Start; - int j = End < 0 ? End + value.Length + 1 : End; - - if (i < 1) i = 1; - if (j > value.Length) j = value.Length; - - if (i > j) - return string.Empty; - - return value.Substring(i - 1, j - i + 1); - } - - public int Length() - { - return (End - Start) + 1; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringModule.cs deleted file mode 100644 index bdfc8e49..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/StringModule.cs +++ /dev/null @@ -1,298 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.IO; -using System.Text; -using MoonSharp.Interpreter.CoreLib.StringLib; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing string Lua functions - /// - [MoonSharpModule(Namespace = "string")] - public class StringModule - { - public const string BASE64_DUMP_HEADER = "MoonSharp_dump_b64::"; - - public static void MoonSharpInit(Table globalTable, Table stringTable) - { - Table stringMetatable = new Table(globalTable.OwnerScript); - stringMetatable.Set("__index", DynValue.NewTable(stringTable)); - globalTable.OwnerScript.SetTypeMetatable(DataType.String, stringMetatable); - } - - - [MoonSharpModuleMethod] - public static DynValue dump(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue fn = args.AsType(0, "dump", DataType.Function, false); - - try - { - byte[] bytes; - using (MemoryStream ms = new MemoryStream()) - { - executionContext.GetScript().Dump(fn, ms); - ms.Seek(0, SeekOrigin.Begin); - bytes = ms.ToArray(); - } - string base64 = Convert.ToBase64String(bytes); - return DynValue.NewString(BASE64_DUMP_HEADER + base64); - } - catch (Exception ex) - { - throw new ScriptRuntimeException(ex.Message); - } - } - - - [MoonSharpModuleMethod] - public static DynValue @char(ScriptExecutionContext executionContext, CallbackArguments args) - { - StringBuilder sb = new StringBuilder(args.Count); - - for (int i = 0; i < args.Count; i++) - { - DynValue v = args[i]; - double d = 0d; - - if (v.Type == DataType.String) - { - double? nd = v.CastToNumber(); - if (nd == null) - args.AsType(i, "char", DataType.Number, false); - else - d = nd.Value; - } - else - { - args.AsType(i, "char", DataType.Number, false); - d = v.Number; - } - - sb.Append((char)(d)); - } - - return DynValue.NewString(sb.ToString()); - } - - - [MoonSharpModuleMethod] - public static DynValue @byte(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vs = args.AsType(0, "byte", DataType.String, false); - DynValue vi = args.AsType(1, "byte", DataType.Number, true); - DynValue vj = args.AsType(2, "byte", DataType.Number, true); - - return PerformByteLike(vs, vi, vj, - i => Unicode2Ascii(i)); - } - - [MoonSharpModuleMethod] - public static DynValue unicode(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vs = args.AsType(0, "unicode", DataType.String, false); - DynValue vi = args.AsType(1, "unicode", DataType.Number, true); - DynValue vj = args.AsType(2, "unicode", DataType.Number, true); - - return PerformByteLike(vs, vi, vj, i => i); - } - - private static int Unicode2Ascii(int i) - { - if (i >= 0 && i < 255) - return i; - - return (int)'?'; - } - - private static DynValue PerformByteLike(DynValue vs, DynValue vi, DynValue vj, Func filter) - { - StringRange range = StringRange.FromLuaRange(vi, vj, null); - string s = range.ApplyToString(vs.String); - - int length = s.Length; - DynValue[] rets = new DynValue[length]; - - for (int i = 0; i < length; ++i) - { - rets[i] = DynValue.NewNumber(filter((int)s[i])); - } - - return DynValue.NewTuple(rets); - } - - - private static int? AdjustIndex(string s, DynValue vi, int defval) - { - if (vi.IsNil()) - return defval; - - int i = (int)Math.Round(vi.Number, 0); - - if (i == 0) - return null; - - if (i > 0) - return i - 1; - - return s.Length - i; - } - - [MoonSharpModuleMethod] - public static DynValue len(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vs = args.AsType(0, "len", DataType.String, false); - return DynValue.NewNumber(vs.String.Length); - } - - - - [MoonSharpModuleMethod] - public static DynValue match(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "match", KopiLua_StringLib.str_match); - } - - - [MoonSharpModuleMethod] - public static DynValue gmatch(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "gmatch", KopiLua_StringLib.str_gmatch); - } - - [MoonSharpModuleMethod] - public static DynValue gsub(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "gsub", KopiLua_StringLib.str_gsub); - } - - [MoonSharpModuleMethod] - public static DynValue find(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "find", - KopiLua_StringLib.str_find); - } - - - [MoonSharpModuleMethod] - public static DynValue lower(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s = args.AsType(0, "lower", DataType.String, false); - return DynValue.NewString(arg_s.String.ToLower()); - } - - [MoonSharpModuleMethod] - public static DynValue upper(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s = args.AsType(0, "upper", DataType.String, false); - return DynValue.NewString(arg_s.String.ToUpper()); - } - - [MoonSharpModuleMethod] - public static DynValue rep(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s = args.AsType(0, "rep", DataType.String, false); - DynValue arg_n = args.AsType(1, "rep", DataType.Number, false); - DynValue arg_sep = args.AsType(2, "rep", DataType.String, true); - - if (String.IsNullOrEmpty(arg_s.String) || (arg_n.Number < 1)) - { - return DynValue.NewString(""); - } - - string sep = (arg_sep.IsNotNil()) ? arg_sep.String : null; - - int count = (int)arg_n.Number; - StringBuilder result = new StringBuilder(arg_s.String.Length * count); - - for (int i = 0; i < count; ++i) - { - if (i != 0 && sep != null) - result.Append(sep); - - result.Append(arg_s.String); - } - - return DynValue.NewString(result.ToString()); - } - - [MoonSharpModuleMethod] - public static DynValue format(ScriptExecutionContext executionContext, CallbackArguments args) - { - return executionContext.EmulateClassicCall(args, "format", KopiLua_StringLib.str_format); - } - - - - [MoonSharpModuleMethod] - public static DynValue reverse(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s = args.AsType(0, "reverse", DataType.String, false); - - if (String.IsNullOrEmpty(arg_s.String)) - { - return DynValue.NewString(""); - } - - char[] elements = arg_s.String.ToCharArray(); - Array.Reverse(elements); - - return DynValue.NewString(new String(elements)); - } - - [MoonSharpModuleMethod] - public static DynValue sub(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s = args.AsType(0, "sub", DataType.String, false); - DynValue arg_i = args.AsType(1, "sub", DataType.Number, true); - DynValue arg_j = args.AsType(2, "sub", DataType.Number, true); - - StringRange range = StringRange.FromLuaRange(arg_i, arg_j, -1); - string s = range.ApplyToString(arg_s.String); - - return DynValue.NewString(s); - } - - [MoonSharpModuleMethod] - public static DynValue startsWith(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s1 = args.AsType(0, "startsWith", DataType.String, true); - DynValue arg_s2 = args.AsType(1, "startsWith", DataType.String, true); - - if (arg_s1.IsNil() || arg_s2.IsNil()) - return DynValue.False; - - return DynValue.NewBoolean(arg_s1.String.StartsWith(arg_s2.String)); - } - - [MoonSharpModuleMethod] - public static DynValue endsWith(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s1 = args.AsType(0, "endsWith", DataType.String, true); - DynValue arg_s2 = args.AsType(1, "endsWith", DataType.String, true); - - if (arg_s1.IsNil() || arg_s2.IsNil()) - return DynValue.False; - - return DynValue.NewBoolean(arg_s1.String.EndsWith(arg_s2.String)); - } - - [MoonSharpModuleMethod] - public static DynValue contains(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue arg_s1 = args.AsType(0, "contains", DataType.String, true); - DynValue arg_s2 = args.AsType(1, "contains", DataType.String, true); - - if (arg_s1.IsNil() || arg_s2.IsNil()) - return DynValue.False; - - return DynValue.NewBoolean(arg_s1.String.Contains(arg_s2.String)); - } - - } - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableIteratorsModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableIteratorsModule.cs deleted file mode 100644 index 6e3b84fe..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableIteratorsModule.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing table Lua iterators (pairs, ipairs, next) - /// - [MoonSharpModule] - public class TableIteratorsModule - { - // ipairs (t) - // ------------------------------------------------------------------------------------------------------------------- - // If t has a metamethod __ipairs, calls it with t as argument and returns the first three results from the call. - // Otherwise, returns three values: an iterator function, the table t, and 0, so that the construction - // for i,v in ipairs(t) do body end - // will iterate over the pairs (1,t[1]), (2,t[2]), ..., up to the first integer key absent from the table. - [MoonSharpModuleMethod] - public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args[0]; - - DynValue meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray()); - - return meta ?? DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0)); - } - - // pairs (t) - // ------------------------------------------------------------------------------------------------------------------- - // If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call. - // Otherwise, returns three values: the next function, the table t, and nil, so that the construction - // for k,v in pairs(t) do body end - // will iterate over all key–value pairs of table t. - // See function next for the caveats of modifying the table during its traversal. - [MoonSharpModuleMethod] - public static DynValue pairs(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args[0]; - - DynValue meta = executionContext.GetMetamethodTailCall(table, "__pairs", args.GetArray()); - - return meta ?? DynValue.NewTuple(DynValue.NewCallback(next), table); - } - - // next (table [, index]) - // ------------------------------------------------------------------------------------------------------------------- - // Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an - // index in this table. next returns the next index of the table and its associated value. - // When called with nil as its second argument, next returns an initial index and its associated value. - // When called with the last index, or with nil in an empty table, next returns nil. If the second argument is absent, - // then it is interpreted as nil. In particular, you can use next(t) to check whether a table is empty. - // The order in which the indices are enumerated is not specified, even for numeric indices. - // (To traverse a table in numeric order, use a numerical for.) - // The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. - // You may however modify existing fields. In particular, you may clear existing fields. - [MoonSharpModuleMethod] - public static DynValue next(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args.AsType(0, "next", DataType.Table); - DynValue index = args[1]; - - TablePair? pair = table.Table.NextKey(index); - - if (pair.HasValue) - return DynValue.NewTuple(pair.Value.Key, pair.Value.Value); - else - throw new ScriptRuntimeException("invalid key to 'next'"); - } - - // __next_i (table [, index]) - // ------------------------------------------------------------------------------------------------------------------- - // Allows a program to traverse all fields of an array. index is an integer number - public static DynValue __next_i(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue table = args.AsType(0, "!!next_i!!", DataType.Table); - DynValue index = args.AsType(1, "!!next_i!!", DataType.Number); - - int idx = ((int)index.Number) + 1; - DynValue val = table.Table.Get(idx); - - if (val.Type != DataType.Nil) - { - return DynValue.NewTuple(DynValue.NewNumber(idx), val); - } - else - { - return DynValue.Nil; - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableModule.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableModule.cs deleted file mode 100644 index 1f623a06..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/CoreLib/TableModule.cs +++ /dev/null @@ -1,292 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using System.Collections.Generic; -using System.Text; - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Class implementing table Lua functions - /// - [MoonSharpModule(Namespace = "table")] - public class TableModule - { - [MoonSharpModuleMethod] - public static DynValue unpack(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue s = args.AsType(0, "unpack", DataType.Table, false); - DynValue vi = args.AsType(1, "unpack", DataType.Number, true); - DynValue vj = args.AsType(2, "unpack", DataType.Number, true); - - int ii = vi.IsNil() ? 1 : (int)vi.Number; - int ij = vj.IsNil() ? GetTableLength(executionContext, s) : (int)vj.Number; - - Table t = s.Table; - - DynValue[] v = new DynValue[ij - ii + 1]; - - int tidx = 0; - for (int i = ii; i <= ij; i++) - v[tidx++] = t.Get(i); - - return DynValue.NewTuple(v); - } - - [MoonSharpModuleMethod] - public static DynValue pack(ScriptExecutionContext executionContext, CallbackArguments args) - { - Table t = new Table(executionContext.GetScript()); - DynValue v = DynValue.NewTable(t); - - for (int i = 0; i < args.Count; i++) - t.Set(i + 1, args[i]); - - t.Set("n", DynValue.NewNumber(args.Count)); - - return v; - } - - [MoonSharpModuleMethod] - public static DynValue sort(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vlist = args.AsType(0, "sort", DataType.Table, false); - DynValue lt = args[1]; - - if (lt.Type != DataType.Function && lt.Type != DataType.ClrFunction && lt.IsNotNil()) - args.AsType(1, "sort", DataType.Function, true); // this throws - - int end = GetTableLength(executionContext, vlist); - - List values = new List(); - - for (int i = 1; i <= end; i++) - values.Add(vlist.Table.Get(i)); - - try - { - values.Sort((a, b) => SortComparer(executionContext, a, b, lt)); - } - catch (InvalidOperationException ex) - { - if (ex.InnerException is ScriptRuntimeException) - throw ex.InnerException; - } - - for (int i = 0; i < values.Count; i++) - { - vlist.Table.Set(i + 1, values[i]); - } - - return vlist; - } - - private static int SortComparer(ScriptExecutionContext executionContext, DynValue a, DynValue b, DynValue lt) - { - if (lt == null || lt.IsNil()) - { - lt = executionContext.GetBinaryMetamethod(a, b, "__lt"); - - if (lt == null || lt.IsNil()) - { - if (a.Type == DataType.Number && b.Type == DataType.Number) - return a.Number.CompareTo(b.Number); - if (a.Type == DataType.String && b.Type == DataType.String) - return a.String.CompareTo(b.String); - - throw ScriptRuntimeException.CompareInvalidType(a, b); - } - else - { - return LuaComparerToClrComparer( - executionContext.GetScript().Call(lt, a, b), - executionContext.GetScript().Call(lt, b, a)); - } - } - else - { - return LuaComparerToClrComparer( - executionContext.GetScript().Call(lt, a, b), - executionContext.GetScript().Call(lt, b, a)); - } - } - - private static int LuaComparerToClrComparer(DynValue dynValue1, DynValue dynValue2) - { - bool v1 = dynValue1.CastToBool(); - bool v2 = dynValue2.CastToBool(); - - if (v1 && !v2) - return -1; - if (v2 && !v1) - return 1; - - if (v1 || v2) - throw new ScriptRuntimeException("invalid order function for sorting"); - - return 0; - } - - [MoonSharpModuleMethod] - public static DynValue insert(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vlist = args.AsType(0, "table.insert", DataType.Table, false); - DynValue vpos = args[1]; - DynValue vvalue = args[2]; - - if (args.Count > 3) - throw new ScriptRuntimeException("wrong number of arguments to 'insert'"); - - int len = GetTableLength(executionContext, vlist); - Table list = vlist.Table; - - if (vvalue.IsNil()) - { - vvalue = vpos; - vpos = DynValue.NewNumber(len + 1); - } - - if (vpos.Type != DataType.Number) - throw ScriptRuntimeException.BadArgument(1, "table.insert", DataType.Number, vpos.Type, false); - - int pos = (int)vpos.Number; - - if (pos > len + 1 || pos < 1) - throw new ScriptRuntimeException("bad argument #2 to 'insert' (position out of bounds)"); - - for (int i = len; i >= pos; i--) - { - list.Set(i + 1, list.Get(i)); - } - - list.Set(pos, vvalue); - - return vlist; - } - - - [MoonSharpModuleMethod] - public static DynValue remove(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vlist = args.AsType(0, "table.remove", DataType.Table, false); - DynValue vpos = args.AsType(1, "table.remove", DataType.Number, true); - DynValue ret = DynValue.Nil; - - if (args.Count > 2) - throw new ScriptRuntimeException("wrong number of arguments to 'remove'"); - - int len = GetTableLength(executionContext, vlist); - Table list = vlist.Table; - - int pos = vpos.IsNil() ? len : (int)vpos.Number; - - if (pos >= len + 1 || (pos < 1 && len > 0)) - throw new ScriptRuntimeException("bad argument #1 to 'remove' (position out of bounds)"); - - for (int i = pos; i <= len; i++) - { - if (i == pos) - ret = list.Get(i); - - list.Set(i, list.Get(i + 1)); - } - - return ret; - } - - - //table.concat (list [, sep [, i [, j]]]) - //Given a list where all elements are strings or numbers, returns the string list[i]..sep..list[i+1] (...) sep..list[j]. - //The default value for sep is the empty string, the default for i is 1, and the default for j is #list. If i is greater - //than j, returns the empty string. - [MoonSharpModuleMethod] - public static DynValue concat(ScriptExecutionContext executionContext, CallbackArguments args) - { - DynValue vlist = args.AsType(0, "concat", DataType.Table, false); - DynValue vsep = args.AsType(1, "concat", DataType.String, true); - DynValue vstart = args.AsType(2, "concat", DataType.Number, true); - DynValue vend = args.AsType(3, "concat", DataType.Number, true); - - Table list = vlist.Table; - string sep = vsep.IsNil() ? "" : vsep.String; - int start = vstart.IsNilOrNan() ? 1 : (int)vstart.Number; - int end; - - if (vend.IsNilOrNan()) - { - end = GetTableLength(executionContext, vlist); - } - else - { - end = (int)vend.Number; - } - - if (end < start) - return DynValue.NewString(string.Empty); - - StringBuilder sb = new StringBuilder(); - - for (int i = start; i <= end; i++) - { - DynValue v = list.Get(i); - - if (v.Type != DataType.Number && v.Type != DataType.String) - throw new ScriptRuntimeException("invalid value ({1}) at index {0} in table for 'concat'", i, v.Type.ToLuaTypeString()); - - string s = v.ToPrintString(); - - if (i != start) - sb.Append(sep); - - sb.Append(s); - - } - - return DynValue.NewString(sb.ToString()); - } - - private static int GetTableLength(ScriptExecutionContext executionContext, DynValue vlist) - { - DynValue __len = executionContext.GetMetamethod(vlist, "__len"); - - if (__len != null) - { - DynValue lenv = executionContext.GetScript().Call(__len, vlist); - - double? len = lenv.CastToNumber(); - - if (len == null) - throw new ScriptRuntimeException("object length is not a number"); - - return (int)len; - } - else - { - return (int)vlist.Table.Length; - } - } - } - - - /// - /// Class exposing table.unpack and table.pack in the global namespace (to work around the most common Lua 5.1 compatibility issue). - /// - [MoonSharpModule] - public class TableModule_Globals - { - [MoonSharpModuleMethod] - public static DynValue unpack(ScriptExecutionContext executionContext, CallbackArguments args) - { - return TableModule.unpack(executionContext, args); - } - - [MoonSharpModuleMethod] - public static DynValue pack(ScriptExecutionContext executionContext, CallbackArguments args) - { - return TableModule.pack(executionContext, args); - } - } - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Extension_Methods.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Extension_Methods.cs deleted file mode 100644 index e2176f81..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Extension_Methods.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter -{ - /// - /// Extension methods used in the whole project. - /// - internal static class Extension_Methods - { - /// - /// Gets a value from the dictionary or returns the default value - /// - /// The type of the key. - /// The type of the value. - /// The dictionary. - /// The key. - /// - public static TValue GetOrDefault(this Dictionary dictionary, TKey key) - { - TValue v; - - if (dictionary.TryGetValue(key, out v)) - return v; - - return default(TValue); - } - - - /// - /// Gets a value from the dictionary or creates it - /// - /// The type of the key. - /// The type of the value. - /// The dictionary. - /// The key. - /// A function which will create the value if it doesn't exist. - /// - public static TValue GetOrCreate(this Dictionary dictionary, TKey key, Func creator) - { - TValue v; - - if (!dictionary.TryGetValue(key, out v)) - { - v = creator(); - dictionary.Add(key, v); - } - - return v; - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStack.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStack.cs deleted file mode 100644 index f9dbf83c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStack.cs +++ /dev/null @@ -1,179 +0,0 @@ -#if !USE_DYNAMIC_STACKS - -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ - /// - /// A preallocated, non-resizable, stack - /// - /// - internal class FastStack : IList - { - T[] m_Storage; - int m_HeadIdx = 0; - - public FastStack(int maxCapacity) - { - m_Storage = new T[maxCapacity]; - } - - public T this[int index] - { - get { return m_Storage[index]; } - set { m_Storage[index] = value; } - } - - public T Push(T item) - { - m_Storage[m_HeadIdx++] = item; - return item; - } - - public void Expand(int size) - { - m_HeadIdx += size; - } - - private void Zero(int from, int to) - { - Array.Clear(m_Storage, from, to - from + 1); - } - - private void Zero(int index) - { - m_Storage[index] = default(T); - } - - public T Peek(int idxofs = 0) - { - T item = m_Storage[m_HeadIdx - 1 - idxofs]; - return item; - } - - public void Set(int idxofs, T item) - { - m_Storage[m_HeadIdx - 1 - idxofs] = item; - } - - public void CropAtCount(int p) - { - RemoveLast(Count - p); - } - - public void RemoveLast( int cnt = 1) - { - if (cnt == 1) - { - --m_HeadIdx; - m_Storage[m_HeadIdx] = default(T); - } - else - { - int oldhead = m_HeadIdx; - m_HeadIdx -= cnt; - Zero(m_HeadIdx, oldhead); - } - } - - public T Pop() - { - --m_HeadIdx; - T retval = m_Storage[m_HeadIdx]; - m_Storage[m_HeadIdx] = default(T); - return retval; - } - - public void Clear() - { - Array.Clear(m_Storage, 0, m_Storage.Length); - m_HeadIdx = 0; - } - - public int Count - { - get { return m_HeadIdx; } - } - - - #region IList Impl. - - int IList.IndexOf(T item) - { - throw new NotImplementedException(); - } - - void IList.Insert(int index, T item) - { - throw new NotImplementedException(); - } - - void IList.RemoveAt(int index) - { - throw new NotImplementedException(); - } - - T IList.this[int index] - { - get - { - return this[index]; - } - set - { - this[index] = value; - } - } - - void ICollection.Add(T item) - { - Push(item); - } - - void ICollection.Clear() - { - Clear(); - } - - bool ICollection.Contains(T item) - { - throw new NotImplementedException(); - } - - void ICollection.CopyTo(T[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - int ICollection.Count - { - get { return this.Count; } - } - - bool ICollection.IsReadOnly - { - get { return false; } - } - - bool ICollection.Remove(T item) - { - throw new NotImplementedException(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } - - #endregion - - } -} - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStackDynamic.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStackDynamic.cs deleted file mode 100644 index 00c54f8b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/FastStackDynamic.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ -#if USE_DYNAMIC_STACKS - internal class FastStack : FastStackDynamic - { - public FastStack(int startingCapacity) - : base(startingCapacity) - { - } - } -#endif - - /// - /// A non preallocated, non_fixed size stack - /// - /// - internal class FastStackDynamic : List - { - public FastStackDynamic(int startingCapacity) - : base(startingCapacity) - { - } - - - public void Set(int idxofs, T item) - { - this[this.Count - 1 - idxofs] = item; - } - - - public T Push(T item) - { - this.Add(item); - return item; - } - - public void Expand(int size) - { - for(int i = 0; i < size; i++) - this.Add(default(T)); - } - - public void Zero(int index) - { - this[index] = default(T); - } - - public T Peek(int idxofs = 0) - { - T item = this[this.Count - 1 - idxofs]; - return item; - } - public void CropAtCount(int p) - { - RemoveLast(Count - p); - } - - public void RemoveLast( int cnt = 1) - { - if (cnt == 1) - { - this.RemoveAt(this.Count - 1); - } - else - { - this.RemoveRange(this.Count - cnt, cnt); - } - } - - public T Pop() - { - T retval = this[this.Count - 1]; - this.RemoveAt(this.Count - 1); - return retval; - } - } -} - - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/LinkedListIndex.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/LinkedListIndex.cs deleted file mode 100644 index 58d41595..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/LinkedListIndex.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ - /// - /// An index to accelerate operations on a LinkedList using a single key of type - /// More than one LinkedListIndex can index the same linked list, but every node in the linked list must be indexed by one and only one - /// LinkedListIndex object. - /// - /// The type of the key. Must implement Equals and GetHashCode appropriately. - /// The type of the values contained in the linked list. - internal class LinkedListIndex - { - LinkedList m_LinkedList; - Dictionary> m_Map = null; - - /// - /// Initializes a new instance of the class. - /// - /// The linked list to be indexed. - public LinkedListIndex(LinkedList linkedList) - { - m_LinkedList = linkedList; - } - - /// - /// Finds the node indexed by the specified key, or null. - /// - /// The key. - public LinkedListNode Find(TKey key) - { - LinkedListNode node; - - if (m_Map == null) - return null; - - if (m_Map.TryGetValue(key, out node)) - return node; - - return null; - } - - /// - /// Updates or creates a new node in the linked list, indexed by the specified key. - /// - /// The key. - /// The value. - /// The previous value of the element - public TValue Set(TKey key, TValue value) - { - LinkedListNode node = Find(key); - - if (node == null) - { - Add(key, value); - return default(TValue); - } - else - { - TValue val = node.Value; - node.Value = value; - return val; - } - } - - /// - /// Creates a new node in the linked list, indexed by the specified key. - /// - /// The key. - /// The value. - public void Add(TKey key, TValue value) - { - var node = m_LinkedList.AddLast(value); - - if (m_Map == null) - m_Map = new Dictionary>(); - - m_Map.Add(key, node); - } - - /// - /// Removes the specified key from the index, and the node indexed by the key from the linked list. - /// - /// The key. - public bool Remove(TKey key) - { - LinkedListNode node = Find(key); - - if (node != null) - { - m_LinkedList.Remove(node); - return m_Map.Remove(key); - } - - return false; - } - - - /// - /// Determines whether the index contains the specified key. - /// - /// The key. - public bool ContainsKey(TKey key) - { - if (m_Map == null) - return false; - - return m_Map.ContainsKey(key); - } - - /// - /// Clears this instance (removes all elements) - /// - public void Clear() - { - if(m_Map != null) - m_Map.Clear(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/MultiDictionary.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/MultiDictionary.cs deleted file mode 100644 index 925b7b8e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/MultiDictionary.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ - /// - /// A Dictionary where multiple values can be associated to the same key - /// - /// The key type - /// The value type - internal class MultiDictionary - { - Dictionary> m_Map; - V[] m_DefaultRet = new V[0]; - - /// - /// Initializes a new instance of the class. - /// - public MultiDictionary() - { - m_Map = new Dictionary>(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The equality comparer to use in the underlying dictionary. - public MultiDictionary(IEqualityComparer eqComparer) - { - m_Map = new Dictionary>(eqComparer); - } - - - /// - /// Adds the specified key. Returns true if this is the first value for a given key - /// - /// The key. - /// The value. - /// - public bool Add(K key, V value) - { - List list; - if (m_Map.TryGetValue(key, out list)) - { - list.Add(value); - return false; - } - else - { - list = new List(); - list.Add(value); - m_Map.Add(key, list); - return true; - } - } - - /// - /// Finds all the values associated with the specified key. - /// An empty collection is returned if not found. - /// - /// The key. - public IEnumerable Find(K key) - { - List list; - if (m_Map.TryGetValue(key, out list)) - return list; - else - return m_DefaultRet; - } - - /// - /// Determines whether this contains the specified key - /// - /// The key. - public bool ContainsKey(K key) - { - return m_Map.ContainsKey(key); - } - - /// - /// Gets the keys. - /// - public IEnumerable Keys - { - get { return m_Map.Keys; } - } - - /// - /// Clears this instance. - /// - public void Clear() - { - m_Map.Clear(); - } - - /// - /// Removes the specified key and all its associated values from the multidictionary - /// - /// The key. - public void Remove(K key) - { - m_Map.Remove(key); - } - - /// - /// Removes the value. Returns true if the removed value was the last of a given key - /// - /// The key. - /// The value. - /// - public bool RemoveValue(K key, V value) - { - List list; - - if (m_Map.TryGetValue(key, out list)) - { - list.Remove(value); - - if (list.Count == 0) - { - Remove(key); - return true; - } - } - - return false; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/ReferenceEqualityComparer.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/ReferenceEqualityComparer.cs deleted file mode 100644 index 13ea0b57..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/ReferenceEqualityComparer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.DataStructs -{ - /// - /// Implementation of IEqualityComparer enforcing reference equality - /// - internal class ReferenceEqualityComparer : IEqualityComparer - { - bool IEqualityComparer.Equals(object x, object y) - { - return object.ReferenceEquals(x, y); - } - - int IEqualityComparer.GetHashCode(object obj) - { - return obj.GetHashCode(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Slice.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Slice.cs deleted file mode 100644 index 0150fa0f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataStructs/Slice.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.DataStructs -{ - /// - /// Provides facility to create a "sliced" view over an existing IList - /// - /// The type of the items contained in the collection - internal class Slice : IEnumerable, IList - { - IList m_SourceList; - int m_From, m_Length; - bool m_Reversed; - - /// - /// Initializes a new instance of the class. - /// - /// The list to apply the Slice view on - /// From which index - /// The length of the slice - /// if set to true the view is in reversed order. - public Slice(IList list, int from, int length, bool reversed) - { - m_SourceList = list; - m_From = from; - m_Length = length; - m_Reversed = reversed; - } - - /// - /// Gets or sets the element at the specified index. - /// - /// The index. - /// - public T this[int index] - { - get - { - return m_SourceList[CalcRealIndex(index)]; - } - set - { - m_SourceList[CalcRealIndex(index)] = value; - } - } - - /// - /// Gets the index from which the slice starts - /// - public int From - { - get { return m_From; } - } - - /// - /// Gets the number of elements contained in the . - /// - /// The number of elements contained in the . - public int Count - { - get { return m_Length; } - } - - /// - /// Gets a value indicating whether this operates in a reversed direction. - /// - /// - /// true if this operates in a reversed direction; otherwise, false. - /// - public bool Reversed - { - get { return m_Reversed; } - } - - /// - /// Calculates the real index in the underlying collection - /// - private int CalcRealIndex(int index) - { - if (index < 0 || index >= m_Length) - throw new ArgumentOutOfRangeException("index"); - - if (m_Reversed) - { - return m_From + m_Length - index - 1; - } - else - { - return m_From + index; - } - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// - /// A that can be used to iterate through the collection. - /// - public IEnumerator GetEnumerator() - { - for (int i = 0; i < m_Length; i++) - yield return m_SourceList[CalcRealIndex(i)]; - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// - /// An object that can be used to iterate through the collection. - /// - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - for (int i = 0; i < m_Length; i++) - yield return m_SourceList[CalcRealIndex(i)]; - } - - /// - /// Converts to an array. - /// - public T[] ToArray() - { - T[] array = new T[m_Length]; - - for (int i = 0; i < m_Length; i++) - array[i] = m_SourceList[CalcRealIndex(i)]; - - return array; - } - - /// - /// Converts to an list. - /// - public List ToList() - { - List list = new List(m_Length); - - for (int i = 0; i < m_Length; i++) - list.Add(m_SourceList[CalcRealIndex(i)]); - - return list; - } - - - /// - /// Determines the index of a specific item in the . - /// - /// The object to locate in the . - /// - /// The index of if found in the list; otherwise, -1. - /// - public int IndexOf(T item) - { - for (int i = 0; i < this.Count; i++) - { - if (this[i].Equals(item)) - return i; - } - return -1; - } - - /// - /// Inserts an item to the at the specified index. - /// - /// The zero-based index at which should be inserted. - /// The object to insert into the . - /// Slices are readonly - public void Insert(int index, T item) - { - throw new InvalidOperationException("Slices are readonly"); - } - - /// - /// Removes the item at the specified index. - /// - /// The zero-based index of the item to remove. - /// Slices are readonly - public void RemoveAt(int index) - { - throw new InvalidOperationException("Slices are readonly"); - } - - /// - /// Adds an item to the . - /// - /// The object to add to the . - /// Slices are readonly - public void Add(T item) - { - throw new InvalidOperationException("Slices are readonly"); - } - - /// - /// Removes all items from the . - /// - /// Slices are readonly - public void Clear() - { - throw new InvalidOperationException("Slices are readonly"); - } - - /// - /// Determines whether the contains a specific value. - /// - /// The object to locate in the . - /// - /// true if is found in the ; otherwise, false. - /// - public bool Contains(T item) - { - return IndexOf(item) >= 0; - } - - /// - /// Copies to. - /// - /// The array. - /// Index of the array. - public void CopyTo(T[] array, int arrayIndex) - { - for (int i = 0; i < Count; i++) - array[i + arrayIndex] = this[i]; - } - - /// - /// Gets a value indicating whether the is read-only. - /// - /// true if the is read-only; otherwise, false. - public bool IsReadOnly - { - get { return true; } - } - - /// - /// Removes the first occurrence of a specific object from the . - /// - /// The object to remove from the . - /// - /// true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original . - /// - /// Slices are readonly - public bool Remove(T item) - { - throw new InvalidOperationException("Slices are readonly"); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackArguments.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackArguments.cs deleted file mode 100644 index 435bac90..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackArguments.cs +++ /dev/null @@ -1,226 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.DataStructs; - -namespace MoonSharp.Interpreter -{ - /// - /// This class is a container for arguments received by a CallbackFunction - /// - public class CallbackArguments - { - IList m_Args; - int m_Count; - bool m_LastIsTuple = false; - - /// - /// Initializes a new instance of the class. - /// - /// The arguments. - /// if set to true [is method call]. - public CallbackArguments(IList args, bool isMethodCall) - { - m_Args = args; - - if (m_Args.Count > 0) - { - var last = m_Args[m_Args.Count - 1]; - - if (last.Type == DataType.Tuple) - { - m_Count = last.Tuple.Length - 1 + m_Args.Count; - m_LastIsTuple = true; - } - else if (last.Type == DataType.Void) - { - m_Count = m_Args.Count - 1; - } - else - { - m_Count = m_Args.Count; - } - } - else - { - m_Count = 0; - } - - IsMethodCall = isMethodCall; - } - - /// - /// Gets the count of arguments - /// - public int Count - { - get { return m_Count; } - } - - /// - /// Gets or sets a value indicating whether this is a method call. - /// - public bool IsMethodCall { get; private set; } - - - /// - /// Gets the at the specified index, or Void if not found - /// - public DynValue this[int index] - { - get - { - return RawGet(index, true) ?? DynValue.Void; - } - } - - /// - /// Gets the at the specified index, or null. - /// - /// The index. - /// if set to true all voids are translated to nils. - /// - public DynValue RawGet(int index, bool translateVoids) - { - DynValue v; - - if (index >= m_Count) - return null; - - if (!m_LastIsTuple || index < m_Args.Count - 1) - v = m_Args[index]; - else - v = m_Args[m_Args.Count - 1].Tuple[index - (m_Args.Count - 1)]; - - if (v.Type == DataType.Tuple) - { - if (v.Tuple.Length > 0) - v = v.Tuple[0]; - else - v = DynValue.Nil; - } - - if (translateVoids && v.Type == DataType.Void) - { - v = DynValue.Nil; - } - - return v; - } - - - /// - /// Converts the arguments to an array - /// - /// The number of elements to skip (default= 0). - /// - public DynValue[] GetArray(int skip = 0) - { - if (skip >= m_Count) - return new DynValue[0]; - - DynValue[] vals = new DynValue[m_Count - skip]; - - for (int i = skip; i < m_Count; i++) - vals[i - skip] = this[i]; - - return vals; - } - - /// - /// Gets the specified argument as as an argument of the specified type. If not possible, - /// an exception is raised. - /// - /// The argument number. - /// Name of the function. - /// The type desired. - /// if set to true nil values are allowed. - /// - public DynValue AsType(int argNum, string funcName, DataType type, bool allowNil = false) - { - return this[argNum].CheckType(funcName, type, argNum, allowNil ? TypeValidationFlags.AllowNil | TypeValidationFlags.AutoConvert : TypeValidationFlags.AutoConvert); - } - - /// - /// Gets the specified argument as as an argument of the specified user data type. If not possible, - /// an exception is raised. - /// - /// The desired userdata type - /// The argument number. - /// Name of the function. - /// if set to true nil values are allowed. - /// - public T AsUserData(int argNum, string funcName, bool allowNil = false) - { - return this[argNum].CheckUserDataType(funcName, argNum, allowNil ? TypeValidationFlags.AllowNil : TypeValidationFlags.None); - } - - /// - /// Gets the specified argument as an integer - /// - /// The argument number. - /// Name of the function. - /// - public int AsInt(int argNum, string funcName) - { - DynValue v = AsType(argNum, funcName, DataType.Number, false); - double d = v.Number; - return (int)d; - } - - /// - /// Gets the specified argument as a long integer - /// - /// The argument number. - /// Name of the function. - /// - public long AsLong(int argNum, string funcName) - { - DynValue v = AsType(argNum, funcName, DataType.Number, false); - double d = v.Number; - return (long)d; - } - - - /// - /// Gets the specified argument as a string, calling the __tostring metamethod if needed, in a NON - /// yield-compatible way. - /// - /// The execution context. - /// The argument number. - /// Name of the function. - /// - /// 'tostring' must return a string to '{0}' - public string AsStringUsingMeta(ScriptExecutionContext executionContext, int argNum, string funcName) - { - if ((this[argNum].Type == DataType.Table) && (this[argNum].Table.MetaTable != null) && - (this[argNum].Table.MetaTable.RawGet("__tostring") != null)) - { - var v = executionContext.GetScript().Call(this[argNum].Table.MetaTable.RawGet("__tostring"), this[argNum]); - - if (v.Type != DataType.String) - throw new ScriptRuntimeException("'tostring' must return a string to '{0}'", funcName); - - return v.ToPrintString(); - } - else - { - return (this[argNum].ToPrintString()); - } - } - - - /// - /// Returns a copy of CallbackArguments where the first ("self") argument is skipped if this was a method call, - /// otherwise returns itself. - /// - /// - public CallbackArguments SkipMethodCall() - { - if (this.IsMethodCall) - { - Slice slice = new Slice(m_Args, 1, m_Args.Count - 1, false); - return new CallbackArguments(slice, false); - } - else return this; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackFunction.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackFunction.cs deleted file mode 100755 index 33e68c4a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CallbackFunction.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Interop; -using System.Reflection; - -namespace MoonSharp.Interpreter -{ - /// - /// This class wraps a CLR function - /// - public sealed class CallbackFunction : RefIdObject - { - private static InteropAccessMode m_DefaultAccessMode = InteropAccessMode.LazyOptimized; - - /// - /// Gets the name of the function - /// - public string Name { get; private set; } - - /// - /// Gets the call back. - /// - /// - /// The call back. - /// - public Func ClrCallback { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The callback function to be called. - /// The callback name, used in stacktraces, debugger, etc.. - public CallbackFunction(Func callBack, string name = null) - { - ClrCallback = callBack; - Name = name; - } - - /// - /// Invokes the callback function - /// - /// The execution context. - /// The arguments. - /// if set to true this is a method call. - /// - public DynValue Invoke(ScriptExecutionContext executionContext, IList args, bool isMethodCall = false) - { - if (isMethodCall) - { - var colon = executionContext.GetScript().Options.ColonOperatorClrCallbackBehaviour; - - if (colon == ColonOperatorBehaviour.TreatAsColon) - isMethodCall = false; - else if (colon == ColonOperatorBehaviour.TreatAsDotOnUserData) - isMethodCall = (args.Count > 0 && args[0].Type == DataType.UserData); - } - - return ClrCallback(executionContext, new CallbackArguments(args, isMethodCall)); - } - - /// - /// Gets or sets the default access mode used when marshalling delegates - /// - /// - /// The default access mode. Default, HideMembers and BackgroundOptimized are NOT supported. - /// - /// Default, HideMembers and BackgroundOptimized are NOT supported. - public static InteropAccessMode DefaultAccessMode - { - get { return m_DefaultAccessMode; } - set - { - if (value == InteropAccessMode.Default || value == InteropAccessMode.HideMembers || value == InteropAccessMode.BackgroundOptimized) - throw new ArgumentException("DefaultAccessMode"); - - m_DefaultAccessMode = value; - } - } - - /// - /// Creates a CallbackFunction from a delegate. - /// - /// The script. - /// The delegate. - /// The access mode. - /// - public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default) - { - if (accessMode == InteropAccessMode.Default) - accessMode = m_DefaultAccessMode; - -#if NETFX_CORE - MethodMemberDescriptor descr = new MethodMemberDescriptor(del.GetMethodInfo(), accessMode); -#else - MethodMemberDescriptor descr = new MethodMemberDescriptor(del.Method, accessMode); -#endif - return descr.GetCallbackFunction(script, del.Target); - } - - - /// - /// Creates a CallbackFunction from a MethodInfo relative to a function. - /// - /// The script. - /// The MethodInfo object. - /// The object to which the function applies, or null for static methods. - /// The access mode. - /// - /// The method is not static. - public static CallbackFunction FromMethodInfo(Script script, System.Reflection.MethodInfo mi, object obj = null, InteropAccessMode accessMode = InteropAccessMode.Default) - { - if (accessMode == InteropAccessMode.Default) - accessMode = m_DefaultAccessMode; - - MethodMemberDescriptor descr = new MethodMemberDescriptor(mi, accessMode); - return descr.GetCallbackFunction(script, obj); - } - - - - /// - /// Gets or sets an object used as additional data to the callback function (available in the execution context). - /// - public object AdditionalData { get; set; } - - - /// - /// Checks the callback signature of a method is compatible for callbacks - /// - public static bool CheckCallbackSignature(System.Reflection.MethodInfo mi, bool requirePublicVisibility) - { - System.Reflection.ParameterInfo[] pi = mi.GetParameters(); - - return (pi.Length == 2 && pi[0].ParameterType == typeof(ScriptExecutionContext) - && pi[1].ParameterType == typeof(CallbackArguments) && mi.ReturnType == typeof(DynValue) && (requirePublicVisibility || mi.IsPublic)); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Closure.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Closure.cs deleted file mode 100644 index 0ed8e705..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Closure.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter -{ - /// - /// A class representing a script function - /// - public class Closure : RefIdObject, IScriptPrivateResource - { - /// - /// Type of closure based on upvalues - /// - public enum UpvaluesType - { - /// - /// The closure has no upvalues (thus, technically, it's a function and not a closure!) - /// - None, - /// - /// The closure has _ENV as its only upvalue - /// - Environment, - /// - /// The closure is a "real" closure, with multiple upvalues - /// - Closure - } - - - /// - /// Gets the entry point location in bytecode . - /// - public int EntryPointByteCodeLocation { get; private set; } - - - /// - /// Gets the script owning this function - /// - public Script OwnerScript { get; private set; } - - - /// - /// Shortcut for an empty closure - /// - private static ClosureContext emptyClosure = new ClosureContext(); - - /// - /// The current closure context - /// - internal ClosureContext ClosureContext { get; private set; } - - - /// - /// Initializes a new instance of the class. - /// - /// The script. - /// The index. - /// The symbols. - /// The resolved locals. - internal Closure(Script script, int idx, SymbolRef[] symbols, IEnumerable resolvedLocals) - { - OwnerScript = script; - - EntryPointByteCodeLocation = idx; - - if (symbols.Length > 0) - ClosureContext = new ClosureContext(symbols, resolvedLocals); - else - ClosureContext = emptyClosure; - } - - /// - /// Calls this function with the specified args - /// - /// - /// Thrown if function is not of DataType.Function - public DynValue Call() - { - return OwnerScript.Call(this); - } - - /// - /// Calls this function with the specified args - /// - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(params object[] args) - { - return OwnerScript.Call(this, args); - } - - /// - /// Calls this function with the specified args - /// - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(params DynValue[] args) - { - return OwnerScript.Call(this, args); - } - - - /// - /// Gets a delegate wrapping calls to this scripted function - /// - /// - public ScriptFunctionDelegate GetDelegate() - { - return args => this.Call(args).ToObject(); - } - - /// - /// Gets a delegate wrapping calls to this scripted function - /// - /// The type of return value of the delegate. - /// - public ScriptFunctionDelegate GetDelegate() - { - return args => this.Call(args).ToObject(); - } - - /// - /// Gets the number of upvalues in this closure - /// - /// The number of upvalues in this closure - public int GetUpvaluesCount() - { - return ClosureContext.Count; - } - - /// - /// Gets the name of the specified upvalue. - /// - /// The index of the upvalue. - /// The upvalue name - public string GetUpvalueName(int idx) - { - return ClosureContext.Symbols[idx]; - } - - /// - /// Gets the value of an upvalue. To set the value, use GetUpvalue(idx).Assign(...); - /// - /// The index of the upvalue. - /// The value of an upvalue - public DynValue GetUpvalue(int idx) - { - return ClosureContext[idx]; - } - - /// - /// Gets the type of the upvalues contained in this closure - /// - /// - public UpvaluesType GetUpvaluesType() - { - int count = GetUpvaluesCount(); - - if (count == 0) - return UpvaluesType.None; - else if (count == 1 && GetUpvalueName(0) == WellKnownSymbols.ENV) - return UpvaluesType.Environment; - else - return UpvaluesType.Closure; - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Coroutine.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Coroutine.cs deleted file mode 100755 index c1b37b58..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Coroutine.cs +++ /dev/null @@ -1,291 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter -{ - /// - /// A class representing a script coroutine - /// - public class Coroutine : RefIdObject, IScriptPrivateResource - { - /// - /// Possible types of coroutine - /// - public enum CoroutineType - { - /// - /// A valid coroutine - /// - Coroutine, - /// - /// A CLR callback assigned to a coroutine. - /// - ClrCallback, - /// - /// A CLR callback assigned to a coroutine and already executed. - /// - ClrCallbackDead - } - - /// - /// Gets the type of coroutine - /// - public CoroutineType Type { get; private set; } - - private CallbackFunction m_ClrCallback; - private Processor m_Processor; - - - internal Coroutine(CallbackFunction function) - { - Type = CoroutineType.ClrCallback; - m_ClrCallback = function; - OwnerScript = null; - } - - internal Coroutine(Processor proc) - { - Type = CoroutineType.Coroutine; - m_Processor = proc; - m_Processor.AssociatedCoroutine = this; - OwnerScript = proc.GetScript(); - } - - internal void MarkClrCallbackAsDead() - { - if (Type != CoroutineType.ClrCallback) - throw new InvalidOperationException("State must be CoroutineType.ClrCallback"); - - Type = CoroutineType.ClrCallbackDead; - } - - - /// - /// Gets this coroutine as a typed enumerable which can be looped over for resuming. - /// Returns its result as DynValue(s) - /// - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public IEnumerable AsTypedEnumerable() - { - if (Type != CoroutineType.Coroutine) - throw new InvalidOperationException("Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead"); - - while (this.State == CoroutineState.NotStarted || this.State == CoroutineState.Suspended || this.State == CoroutineState.ForceSuspended) - yield return Resume(); - } - - - /// - /// Gets this coroutine as a typed enumerable which can be looped over for resuming. - /// Returns its result as System.Object. Only the first element of tuples is returned. - /// Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - /// - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public IEnumerable AsEnumerable() - { - foreach(DynValue v in AsTypedEnumerable()) - { - yield return v.ToScalar().ToObject(); - } - } - - /// - /// Gets this coroutine as a typed enumerable which can be looped over for resuming. - /// Returns its result as the specified type. Only the first element of tuples is returned. - /// Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - /// - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public IEnumerable AsEnumerable() - { - foreach(DynValue v in AsTypedEnumerable()) - { - yield return v.ToScalar().ToObject(); - } - } - - /// - /// The purpose of this method is to convert a MoonSharp/Lua coroutine to a Unity3D coroutine. - /// This loops over the coroutine, discarding returned values, and returning null for each invocation. - /// This means however that the coroutine will be invoked each frame. - /// Only non-CLR coroutines can be resumed with this method. Use an overload of the Resume method accepting a ScriptExecutionContext instead. - /// - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public System.Collections.IEnumerator AsUnityCoroutine() - { -#pragma warning disable 0219 - foreach (DynValue v in AsTypedEnumerable()) - { - yield return null; - } -#pragma warning restore 0219 - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// The arguments. - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public DynValue Resume(params DynValue[] args) - { - this.CheckScriptOwnership(args); - - if (Type == CoroutineType.Coroutine) - return m_Processor.Coroutine_Resume(args); - else - throw new InvalidOperationException("Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead"); - } - - - /// - /// Resumes the coroutine. - /// - /// The ScriptExecutionContext. - /// The arguments. - /// - public DynValue Resume(ScriptExecutionContext context, params DynValue[] args) - { - this.CheckScriptOwnership(context); - this.CheckScriptOwnership(args); - - if (Type == CoroutineType.Coroutine) - return m_Processor.Coroutine_Resume(args); - else if (Type == CoroutineType.ClrCallback) - { - DynValue ret = m_ClrCallback.Invoke(context, args); - MarkClrCallbackAsDead(); - return ret; - } - else - throw ScriptRuntimeException.CannotResumeNotSuspended(CoroutineState.Dead); - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead - public DynValue Resume() - { - return Resume(new DynValue[0]); - } - - - /// - /// Resumes the coroutine. - /// - /// The ScriptExecutionContext. - /// - public DynValue Resume(ScriptExecutionContext context) - { - return Resume(context, new DynValue[0]); - } - - /// - /// Resumes the coroutine. - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - /// - /// The arguments. - /// - /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead. - public DynValue Resume(params object[] args) - { - if (Type != CoroutineType.Coroutine) - throw new InvalidOperationException("Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead"); - - DynValue[] dargs = new DynValue[args.Length]; - - for (int i = 0; i < dargs.Length; i++) - dargs[i] = DynValue.FromObject(this.OwnerScript, args[i]); - - return Resume(dargs); - } - - - /// - /// Resumes the coroutine - /// - /// The ScriptExecutionContext. - /// The arguments. - /// - public DynValue Resume(ScriptExecutionContext context, params object[] args) - { - DynValue[] dargs = new DynValue[args.Length]; - - for (int i = 0; i < dargs.Length; i++) - dargs[i] = DynValue.FromObject(context.GetScript(), args[i]); - - return Resume(context, dargs); - } - - - - - /// - /// Gets the coroutine state. - /// - public CoroutineState State - { - get - { - if (Type == CoroutineType.ClrCallback) - return CoroutineState.NotStarted; - else if (Type == CoroutineType.ClrCallbackDead) - return CoroutineState.Dead; - else - return m_Processor.State; - } - } - - /// - /// Gets the coroutine stack trace for debug purposes - /// - /// The skip. - /// The entry source reference. - /// - public WatchItem[] GetStackTrace(int skip, SourceRef entrySourceRef = null) - { - if (this.State != CoroutineState.Running) - { - entrySourceRef = m_Processor.GetCoroutineSuspendedLocation(); - } - - List stack = m_Processor.Debugger_GetCallStack(entrySourceRef); - return stack.Skip(skip).ToArray(); - } - - /// - /// Gets the script owning this resource. - /// - /// - /// The script owning this resource. - /// - /// - public Script OwnerScript - { - get; - private set; - } - - /// - /// Gets or sets the automatic yield counter. - /// - /// - /// The automatic yield counter. - /// - public long AutoYieldCounter - { - get { return m_Processor.AutoYieldCounter; } - set { m_Processor.AutoYieldCounter = value; } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CoroutineState.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CoroutineState.cs deleted file mode 100644 index 029b8893..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/CoroutineState.cs +++ /dev/null @@ -1,34 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// State of coroutines - /// - public enum CoroutineState - { - /// - /// This is the main coroutine - /// - Main, - /// - /// Coroutine has not started yet - /// - NotStarted, - /// - /// Coroutine is suspended - /// - Suspended, - /// - /// Coroutine has been forcefully suspended (i.e. auto-yielded) - /// - ForceSuspended, - /// - /// Coroutine is running - /// - Running, - /// - /// Coroutine has terminated - /// - Dead - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DataType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DataType.cs deleted file mode 100644 index 46694a6e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DataType.cs +++ /dev/null @@ -1,175 +0,0 @@ - - -namespace MoonSharp.Interpreter -{ - /// - /// Enumeration of possible data types in MoonSharp - /// - public enum DataType - { - // DO NOT MODIFY ORDER - IT'S SIGNIFICANT - - /// - /// A nil value, as in Lua - /// - Nil, - /// - /// A place holder for no value - /// - Void, - /// - /// A Lua boolean - /// - Boolean, - /// - /// A Lua number - /// - Number, - /// - /// A Lua string - /// - String, - /// - /// A Lua function - /// - Function, - - /// - /// A Lua table - /// - Table, - /// - /// A set of multiple values - /// - Tuple, - /// - /// A userdata reference - that is a wrapped CLR object - /// - UserData, - /// - /// A coroutine handle - /// - Thread, - - /// - /// A callback function - /// - ClrFunction, - - /// - /// A request to execute a tail call - /// - TailCallRequest, - /// - /// A request to coroutine.yield - /// - YieldRequest, - } - - /// - /// Extension methods to DataType - /// - public static class LuaTypeExtensions - { - internal const DataType MaxMetaTypes = DataType.Table; - internal const DataType MaxConvertibleTypes = DataType.ClrFunction; - - /// - /// Determines whether this data type can have type metatables. - /// - /// The type. - /// - public static bool CanHaveTypeMetatables(this DataType type) - { - return (int)type < (int)MaxMetaTypes; - } - - /// - /// Converts the DataType to the string returned by the "type(...)" Lua function - /// - /// The type. - /// - /// The DataType is not a Lua type - public static string ToErrorTypeString(this DataType type) - { - switch (type) - { - case DataType.Void: - return "no value"; - case DataType.Nil: - return "nil"; - case DataType.Boolean: - return "boolean"; - case DataType.Number: - return "number"; - case DataType.String: - return "string"; - case DataType.Function: - return "function"; - case DataType.ClrFunction: - return "function"; - case DataType.Table: - return "table"; - case DataType.UserData: - return "userdata"; - case DataType.Thread: - return "coroutine"; - case DataType.Tuple: - case DataType.TailCallRequest: - case DataType.YieldRequest: - default: - return string.Format("internal<{0}>", type.ToLuaDebuggerString()); - } - } - - /// - /// Converts the DataType to the string returned by the "type(...)" Lua function, with additional values - /// to support debuggers - /// - /// The type. - /// - /// The DataType is not a Lua type - public static string ToLuaDebuggerString(this DataType type) - { - return type.ToString().ToLowerInvariant(); - } - - - /// - /// Converts the DataType to the string returned by the "type(...)" Lua function - /// - /// The type. - /// - /// The DataType is not a Lua type - public static string ToLuaTypeString(this DataType type) - { - switch (type) - { - case DataType.Void: - case DataType.Nil: - return "nil"; - case DataType.Boolean: - return "boolean"; - case DataType.Number: - return "number"; - case DataType.String: - return "string"; - case DataType.Function: - return "function"; - case DataType.ClrFunction: - return "function"; - case DataType.Table: - return "table"; - case DataType.UserData: - return "userdata"; - case DataType.Thread: - return "thread"; - case DataType.Tuple: - case DataType.TailCallRequest: - case DataType.YieldRequest: - default: - throw new ScriptRuntimeException("Unexpected LuaType {0}", type); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DynValue.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DynValue.cs deleted file mode 100644 index c3f631a4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/DynValue.cs +++ /dev/null @@ -1,969 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter -{ - /// - /// A class representing a value in a Lua/MoonSharp script. - /// - public sealed class DynValue - { - static int s_RefIDCounter = 0; - - private int m_RefID = ++s_RefIDCounter; - private int m_HashCode = -1; - - private bool m_ReadOnly; - private double m_Number; - private object m_Object; - private DataType m_Type; - - - /// - /// Gets a unique reference identifier. This is guaranteed to be unique only for dynvalues created in a single thread as it's not thread-safe. - /// - public int ReferenceID { get { return m_RefID; } } - - /// - /// Gets the type of the value. - /// - public DataType Type { get { return m_Type; } } - /// - /// Gets the function (valid only if the is ) - /// - public Closure Function { get { return m_Object as Closure; } } - /// - /// Gets the numeric value (valid only if the is ) - /// - public double Number { get { return m_Number; } } - /// - /// Gets the values in the tuple (valid only if the is Tuple). - /// This field is currently also used to hold arguments in values whose is . - /// - public DynValue[] Tuple { get { return m_Object as DynValue[]; } } - /// - /// Gets the coroutine handle. (valid only if the is Thread). - /// - public Coroutine Coroutine { get { return m_Object as Coroutine; } } - /// - /// Gets the table (valid only if the is ) - /// - public Table Table { get { return m_Object as Table; } } - /// - /// Gets the boolean value (valid only if the is ) - /// - public bool Boolean { get { return Number != 0; } } - /// - /// Gets the string value (valid only if the is ) - /// - public string String { get { return m_Object as string; } } - /// - /// Gets the CLR callback (valid only if the is ) - /// - public CallbackFunction Callback { get { return m_Object as CallbackFunction; } } - /// - /// Gets the tail call data. - /// - public TailCallData TailCallData { get { return m_Object as TailCallData; } } - /// - /// Gets the yield request data. - /// - public YieldRequest YieldRequest { get { return m_Object as YieldRequest; } } - /// - /// Gets the tail call data. - /// - public UserData UserData { get { return m_Object as UserData; } } - - /// - /// Returns true if this instance is write protected. - /// - public bool ReadOnly { get { return m_ReadOnly; } } - - - - /// - /// Creates a new writable value initialized to Nil. - /// - public static DynValue NewNil() - { - return new DynValue(); - } - - /// - /// Creates a new writable value initialized to the specified boolean. - /// - public static DynValue NewBoolean(bool v) - { - return new DynValue() - { - m_Number = v ? 1 : 0, - m_Type = DataType.Boolean, - }; - } - - /// - /// Creates a new writable value initialized to the specified number. - /// - public static DynValue NewNumber(double num) - { - return new DynValue() - { - m_Number = num, - m_Type = DataType.Number, - m_HashCode = -1, - }; - } - - /// - /// Creates a new writable value initialized to the specified string. - /// - public static DynValue NewString(string str) - { - return new DynValue() - { - m_Object = str, - m_Type = DataType.String, - }; - } - - /// - /// Creates a new writable value initialized to the specified StringBuilder. - /// - public static DynValue NewString(StringBuilder sb) - { - return new DynValue() - { - m_Object = sb.ToString(), - m_Type = DataType.String, - }; - } - - /// - /// Creates a new writable value initialized to the specified string using String.Format like syntax - /// - public static DynValue NewString(string format, params object[] args) - { - return new DynValue() - { - m_Object = string.Format(format, args), - m_Type = DataType.String, - }; - } - - /// - /// Creates a new writable value initialized to the specified coroutine. - /// Internal use only, for external use, see Script.CoroutineCreate - /// - /// The coroutine object. - /// - public static DynValue NewCoroutine(Coroutine coroutine) - { - return new DynValue() - { - m_Object = coroutine, - m_Type = DataType.Thread - }; - } - - /// - /// Creates a new writable value initialized to the specified closure (function). - /// - public static DynValue NewClosure(Closure function) - { - return new DynValue() - { - m_Object = function, - m_Type = DataType.Function, - }; - } - - /// - /// Creates a new writable value initialized to the specified CLR callback. - /// - public static DynValue NewCallback(Func callBack, string name = null) - { - return new DynValue() - { - m_Object = new CallbackFunction(callBack, name), - m_Type = DataType.ClrFunction, - }; - } - - /// - /// Creates a new writable value initialized to the specified CLR callback. - /// See also CallbackFunction.FromDelegate and CallbackFunction.FromMethodInfo factory methods. - /// - public static DynValue NewCallback(CallbackFunction function) - { - return new DynValue() - { - m_Object = function, - m_Type = DataType.ClrFunction, - }; - } - - /// - /// Creates a new writable value initialized to the specified table. - /// - public static DynValue NewTable(Table table) - { - return new DynValue() - { - m_Object = table, - m_Type = DataType.Table, - }; - } - - /// - /// Creates a new writable value initialized to an empty prime table (a - /// prime table is a table made only of numbers, strings, booleans and other - /// prime tables). - /// - public static DynValue NewPrimeTable() - { - return NewTable(new Table(null)); - } - - /// - /// Creates a new writable value initialized to an empty table. - /// - public static DynValue NewTable(Script script) - { - return NewTable(new Table(script)); - } - - /// - /// Creates a new writable value initialized to with array contents. - /// - public static DynValue NewTable(Script script, params DynValue[] arrayValues) - { - return NewTable(new Table(script, arrayValues)); - } - - /// - /// Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - /// although it's not always possible to use it. When a function (callback or script closure) returns a - /// TailCallRequest, the bytecode processor immediately executes the function contained in the request. - /// By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - /// of functionality (state savings, coroutines, etc) keeps working at full power. - /// - /// The function to be called. - /// The arguments. - /// - public static DynValue NewTailCallReq(DynValue tailFn, params DynValue[] args) - { - return new DynValue() - { - m_Object = new TailCallData() - { - Args = args, - Function = tailFn, - }, - m_Type = DataType.TailCallRequest, - }; - } - - /// - /// Creates a new request for a tail call. This is the preferred way to execute Lua/MoonSharp code from a callback, - /// although it's not always possible to use it. When a function (callback or script closure) returns a - /// TailCallRequest, the bytecode processor immediately executes the function contained in the request. - /// By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number - /// of functionality (state savings, coroutines, etc) keeps working at full power. - /// - /// The data for the tail call. - /// - public static DynValue NewTailCallReq(TailCallData tailCallData) - { - return new DynValue() - { - m_Object = tailCallData, - m_Type = DataType.TailCallRequest, - }; - } - - - - /// - /// Creates a new request for a yield of the current coroutine. - /// - /// The yield argumenst. - /// - public static DynValue NewYieldReq(DynValue[] args) - { - return new DynValue() - { - m_Object = new YieldRequest() { ReturnValues = args }, - m_Type = DataType.YieldRequest, - }; - } - - /// - /// Creates a new request for a yield of the current coroutine. - /// - /// The yield argumenst. - /// - internal static DynValue NewForcedYieldReq() - { - return new DynValue() - { - m_Object = new YieldRequest() { Forced = true }, - m_Type = DataType.YieldRequest, - }; - } - - /// - /// Creates a new tuple initialized to the specified values. - /// - public static DynValue NewTuple(params DynValue[] values) - { - if (values.Length == 0) - return DynValue.NewNil(); - - if (values.Length == 1) - return values[0]; - - return new DynValue() - { - m_Object = values, - m_Type = DataType.Tuple, - }; - } - - /// - /// Creates a new tuple initialized to the specified values - which can be potentially other tuples - /// - public static DynValue NewTupleNested(params DynValue[] values) - { - if (!values.Any(v => v.Type == DataType.Tuple)) - return NewTuple(values); - - if (values.Length == 1) - return values[0]; - - List vals = new List(); - - foreach (var v in values) - { - if (v.Type == DataType.Tuple) - vals.AddRange(v.Tuple); - else - vals.Add(v); - } - - return new DynValue() - { - m_Object = vals.ToArray(), - m_Type = DataType.Tuple, - }; - } - - - /// - /// Creates a new userdata value - /// - public static DynValue NewUserData(UserData userData) - { - return new DynValue() - { - m_Object = userData, - m_Type = DataType.UserData, - }; - } - - /// - /// Returns this value as readonly - eventually cloning it in the process if it isn't readonly to start with. - /// - public DynValue AsReadOnly() - { - if (ReadOnly) - return this; - else - { - return Clone(true); - } - } - - /// - /// Clones this instance. - /// - /// - public DynValue Clone() - { - return Clone(this.ReadOnly); - } - - /// - /// Clones this instance, overriding the "readonly" status. - /// - /// if set to true the new instance is set as readonly, or writeable otherwise. - /// - public DynValue Clone(bool readOnly) - { - DynValue v = new DynValue(); - v.m_Object = this.m_Object; - v.m_Number = this.m_Number; - v.m_HashCode = this.m_HashCode; - v.m_Type = this.m_Type; - v.m_ReadOnly = readOnly; - return v; - } - - /// - /// Clones this instance, returning a writable copy. - /// - /// Can't clone Symbol values - public DynValue CloneAsWritable() - { - return Clone(false); - } - - - /// - /// A preinitialized, readonly instance, equaling Void - /// - public static DynValue Void { get; private set; } - /// - /// A preinitialized, readonly instance, equaling Nil - /// - public static DynValue Nil { get; private set; } - /// - /// A preinitialized, readonly instance, equaling True - /// - public static DynValue True { get; private set; } - /// - /// A preinitialized, readonly instance, equaling False - /// - public static DynValue False { get; private set; } - - - static DynValue() - { - Nil = new DynValue() { m_Type = DataType.Nil }.AsReadOnly(); - Void = new DynValue() { m_Type = DataType.Void }.AsReadOnly(); - True = DynValue.NewBoolean(true).AsReadOnly(); - False = DynValue.NewBoolean(false).AsReadOnly(); - } - - - /// - /// Returns a string which is what it's expected to be output by the print function applied to this value. - /// - public string ToPrintString() - { - if (this.m_Object != null && this.m_Object is RefIdObject) - { - RefIdObject refid = (RefIdObject)m_Object; - - string typeString = this.Type.ToLuaTypeString(); - - if (m_Object is UserData) - { - UserData ud = (UserData)m_Object; - string str = ud.Descriptor.AsString(ud.Object); - if (str != null) - return str; - } - - return refid.FormatTypeString(typeString); - } - - switch (Type) - { - case DataType.String: - return String; - case DataType.Tuple: - return string.Join("\t", Tuple.Select(t => t.ToPrintString()).ToArray()); - case DataType.TailCallRequest: - return "(TailCallRequest -- INTERNAL!)"; - case DataType.YieldRequest: - return "(YieldRequest -- INTERNAL!)"; - default: - return ToString(); - } - } - - /// - /// Returns a string which is what it's expected to be output by debuggers. - /// - public string ToDebugPrintString() - { - if (this.m_Object != null && this.m_Object is RefIdObject) - { - RefIdObject refid = (RefIdObject)m_Object; - - string typeString = this.Type.ToLuaTypeString(); - - if (m_Object is UserData) - { - UserData ud = (UserData)m_Object; - string str = ud.Descriptor.AsString(ud.Object); - if (str != null) - return str; - } - - return refid.FormatTypeString(typeString); - } - - switch (Type) - { - case DataType.Tuple: - return string.Join("\t", Tuple.Select(t => t.ToPrintString()).ToArray()); - case DataType.TailCallRequest: - return "(TailCallRequest)"; - case DataType.YieldRequest: - return "(YieldRequest)"; - default: - return ToString(); - } - } - - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - switch (Type) - { - case DataType.Void: - return "void"; - case DataType.Nil: - return "nil"; - case DataType.Boolean: - return Boolean.ToString().ToLower(); - case DataType.Number: - return Number.ToString(CultureInfo.InvariantCulture); - case DataType.String: - return "\"" + String + "\""; - case DataType.Function: - return string.Format("(Function {0:X8})", Function.EntryPointByteCodeLocation); - case DataType.ClrFunction: - return string.Format("(Function CLR)", Function); - case DataType.Table: - return "(Table)"; - case DataType.Tuple: - return string.Join(", ", Tuple.Select(t => t.ToString()).ToArray()); - case DataType.TailCallRequest: - return "Tail:(" + string.Join(", ", Tuple.Select(t => t.ToString()).ToArray()) + ")"; - case DataType.UserData: - return "(UserData)"; - case DataType.Thread: - return string.Format("(Coroutine {0:X8})", this.Coroutine.ReferenceID); - default: - return "(???)"; - } - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - if (m_HashCode != -1) - return m_HashCode; - - int baseValue = ((int)(Type)) << 27; - - switch (Type) - { - case DataType.Void: - case DataType.Nil: - m_HashCode = 0; - break; - case DataType.Boolean: - m_HashCode = Boolean ? 1 : 2; - break; - case DataType.Number: - m_HashCode = baseValue ^ Number.GetHashCode(); - break; - case DataType.String: - m_HashCode = baseValue ^ String.GetHashCode(); - break; - case DataType.Function: - m_HashCode = baseValue ^ Function.GetHashCode(); - break; - case DataType.ClrFunction: - m_HashCode = baseValue ^ Callback.GetHashCode(); - break; - case DataType.Table: - m_HashCode = baseValue ^ Table.GetHashCode(); - break; - case DataType.Tuple: - case DataType.TailCallRequest: - m_HashCode = baseValue ^ Tuple.GetHashCode(); - break; - case DataType.UserData: - case DataType.Thread: - default: - m_HashCode = 999; - break; - } - - return m_HashCode; - } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - DynValue other = obj as DynValue; - - if (other == null) return false; - - if ((other.Type == DataType.Nil && this.Type == DataType.Void) - || (other.Type == DataType.Void && this.Type == DataType.Nil)) - return true; - - if (other.Type != this.Type) return false; - - - switch (Type) - { - case DataType.Void: - case DataType.Nil: - return true; - case DataType.Boolean: - return Boolean == other.Boolean; - case DataType.Number: - return Number == other.Number; - case DataType.String: - return String == other.String; - case DataType.Function: - return Function == other.Function; - case DataType.ClrFunction: - return Callback == other.Callback; - case DataType.Table: - return Table == other.Table; - case DataType.Tuple: - case DataType.TailCallRequest: - return Tuple == other.Tuple; - case DataType.Thread: - return Coroutine == other.Coroutine; - case DataType.UserData: - { - UserData ud1 = this.UserData; - UserData ud2 = other.UserData; - - if (ud1 == null || ud2 == null) - return false; - - if (ud1.Descriptor != ud2.Descriptor) - return false; - - if (ud1.Object == null && ud2.Object == null) - return true; - - if (ud1.Object != null && ud2.Object != null) - return ud1.Object.Equals(ud2.Object); - - return false; - } - default: - return object.ReferenceEquals(this, other); - } - } - - - /// - /// Casts this DynValue to string, using coercion if the type is number. - /// - /// The string representation, or null if not number, not string. - public string CastToString() - { - DynValue rv = ToScalar(); - if (rv.Type == DataType.Number) - { - return rv.Number.ToString(); - } - else if (rv.Type == DataType.String) - { - return rv.String; - } - return null; - } - - /// - /// Casts this DynValue to a double, using coercion if the type is string. - /// - /// The string representation, or null if not number, not string or non-convertible-string. - public double? CastToNumber() - { - DynValue rv = ToScalar(); - if (rv.Type == DataType.Number) - { - return rv.Number; - } - else if (rv.Type == DataType.String) - { - double num; - if (double.TryParse(rv.String, NumberStyles.Any, CultureInfo.InvariantCulture, out num)) - return num; - } - return null; - } - - - /// - /// Casts this DynValue to a bool - /// - /// False if value is false or nil, true otherwise. - public bool CastToBool() - { - DynValue rv = ToScalar(); - if (rv.Type == DataType.Boolean) - return rv.Boolean; - else return (rv.Type != DataType.Nil && rv.Type != DataType.Void); - } - - /// - /// Returns this DynValue as an instance of , if possible, - /// null otherwise - /// - /// False if value is false or nil, true otherwise. - public IScriptPrivateResource GetAsPrivateResource() - { - return m_Object as IScriptPrivateResource; - } - - - /// - /// Converts a tuple to a scalar value. If it's already a scalar value, this function returns "this". - /// - public DynValue ToScalar() - { - if (Type != DataType.Tuple) - return this; - - if (Tuple.Length == 0) - return DynValue.Void; - - return Tuple[0].ToScalar(); - } - - /// - /// Performs an assignment, overwriting the value with the specified one. - /// - /// The value. - /// If the value is readonly. - public void Assign(DynValue value) - { - if (this.ReadOnly) - throw new ScriptRuntimeException("Assigning on r-value"); - - this.m_Number = value.m_Number; - this.m_Object = value.m_Object; - this.m_Type = value.Type; - this.m_HashCode = -1; - } - - - - /// - /// Gets the length of a string or table value. - /// - /// - /// Value is not a table or string. - public DynValue GetLength() - { - if (this.Type == DataType.Table) - return DynValue.NewNumber(this.Table.Length); - if (this.Type == DataType.String) - return DynValue.NewNumber(this.String.Length); - - throw new ScriptRuntimeException("Can't get length of type {0}", this.Type); - } - - /// - /// Determines whether this instance is nil or void - /// - public bool IsNil() - { - return this.Type == DataType.Nil || this.Type == DataType.Void; - } - - /// - /// Determines whether this instance is not nil or void - /// - public bool IsNotNil() - { - return this.Type != DataType.Nil && this.Type != DataType.Void; - } - - /// - /// Determines whether this instance is void - /// - public bool IsVoid() - { - return this.Type == DataType.Void; - } - - /// - /// Determines whether this instance is not void - /// - public bool IsNotVoid() - { - return this.Type != DataType.Void; - } - - /// - /// Determines whether is nil, void or NaN (and thus unsuitable for using as a table key). - /// - public bool IsNilOrNan() - { - return (this.Type == DataType.Nil) || (this.Type == DataType.Void) || (this.Type == DataType.Number && double.IsNaN(this.Number)); - } - - /// - /// Changes the numeric value of a number DynValue. - /// - internal void AssignNumber(double num) - { - if (this.ReadOnly) - throw new InternalErrorException(null, "Writing on r-value"); - - if (this.Type != DataType.Number) - throw new InternalErrorException("Can't assign number to type {0}", this.Type); - - this.m_Number = num; - } - - /// - /// Creates a new DynValue from a CLR object - /// - /// The script. - /// The object. - /// - public static DynValue FromObject(Script script, object obj) - { - return MoonSharp.Interpreter.Interop.Converters.ClrToScriptConversions.ObjectToDynValue(script, obj); - } - - /// - /// Converts this MoonSharp DynValue to a CLR object. - /// - public object ToObject() - { - return MoonSharp.Interpreter.Interop.Converters.ScriptToClrConversions.DynValueToObject(this); - } - - /// - /// Converts this MoonSharp DynValue to a CLR object of the specified type. - /// - public object ToObject(Type desiredType) - { - //Contract.Requires(desiredType != null); - return MoonSharp.Interpreter.Interop.Converters.ScriptToClrConversions.DynValueToObjectOfType(this, desiredType, null, false); - } - - /// - /// Converts this MoonSharp DynValue to a CLR object of the specified type. - /// - public T ToObject() - { - return (T)ToObject(typeof(T)); - } - -#if HASDYNAMIC - /// - /// Converts this MoonSharp DynValue to a CLR object, marked as dynamic - /// - public dynamic ToDynamic() - { - return MoonSharp.Interpreter.Interop.Converters.ScriptToClrConversions.DynValueToObject(this); - } -#endif - - /// - /// Checks the type of this value corresponds to the desired type. A propert ScriptRuntimeException is thrown - /// if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - /// to the specified type. - /// - /// Name of the function requesting the value, for error message purposes. - /// The desired data type. - /// The argument number, for error message purposes. - /// The TypeValidationFlags. - /// - /// Thrown - /// if the value is not of the specified type or - considering the TypeValidationFlags - is not convertible - /// to the specified type. - public DynValue CheckType(string funcName, DataType desiredType, int argNum = -1, TypeValidationFlags flags = TypeValidationFlags.Default) - { - if (this.Type == desiredType) - return this; - - bool allowNil = ((int)(flags & TypeValidationFlags.AllowNil) != 0); - - if (allowNil && this.IsNil()) - return this; - - bool autoConvert = ((int)(flags & TypeValidationFlags.AutoConvert) != 0); - - if (autoConvert) - { - if (desiredType == DataType.Boolean) - return DynValue.NewBoolean(this.CastToBool()); - - if (desiredType == DataType.Number) - { - double? v = this.CastToNumber(); - if (v.HasValue) - return DynValue.NewNumber(v.Value); - } - - if (desiredType == DataType.String) - { - string v = this.CastToString(); - if (v != null) - return DynValue.NewString(v); - } - } - - if (this.IsVoid()) - throw ScriptRuntimeException.BadArgumentNoValue(argNum, funcName, desiredType); - - throw ScriptRuntimeException.BadArgument(argNum, funcName, desiredType, this.Type, allowNil); - } - - /// - /// Checks if the type is a specific userdata type, and returns it or throws. - /// - /// - /// Name of the function. - /// The argument number. - /// The flags. - /// - public T CheckUserDataType(string funcName, int argNum = -1, TypeValidationFlags flags = TypeValidationFlags.Default) - { - DynValue v = this.CheckType(funcName, DataType.UserData, argNum, flags); - bool allowNil = ((int)(flags & TypeValidationFlags.AllowNil) != 0); - - if (v.IsNil()) - return default(T); - - object o = v.UserData.Object; - if (o != null && o is T) - return (T)o; - - throw ScriptRuntimeException.BadArgumentUserData(argNum, funcName, typeof(T), o, allowNil); - } - - } - - - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/IScriptPrivateResource.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/IScriptPrivateResource.cs deleted file mode 100644 index 6bb38dd1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/IScriptPrivateResource.cs +++ /dev/null @@ -1,64 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Common interface for all resources which are uniquely bound to a script. - /// - public interface IScriptPrivateResource - { - /// - /// Gets the script owning this resource. - /// - /// - /// The script owning this resource. - /// - Script OwnerScript { get; } - } - - internal static class ScriptPrivateResource_Extension - { - public static void CheckScriptOwnership(this IScriptPrivateResource containingResource, DynValue[] values) - { - foreach (DynValue v in values) - CheckScriptOwnership(containingResource, v); - } - - - public static void CheckScriptOwnership(this IScriptPrivateResource containingResource, DynValue value) - { - if (value != null) - { - var otherResource = value.GetAsPrivateResource(); - - if (otherResource != null) - { - CheckScriptOwnership(containingResource, otherResource); - } - } - } - - public static void CheckScriptOwnership(this IScriptPrivateResource resource, Script script) - { - if (resource.OwnerScript != null && resource.OwnerScript != script && script != null) - { - throw new ScriptRuntimeException("Attempt to access a resource owned by a script, from another script"); - } - } - - public static void CheckScriptOwnership(this IScriptPrivateResource containingResource, IScriptPrivateResource itemResource) - { - if (itemResource != null) - { - if (containingResource.OwnerScript != null && containingResource.OwnerScript != itemResource.OwnerScript && itemResource.OwnerScript != null) - { - throw new ScriptRuntimeException("Attempt to perform operations with resources owned by different scripts."); - } - else if (containingResource.OwnerScript == null && itemResource.OwnerScript != null) - { - throw new ScriptRuntimeException("Attempt to perform operations with a script private resource on a shared resource."); - } - } - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/RefIdObject.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/RefIdObject.cs deleted file mode 100644 index 0569e363..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/RefIdObject.cs +++ /dev/null @@ -1,35 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// A base class for many MoonSharp objects. - /// Helds a ReferenceID property which gets a different value for every object instance, for debugging - /// purposes. Note that the ID is not assigned in a thread safe manner for speed reason, so the IDs - /// are guaranteed to be unique only if everything is running on one thread at a time. - /// - public class RefIdObject - { - private static int s_RefIDCounter = 0; - private int m_RefID = ++s_RefIDCounter; - - /// - /// Gets the reference identifier. - /// - /// - /// The reference identifier. - /// - public int ReferenceID { get { return m_RefID; } } - - - /// - /// Formats a string with a type name and a ref-id - /// - /// The type name. - /// - public string FormatTypeString(string typeString) - { - return string.Format("{0}: {1:X8}", typeString, m_RefID); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/ScriptFunctionDelegate.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/ScriptFunctionDelegate.cs deleted file mode 100644 index 805a3fe1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/ScriptFunctionDelegate.cs +++ /dev/null @@ -1,17 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// A Delegate type which can wrap a script function - /// - /// The arguments. - /// The return value of the script function - public delegate object ScriptFunctionDelegate(params object[] args); - /// - /// A Delegate type which can wrap a script function with a generic typed return value - /// - /// - /// The arguments. - /// The return value of the script function - public delegate T ScriptFunctionDelegate(params object[] args); -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRef.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRef.cs deleted file mode 100644 index 8ff6648e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRef.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -namespace MoonSharp.Interpreter -{ - /// - /// This class stores a possible l-value (that is a potential target of an assignment) - /// - public class SymbolRef - { - private static SymbolRef s_DefaultEnv = new SymbolRef() { i_Type = SymbolRefType.DefaultEnv }; - - // Fields are internal - direct access by the executor was a 10% improvement at profiling here! - internal SymbolRefType i_Type; - internal SymbolRef i_Env; - internal int i_Index; - internal string i_Name; - - /// - /// Gets the type of this symbol reference - /// - public SymbolRefType Type { get { return i_Type; } } - /// - /// Gets the index of this symbol in its scope context - /// - public int Index { get { return i_Index; } } - /// - /// Gets the name of this symbol - /// - public string Name { get { return i_Name; } } - /// - /// Gets the environment this symbol refers to (for global symbols only) - /// - public SymbolRef Environment { get { return i_Env; } } - - - /// - /// Gets the default _ENV. - /// - public static SymbolRef DefaultEnv { get { return s_DefaultEnv; } } - - /// - /// Creates a new symbol reference pointing to a global var - /// - /// The name. - /// The _ENV symbol. - /// - public static SymbolRef Global(string name, SymbolRef envSymbol) - { - return new SymbolRef() { i_Index = -1, i_Type = SymbolRefType.Global, i_Env = envSymbol, i_Name = name }; - } - - /// - /// Creates a new symbol reference pointing to a local var - /// - /// The name. - /// The index of the var in local scope. - /// - internal static SymbolRef Local(string name, int index) - { - //Debug.Assert(index >= 0, "Symbol Index < 0"); - return new SymbolRef() { i_Index = index, i_Type = SymbolRefType.Local, i_Name = name }; - } - - /// - /// Creates a new symbol reference pointing to an upvalue var - /// - /// The name. - /// The index of the var in closure scope. - /// - internal static SymbolRef Upvalue(string name, int index) - { - //Debug.Assert(index >= 0, "Symbol Index < 0"); - return new SymbolRef() { i_Index = index, i_Type = SymbolRefType.Upvalue, i_Name = name }; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - if (i_Type == SymbolRefType.DefaultEnv) - return "(default _ENV)"; - else - if (i_Type == SymbolRefType.Global) - return string.Format("{2} : {0} / {1}", i_Type, i_Env, i_Name); - else - return string.Format("{2} : {0}[{1}]", i_Type, i_Index, i_Name); - } - - /// - /// Writes this instance to a binary stream - /// - internal void WriteBinary(BinaryWriter bw) - { - bw.Write((byte)this.i_Type); - bw.Write(i_Index); - bw.Write(i_Name); - } - - /// - /// Reads a symbolref from a binary stream - /// - internal static SymbolRef ReadBinary(BinaryReader br) - { - SymbolRef that = new SymbolRef(); - that.i_Type = (SymbolRefType)br.ReadByte(); - that.i_Index = br.ReadInt32(); - that.i_Name = br.ReadString(); - return that; - } - - internal void WriteBinaryEnv(BinaryWriter bw, Dictionary symbolMap) - { - if (this.i_Env != null) - bw.Write(symbolMap[i_Env]); - else - bw.Write(-1); - } - - internal void ReadBinaryEnv(BinaryReader br, SymbolRef[] symbolRefs) - { - int idx = br.ReadInt32(); - - if (idx >= 0) - i_Env = symbolRefs[idx]; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRefType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRefType.cs deleted file mode 100644 index 75dd8a22..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/SymbolRefType.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Enumeration of the types of SymbolRef - /// - public enum SymbolRefType - { - /// - /// The symbol ref of a local variable - /// - Local, - /// - /// The symbol ref of an upvalue variable - /// - Upvalue, - /// - /// The symbol ref of a global variable - /// - Global, - /// - /// The symbol ref of the global environment - /// - DefaultEnv, - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs deleted file mode 100644 index c4a4bec4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs +++ /dev/null @@ -1,688 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.DataStructs; - -namespace MoonSharp.Interpreter -{ - /// - /// A class representing a Lua table. - /// - public class Table : RefIdObject, IScriptPrivateResource - { - readonly LinkedList m_Values; - readonly LinkedListIndex m_ValueMap; - readonly LinkedListIndex m_StringMap; - readonly LinkedListIndex m_ArrayMap; - readonly Script m_Owner; - - int m_InitArray = 0; - int m_CachedLength = -1; - bool m_ContainsNilEntries = false; - - /// - /// Initializes a new instance of the class. - /// - /// The owner script. - public Table(Script owner) - { - m_Values = new LinkedList(); - m_StringMap = new LinkedListIndex(m_Values); - m_ArrayMap = new LinkedListIndex(m_Values); - m_ValueMap = new LinkedListIndex(m_Values); - m_Owner = owner; - } - - /// - /// Initializes a new instance of the class. - /// - /// The owner. - /// The values for the "array-like" part of the table. - public Table(Script owner, params DynValue[] arrayValues) - : this(owner) - { - for (int i = 0; i < arrayValues.Length; i++) - { - this.Set(DynValue.NewNumber(i + 1), arrayValues[i]); - } - } - - /// - /// Gets the script owning this resource. - /// - public Script OwnerScript - { - get { return m_Owner; } - } - - /// - /// Removes all items from the Table. - /// - public void Clear() - { - m_Values.Clear(); - m_StringMap.Clear(); - m_ArrayMap.Clear(); - m_ValueMap.Clear(); - m_CachedLength = -1; - } - - /// - /// Gets the integral key from a double. - /// - private int GetIntegralKey(double d) - { - int v = ((int)d); - - if (d >= 1.0 && d == v) - return v; - - return -1; - } - - /// - /// Gets or sets the - /// with the specified key(s). - /// This will marshall CLR and MoonSharp objects in the best possible way. - /// Multiple keys can be used to access subtables. - /// - /// - /// The . - /// - /// The keys to access the table and subtables - public object this[params object[] keys] - { - get - { - return Get(keys).ToObject(); - } - set - { - Set(keys, DynValue.FromObject(OwnerScript, value)); - } - } - - /// - /// Gets or sets the with the specified key(s). - /// This will marshall CLR and MoonSharp objects in the best possible way. - /// - /// - /// The . - /// - /// The key. - /// - public object this[object key] - { - get - { - return Get(key).ToObject(); - } - set - { - Set(key, DynValue.FromObject(OwnerScript, value)); - } - } - - private Table ResolveMultipleKeys(object[] keys, out object key) - { - //Contract.Ensures(Contract.Result
() != null); - //Contract.Requires(keys != null); - - Table t = this; - key = (keys.Length > 0) ? keys[0] : null; - - for (int i = 1; i < keys.Length; ++i) - { - DynValue vt = t.RawGet(key); - - if (vt == null) - throw new ScriptRuntimeException("Key '{0}' did not point to anything"); - - if (vt.Type != DataType.Table) - throw new ScriptRuntimeException("Key '{0}' did not point to a table"); - - t = vt.Table; - key = keys[i]; - } - - return t; - } - - /// - /// Append the value to the table using the next available integer index. - /// - /// The value. - public void Append(DynValue value) - { - this.CheckScriptOwnership(value); - PerformTableSet(m_ArrayMap, Length + 1, DynValue.NewNumber(Length + 1), value, true, Length + 1); - } - - #region Set - - private void PerformTableSet(LinkedListIndex listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber, int appendKey) - { - TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value)); - - // If this is an insert, we can invalidate all iterators and collect dead keys - if (m_ContainsNilEntries && value.IsNotNil() && (prev.Value == null || prev.Value.IsNil())) - { - CollectDeadKeys(); - } - // If this value is nil (and we didn't collect), set that there are nil entries, and invalidate array len cache - else if (value.IsNil()) - { - m_ContainsNilEntries = true; - - if (isNumber) - m_CachedLength = -1; - } - else if (isNumber) - { - // If this is an array insert, we might have to invalidate the array length - if (prev.Value == null || prev.Value.IsNilOrNan()) - { - // If this is an array append, let's check the next element before blindly invalidating - if (appendKey >= 0) - { - LinkedListNode next = m_ArrayMap.Find(appendKey + 1); - if (next == null || next.Value.Value == null || next.Value.Value.IsNil()) - { - m_CachedLength += 1; - } - else - { - m_CachedLength = -1; - } - } - else - { - m_CachedLength = -1; - } - } - } - } - - /// - /// Sets the value associated to the specified key. - /// - /// The key. - /// The value. - public void Set(string key, DynValue value) - { - if (key == null) - throw ScriptRuntimeException.TableIndexIsNil(); - - this.CheckScriptOwnership(value); - PerformTableSet(m_StringMap, key, DynValue.NewString(key), value, false, -1); - } - - /// - /// Sets the value associated to the specified key. - /// - /// The key. - /// The value. - public void Set(int key, DynValue value) - { - this.CheckScriptOwnership(value); - PerformTableSet(m_ArrayMap, key, DynValue.NewNumber(key), value, true, -1); - } - - /// - /// Sets the value associated to the specified key. - /// - /// The key. - /// The value. - public void Set(DynValue key, DynValue value) - { - if (key.IsNilOrNan()) - { - if (key.IsNil()) - throw ScriptRuntimeException.TableIndexIsNil(); - else - throw ScriptRuntimeException.TableIndexIsNaN(); - } - - if (key.Type == DataType.String) - { - Set(key.String, value); - return; - } - - if (key.Type == DataType.Number) - { - int idx = GetIntegralKey(key.Number); - - if (idx > 0) - { - Set(idx, value); - return; - } - } - - this.CheckScriptOwnership(key); - this.CheckScriptOwnership(value); - - PerformTableSet(m_ValueMap, key, key, value, false, -1); - } - - /// - /// Sets the value associated with the specified key. - /// - /// The key. - /// The value. - public void Set(object key, DynValue value) - { - if (key == null) - throw ScriptRuntimeException.TableIndexIsNil(); - - if (key is string) - Set((string)key, value); - else if (key is int) - Set((int)key, value); - else - Set(DynValue.FromObject(OwnerScript, key), value); - } - - /// - /// Sets the value associated with the specified keys. - /// Multiple keys can be used to access subtables. - /// - /// The keys. - /// The value. - public void Set(object[] keys, DynValue value) - { - if (keys == null || keys.Length <= 0) - throw ScriptRuntimeException.TableIndexIsNil(); - - object key; - ResolveMultipleKeys(keys, out key).Set(key, value); - } - - #endregion - - #region Get - - /// - /// Gets the value associated with the specified key. - /// - /// The key. - public DynValue Get(string key) - { - //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; - } - - /// - /// Gets the value associated with the specified key. - /// - /// The key. - public DynValue Get(int key) - { - //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; - } - - /// - /// Gets the value associated with the specified key. - /// - /// The key. - public DynValue Get(DynValue key) - { - //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; - } - - /// - /// Gets the value associated with the specified key. - /// (expressed as a ). - /// - /// The key. - public DynValue Get(object key) - { - //Contract.Ensures(Contract.Result() != null); - return RawGet(key) ?? DynValue.Nil; - } - - /// - /// Gets the value associated with the specified keys (expressed as an - /// array of ). - /// This will marshall CLR and MoonSharp objects in the best possible way. - /// Multiple keys can be used to access subtables. - /// - /// The keys to access the table and subtables - public DynValue Get(params object[] keys) - { - //Contract.Ensures(Contract.Result() != null); - return RawGet(keys) ?? DynValue.Nil; - } - - #endregion - - #region RawGet - - private static DynValue RawGetValue(LinkedListNode linkedListNode) - { - return (linkedListNode != null) ? linkedListNode.Value.Value : null; - } - - /// - /// Gets the value associated with the specified key, - /// without bringing to Nil the non-existant values. - /// - /// The key. - public DynValue RawGet(string key) - { - return RawGetValue(m_StringMap.Find(key)); - } - - /// - /// Gets the value associated with the specified key, - /// without bringing to Nil the non-existant values. - /// - /// The key. - public DynValue RawGet(int key) - { - return RawGetValue(m_ArrayMap.Find(key)); - } - - /// - /// Gets the value associated with the specified key, - /// without bringing to Nil the non-existant values. - /// - /// The key. - public DynValue RawGet(DynValue key) - { - if (key.Type == DataType.String) - return RawGet(key.String); - - if (key.Type == DataType.Number) - { - int idx = GetIntegralKey(key.Number); - if (idx > 0) - return RawGet(idx); - } - - return RawGetValue(m_ValueMap.Find(key)); - } - - /// - /// Gets the value associated with the specified key, - /// without bringing to Nil the non-existant values. - /// - /// The key. - public DynValue RawGet(object key) - { - if (key == null) - return null; - - if (key is string) - return RawGet((string)key); - - if (key is int) - return RawGet((int)key); - - return RawGet(DynValue.FromObject(OwnerScript, key)); - } - - /// - /// Gets the value associated with the specified keys (expressed as an - /// array of ). - /// This will marshall CLR and MoonSharp objects in the best possible way. - /// Multiple keys can be used to access subtables. - /// - /// The keys to access the table and subtables - public DynValue RawGet(params object[] keys) - { - if (keys == null || keys.Length <= 0) - return null; - - object key; - return ResolveMultipleKeys(keys, out key).RawGet(key); - } - - #endregion - - #region Remove - - private bool PerformTableRemove(LinkedListIndex listIndex, T key, bool isNumber) - { - var removed = listIndex.Remove(key); - - if (removed && isNumber) - { - m_CachedLength = -1; - } - - return removed; - } - - /// - /// Remove the value associated with the specified key from the table. - /// - /// The key. - /// true if values was successfully removed; otherwise, false. - public bool Remove(string key) - { - return PerformTableRemove(m_StringMap, key, false); - } - - /// - /// Remove the value associated with the specified key from the table. - /// - /// The key. - /// true if values was successfully removed; otherwise, false. - public bool Remove(int key) - { - return PerformTableRemove(m_ArrayMap, key, true); - } - - /// - /// Remove the value associated with the specified key from the table. - /// - /// The key. - /// true if values was successfully removed; otherwise, false. - public bool Remove(DynValue key) - { - if (key.Type == DataType.String) - return Remove(key.String); - - if (key.Type == DataType.Number) - { - int idx = GetIntegralKey(key.Number); - if (idx > 0) - return Remove(idx); - } - - return PerformTableRemove(m_ValueMap, key, false); - } - - /// - /// Remove the value associated with the specified key from the table. - /// - /// The key. - /// true if values was successfully removed; otherwise, false. - public bool Remove(object key) - { - if (key is string) - return Remove((string)key); - - if (key is int) - return Remove((int)key); - - return Remove(DynValue.FromObject(OwnerScript, key)); - } - - /// - /// Remove the value associated with the specified keys from the table. - /// Multiple keys can be used to access subtables. - /// - /// The key. - /// true if values was successfully removed; otherwise, false. - public bool Remove(params object[] keys) - { - if (keys == null || keys.Length <= 0) - return false; - - object key; - return ResolveMultipleKeys(keys, out key).Remove(key); - } - - #endregion - - /// - /// Collects the dead keys. This frees up memory but invalidates pending iterators. - /// It's called automatically internally when the semantics of Lua tables allow, but can be forced - /// externally if it's known that no iterators are pending. - /// - public void CollectDeadKeys() - { - for (LinkedListNode node = m_Values.First; node != null; node = node.Next) - { - if (node.Value.Value.IsNil()) - { - Remove(node.Value.Key); - } - } - - m_ContainsNilEntries = false; - m_CachedLength = -1; - } - - - /// - /// Returns the next pair from a value - /// - public TablePair? NextKey(DynValue v) - { - if (v.IsNil()) - { - LinkedListNode node = m_Values.First; - - if (node == null) - return TablePair.Nil; - else - { - if (node.Value.Value.IsNil()) - return NextKey(node.Value.Key); - else - return node.Value; - } - } - - if (v.Type == DataType.String) - { - return GetNextOf(m_StringMap.Find(v.String)); - } - - if (v.Type == DataType.Number) - { - int idx = GetIntegralKey(v.Number); - - if (idx > 0) - { - return GetNextOf(m_ArrayMap.Find(idx)); - } - } - - return GetNextOf(m_ValueMap.Find(v)); - } - - private TablePair? GetNextOf(LinkedListNode linkedListNode) - { - while (true) - { - if (linkedListNode == null) - return null; - - if (linkedListNode.Next == null) - return TablePair.Nil; - - linkedListNode = linkedListNode.Next; - - if (!linkedListNode.Value.Value.IsNil()) - return linkedListNode.Value; - } - } - - - /// - /// Gets the length of the "array part". - /// - public int Length - { - get - { - if (m_CachedLength < 0) - { - m_CachedLength = 0; - - for (int i = 1; m_ArrayMap.ContainsKey(i) && !m_ArrayMap.Find(i).Value.Value.IsNil(); i++) - m_CachedLength = i; - } - - return m_CachedLength; - } - } - - internal void InitNextArrayKeys(DynValue val, bool lastpos) - { - if (val.Type == DataType.Tuple && lastpos) - { - foreach (DynValue v in val.Tuple) - InitNextArrayKeys(v, true); - } - else - { - Set(++m_InitArray, val.ToScalar()); - } - } - - /// - /// Gets the meta-table associated with this instance. - /// - public Table MetaTable - { - get { return m_MetaTable; } - set { this.CheckScriptOwnership(m_MetaTable); m_MetaTable = value; } - } - private Table m_MetaTable; - - - - /// - /// Enumerates the key/value pairs. - /// - /// - public IEnumerable Pairs - { - get - { - return m_Values.Select(n => new TablePair(n.Key, n.Value)); - } - } - - /// - /// Enumerates the keys. - /// - /// - public IEnumerable Keys - { - get - { - return m_Values.Select(n => n.Key); - } - } - - /// - /// Enumerates the values - /// - /// - public IEnumerable Values - { - get - { - return m_Values.Select(n => n.Value); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TablePair.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TablePair.cs deleted file mode 100644 index 6045ab47..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TablePair.cs +++ /dev/null @@ -1,47 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// A class representing a key/value pair for Table use - /// - public struct TablePair - { - private static TablePair s_NilNode = new TablePair(DynValue.Nil, DynValue.Nil); - private DynValue key, value; - - /// - /// Gets the key. - /// - public DynValue Key - { - get { return key; } - private set { Key = key; } - } - - /// - /// Gets or sets the value. - /// - public DynValue Value - { - get { return value; } - set { if (key.IsNotNil()) Value = value; } - } - - - /// - /// Initializes a new instance of the struct. - /// - /// The key. - /// The value. - public TablePair(DynValue key, DynValue val) - { - this.key = key; - this.value = val; - } - - /// - /// Gets the nil pair - /// - public static TablePair Nil { get { return s_NilNode; } } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TailCallData.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TailCallData.cs deleted file mode 100644 index 13d7ba3f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TailCallData.cs +++ /dev/null @@ -1,31 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Class used to support "tail" continuations - a way for C# / Lua interaction which supports - /// coroutine yielding (at the expense of a LOT of added complexity in calling code). - /// - public class TailCallData - { - /// - /// Gets or sets the function to call - /// - public DynValue Function { get; set; } - /// - /// Gets or sets the arguments to the function - /// - public DynValue[] Args { get; set; } - /// - /// Gets or sets the callback to be used as a continuation. - /// - public CallbackFunction Continuation { get; set; } - /// - /// Gets or sets the callback to be used in case of errors. - /// - public CallbackFunction ErrorHandler { get; set; } - /// - /// Gets or sets the error handler to be called before stack unwinding - /// - public DynValue ErrorHandlerBeforeUnwind { get; set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TypeValidationFlags.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TypeValidationFlags.cs deleted file mode 100644 index 1540f895..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/TypeValidationFlags.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Flags to alter the way the DynValue.CheckType and other related functions operate on data types for - /// validation. - /// - [Flags] - public enum TypeValidationFlags - { - /// - /// No type validation specific behaviour - /// - None = 0, - /// - /// Nil and Void values are allowed (and returned by the call) - /// - AllowNil = 0x1, - /// - /// Simple autoconversions are attempted: - /// 1) Numbers are convertible to strings - /// 2) Strings are convertible to numbers if they contain a number - /// 3) Everything is convertible to boolean (with void and nil converting to 'false', everything else converting to 'true') - /// Note: if both AutoConvert and AllowNil are specified, nils will NOT be converted to false booleans. - /// - AutoConvert = 0x2, - - /// - /// The default : Autoconverting values, no nils. - /// - Default = AutoConvert - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/UserData.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/UserData.cs deleted file mode 100755 index c56f2285..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/UserData.cs +++ /dev/null @@ -1,401 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Linq; -using MoonSharp.Interpreter.Interop; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.RegistrationPolicies; -using MoonSharp.Interpreter.Interop.StandardDescriptors; -using MoonSharp.Interpreter.Interop.UserDataRegistries; -using MoonSharp.Interpreter.Serialization.Json; - -namespace MoonSharp.Interpreter -{ - /// - /// Class exposing C# objects as Lua userdata. - /// For efficiency, a global registry of types is maintained, instead of a per-script one. - /// - public class UserData : RefIdObject - { - private UserData() - { - // This type can only be instantiated using one of the Create methods - } - - /// - /// Gets or sets the "uservalue". See debug.getuservalue and debug.setuservalue. - /// http://www.lua.org/manual/5.2/manual.html#pdf-debug.setuservalue - /// - public DynValue UserValue { get; set; } - - /// - /// Gets the object associated to this userdata (null for statics) - /// - public object Object { get; private set; } - - /// - /// Gets the type descriptor of this userdata - /// - public IUserDataDescriptor Descriptor { get; private set; } - - - - static UserData() - { - RegistrationPolicy = InteropRegistrationPolicy.Default; - - RegisterType(InteropAccessMode.NoReflectionAllowed); - RegisterType(InteropAccessMode.HideMembers); - RegisterType(InteropAccessMode.NoReflectionAllowed); - RegisterType(InteropAccessMode.Reflection); - - DefaultAccessMode = InteropAccessMode.LazyOptimized; - } - - /// - /// Registers a type for userdata interop - /// - /// The type to be registered - /// The access mode (optional). - /// Friendly name for the type (optional) - public static IUserDataDescriptor RegisterType(InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) - { - return TypeDescriptorRegistry.RegisterType_Impl(typeof(T), accessMode, friendlyName, null); - } - - /// - /// Registers a type for userdata interop - /// - /// The type to be registered - /// The access mode (optional). - /// Friendly name for the type (optional) - public static IUserDataDescriptor RegisterType(Type type, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) - { - return TypeDescriptorRegistry.RegisterType_Impl(type, accessMode, friendlyName, null); - } - - - /// - /// Registers a proxy type. - /// - /// The proxy factory. - /// The access mode. - /// A friendly name for the descriptor. - /// - public static IUserDataDescriptor RegisterProxyType(IProxyFactory proxyFactory, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) - { - return TypeDescriptorRegistry.RegisterProxyType_Impl(proxyFactory, accessMode, friendlyName); - } - - /// - /// Registers a proxy type using a delegate. - /// - /// The type of the proxy. - /// The type of the target. - /// A delegate creating a proxy object from a target object. - /// The access mode. - /// A friendly name for the descriptor. - /// - public static IUserDataDescriptor RegisterProxyType(Func wrapDelegate, InteropAccessMode accessMode = InteropAccessMode.Default, string friendlyName = null) - where TProxy : class - where TTarget : class - { - return RegisterProxyType(new DelegateProxyFactory(wrapDelegate), accessMode, friendlyName); - } - - - - /// - /// Registers a type with a custom userdata descriptor - /// - /// The type to be registered - /// The custom descriptor. - public static IUserDataDescriptor RegisterType(IUserDataDescriptor customDescriptor) - { - return TypeDescriptorRegistry.RegisterType_Impl(typeof(T), InteropAccessMode.Default, null, customDescriptor); - } - - /// - /// Registers a type with a custom userdata descriptor - /// - /// The type to be registered - /// The custom descriptor. - public static IUserDataDescriptor RegisterType(Type type, IUserDataDescriptor customDescriptor) - { - return TypeDescriptorRegistry.RegisterType_Impl(type, InteropAccessMode.Default, null, customDescriptor); - } - - /// - /// Registers a type with a custom userdata descriptor - /// - /// The custom descriptor. - public static IUserDataDescriptor RegisterType(IUserDataDescriptor customDescriptor) - { - return TypeDescriptorRegistry.RegisterType_Impl(customDescriptor.Type, InteropAccessMode.Default, null, customDescriptor); - } - - - /// - /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. - /// - /// The assembly. - /// if set to true extension types are registered to the appropriate registry. - public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) - { - if (asm == null) - { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif - } - - TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); - } - - /// - /// Determines whether the specified type is registered. Note that this should be used only to check if a descriptor - /// has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor - /// of a base type or implemented interfaces. - /// - /// The type. - /// - public static bool IsTypeRegistered(Type t) - { - return TypeDescriptorRegistry.IsTypeRegistered(t); - } - - /// - /// Determines whether the specified type is registered. Note that this should be used only to check if a descriptor - /// has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor - /// of a base type or implemented interfaces. - /// - /// The type. - /// - public static bool IsTypeRegistered() - { - return TypeDescriptorRegistry.IsTypeRegistered(typeof(T)); - } - - /// - /// Unregisters a type. - /// WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - /// Use this only for testing purposes or to re-register the same type in a slightly different way. - /// Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - /// - /// The type to be unregistered - public static void UnregisterType() - { - TypeDescriptorRegistry.UnregisterType(typeof(T)); - } - - /// - /// Unregisters a type. - /// WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - /// Use this only for testing purposes or to re-register the same type in a slightly different way. - /// Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - /// - /// The The type to be unregistered - public static void UnregisterType(Type t) - { - TypeDescriptorRegistry.UnregisterType(t); - } - - /// - /// Creates a userdata DynValue from the specified object, using a specific descriptor - /// - /// The object - /// The descriptor. - /// - public static DynValue Create(object o, IUserDataDescriptor descr) - { - return DynValue.NewUserData(new UserData() - { - Descriptor = descr, - Object = o - }); - } - - /// - /// Creates a userdata DynValue from the specified object - /// - /// The object - /// - public static DynValue Create(object o) - { - var descr = GetDescriptorForObject(o); - if (descr == null) - { - if (o is Type) - return CreateStatic((Type)o); - - return null; - } - - return Create(o, descr); - } - - /// - /// Creates a static userdata DynValue from the specified IUserDataDescriptor - /// - /// The IUserDataDescriptor - /// - public static DynValue CreateStatic(IUserDataDescriptor descr) - { - if (descr == null) return null; - - return DynValue.NewUserData(new UserData() - { - Descriptor = descr, - Object = null - }); - } - - /// - /// Creates a static userdata DynValue from the specified Type - /// - /// The type - /// - public static DynValue CreateStatic(Type t) - { - return CreateStatic(GetDescriptorForType(t, false)); - } - - /// - /// Creates a static userdata DynValue from the specified Type - /// - /// The Type - /// - public static DynValue CreateStatic() - { - return CreateStatic(GetDescriptorForType(typeof(T), false)); - } - - /// - /// Gets or sets the registration policy to be used in the whole application - /// - public static IRegistrationPolicy RegistrationPolicy - { - get { return TypeDescriptorRegistry.RegistrationPolicy; } - set { TypeDescriptorRegistry.RegistrationPolicy = value; } - } - - /// - /// Gets or sets the default access mode to be used in the whole application - /// - /// - /// The default access mode. - /// - /// InteropAccessMode is InteropAccessMode.Default - public static InteropAccessMode DefaultAccessMode - { - get { return TypeDescriptorRegistry.DefaultAccessMode; } - set { TypeDescriptorRegistry.DefaultAccessMode = value; } - } - - /// - /// Registers an extension Type (that is a type containing extension methods) - /// - /// The type. - /// The InteropAccessMode. - public static void RegisterExtensionType(Type type, InteropAccessMode mode = InteropAccessMode.Default) - { - ExtensionMethodsRegistry.RegisterExtensionType(type, mode); - } - - /// - /// Gets all the extension methods which can match a given name and extending a given Type - /// - /// The name. - /// The extended type. - /// - public static List GetExtensionMethodsByNameAndType(string name, Type extendedType) - { - return ExtensionMethodsRegistry.GetExtensionMethodsByNameAndType(name, extendedType); - } - - /// - /// Gets a number which gets incremented everytime the extension methods registry changes. - /// Use this to invalidate caches based on extension methods - /// - /// - public static int GetExtensionMethodsChangeVersion() - { - return ExtensionMethodsRegistry.GetExtensionMethodsChangeVersion(); - } - - /// - /// Gets the best possible type descriptor for a specified CLR type. - /// - /// The CLR type for which the descriptor is desired. - /// if set to true interfaces are used in the search. - /// - public static IUserDataDescriptor GetDescriptorForType(bool searchInterfaces) - { - return TypeDescriptorRegistry.GetDescriptorForType(typeof(T), searchInterfaces); - } - - /// - /// Gets the best possible type descriptor for a specified CLR type. - /// - /// The CLR type for which the descriptor is desired. - /// if set to true interfaces are used in the search. - /// - public static IUserDataDescriptor GetDescriptorForType(Type type, bool searchInterfaces) - { - return TypeDescriptorRegistry.GetDescriptorForType(type, searchInterfaces); - } - - - /// - /// Gets the best possible type descriptor for a specified CLR object. - /// - /// The object. - /// - public static IUserDataDescriptor GetDescriptorForObject(object o) - { - return TypeDescriptorRegistry.GetDescriptorForType(o.GetType(), true); - } - - - /// - /// Gets a table with the description of registered types. - /// - /// if set to true, it will also include the last found descriptor of all unregistered types. - /// - public static Table GetDescriptionOfRegisteredTypes(bool useHistoricalData = false) - { - DynValue output = DynValue.NewPrimeTable(); - var registeredTypesPairs = useHistoricalData ? TypeDescriptorRegistry.RegisteredTypesHistory : TypeDescriptorRegistry.RegisteredTypes; - - foreach (var descpair in registeredTypesPairs) - { - IWireableDescriptor sd = descpair.Value as IWireableDescriptor; - - if (sd != null) - { - DynValue t = DynValue.NewPrimeTable(); - output.Table.Set(descpair.Key.FullName, t); - sd.PrepareForWiring(t.Table); - } - } - - return output.Table; - } - - /// - /// Gets all the registered types. - /// - /// if set to true, it will also include the last found descriptor of all unregistered types. - /// - public static IEnumerable GetRegisteredTypes(bool useHistoricalData = false) - { - var registeredTypesPairs = useHistoricalData ? TypeDescriptorRegistry.RegisteredTypesHistory : TypeDescriptorRegistry.RegisteredTypes; - return registeredTypesPairs.Select(p => p.Value.Type); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/WellKnownSymbols.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/WellKnownSymbols.cs deleted file mode 100644 index ed78ef3f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/WellKnownSymbols.cs +++ /dev/null @@ -1,19 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Constants of well known "symbols" in the MoonSharp grammar - /// - public static class WellKnownSymbols - { - /// - /// The variadic argument symbol ("...") - /// - public const string VARARGS = "..."; - - /// - /// The environment symbol ("_ENV") - /// - public const string ENV = "_ENV"; - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/YieldRequest.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/YieldRequest.cs deleted file mode 100644 index a46a3cb0..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/YieldRequest.cs +++ /dev/null @@ -1,19 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Class wrapping a request to yield a coroutine - /// - public class YieldRequest - { - /// - /// The return values of the coroutine - /// - public DynValue[] ReturnValues; - - /// - /// Gets or sets a value indicating whether this is a forced yield. - /// - public bool Forced { get; internal set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebugService.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebugService.cs deleted file mode 100644 index 28802d93..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebugService.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Class providing services specific to debugger implementations. - /// - /// - public sealed class DebugService : IScriptPrivateResource - { - Processor m_Processor; - - internal DebugService(Script script, Processor processor) - { - OwnerScript = script; - m_Processor = processor; - } - - /// - /// Gets the script owning this resource. - /// - /// - /// The script owning this resource. - /// - public Script OwnerScript { get; private set; } - - /// - /// Resets the break points for a given file. Supports only line-based breakpoints. - /// - /// The source. - /// The lines. - /// The lines for which breakpoints have been set - public HashSet ResetBreakPoints(SourceCode src, HashSet lines) - { - return m_Processor.ResetBreakPoints(src, lines); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerAction.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerAction.cs deleted file mode 100644 index 270df3bc..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerAction.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Wrapper for a debugger initiated action - /// - public class DebuggerAction - { - /// - /// Type of the action - /// - public enum ActionType - { - /// - /// Step-in at the bytecode level - /// - ByteCodeStepIn, - /// - /// Step-over at the bytecode level - /// - ByteCodeStepOver, - /// - /// Step-out at the bytecode level - /// - ByteCodeStepOut, - /// - /// Step-in at the source level - /// - StepIn, - /// - /// Step-over at the source level - /// - StepOver, - /// - /// Step-out at the source level - /// - StepOut, - /// - /// Continue execution "freely" - /// - Run, - /// - /// Toggles breakpoint - /// - ToggleBreakpoint, - /// - /// Sets a breakpoint - /// - SetBreakpoint, - /// - /// Clears a breakpoint - /// - ClearBreakpoint, - /// - /// Reset all breakpoints - /// - ResetBreakpoints, - /// - /// Refresh the data - /// - Refresh, - /// - /// Hard refresh of data - /// - HardRefresh, - /// - /// No action - /// - None, - } - - /// - /// The type of action - /// - public ActionType Action { get; set; } - /// - /// Gets the time stamp UTC of this action - /// - public DateTime TimeStampUTC { get; private set; } - - /// - /// Gets or sets the source identifier this action refers to. - /// - public int SourceID { get; set; } - /// - /// Gets or sets the source line this action refers to. - /// - public int SourceLine { get; set; } - /// - /// Gets or sets the source column this action refers to. - /// - public int SourceCol { get; set; } - /// - /// Gets or sets the lines. This is used for the ResetBreakpoints and sets line-based bps only. - /// - public int[] Lines { get; set; } - - - /// - /// Initializes a new instance of the class. - /// - public DebuggerAction() - { - TimeStampUTC = DateTime.UtcNow; - } - - /// - /// Gets the age of this debugger action - /// - public TimeSpan Age { get { return DateTime.UtcNow - TimeStampUTC; } } - - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - if (Action == ActionType.ToggleBreakpoint || Action == ActionType.SetBreakpoint || Action == ActionType.ClearBreakpoint) - { - return string.Format("{0} {1}:({2},{3})", Action, SourceID, SourceLine, SourceCol); - } - else - { - return Action.ToString(); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerCaps.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerCaps.cs deleted file mode 100644 index 415866d7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/DebuggerCaps.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Enumeration of capabilities for a debugger - /// - [Flags] - public enum DebuggerCaps - { - /// - /// Flag set if the debugger can debug source code - /// - CanDebugSourceCode = 0x1, - /// - /// Flag set if the can debug VM bytecode - /// - CanDebugByteCode = 0x2, - /// - /// Flag set if the debugger uses breakpoints based on lines instead of tokens - /// - HasLineBasedBreakpoints = 0x4 - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/IDebugger.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/IDebugger.cs deleted file mode 100644 index 8e2e4dca..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/IDebugger.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Interface for debuggers to implement, in order to provide debugging facilities to Scripts. - /// - public interface IDebugger - { - /// - /// Gets the debugger caps. - /// - DebuggerCaps GetDebuggerCaps(); - /// - /// Sets the debug service for this debugger - /// - /// The debug service. - void SetDebugService(DebugService debugService); - /// - /// Called by the script engine when a source code is added or changed. - /// - /// The source code object. - void SetSourceCode(SourceCode sourceCode); - /// - /// Called by the script engine when the bytecode changes. - /// - /// The bytecode source - void SetByteCode(string[] byteCode); - /// - /// Called by the script engine at execution time to check if a break has - /// been requested. Should return pretty fast as it's called A LOT. - /// - bool IsPauseRequested(); - /// - /// Called by the script engine when a runtime error occurs. - /// The debugger can return true to signal the engine that it wants to break - /// into the source of the error. If it does so, it should also return true - /// to subsequent calls to IsPauseRequested(). - /// - /// The runtime exception. - /// True if this error should break execution. - bool SignalRuntimeException(ScriptRuntimeException ex); - /// - /// Called by the script engine to get what action to do next. - /// - /// The instruction pointer in bytecode. - /// The source reference. - /// T - DebuggerAction GetAction(int ip, SourceRef sourceref); - /// - /// Called by the script engine when the execution ends. - /// - void SignalExecutionEnded(); - /// - /// Called by the script engine to update watches of a given type. Note - /// that this method is not called only for watches in the strictest term, - /// but also for the stack, etc. - /// - /// Type of the watch. - /// The items. - void Update(WatchType watchType, IEnumerable items); - /// - /// Called by the script engine to get which expressions are active - /// watches in the debugger. - /// - /// A list of watches - List GetWatchItems(); - /// - /// Called by the script engine to refresh the breakpoint list. - /// - void RefreshBreakpoints(IEnumerable refs); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceCode.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceCode.cs deleted file mode 100644 index 797db448..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceCode.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Class representing the source code of a given script - /// - public class SourceCode : IScriptPrivateResource - { - /// - /// Gets the name of the source code - /// - public string Name { get; private set; } - /// - /// Gets the source code as a string - /// - public string Code { get; private set; } - /// - /// Gets the source code lines. - /// - public string[] Lines { get; private set; } - /// - /// Gets the script owning this resource. - /// - public Script OwnerScript { get; private set; } - /// - /// Gets the source identifier inside a script - /// - public int SourceID { get; private set; } - - internal List Refs { get; private set; } - - internal SourceCode(string name, string code, int sourceID, Script ownerScript) - { - Refs = new List(); - - List lines = new List(); - - Name = name; - Code = code; - - lines.Add(string.Format("-- Begin of chunk : {0} ", name)); - - lines.AddRange(Code.Split('\n')); - - Lines = lines.ToArray(); - - OwnerScript = ownerScript; - SourceID = sourceID; - } - - /// - /// Gets the code snippet represented by a source ref - /// - /// The source code reference. - /// - public string GetCodeSnippet(SourceRef sourceCodeRef) - { - if (sourceCodeRef.FromLine == sourceCodeRef.ToLine) - { - int from = AdjustStrIndex(Lines[sourceCodeRef.FromLine], sourceCodeRef.FromChar); - int to = AdjustStrIndex(Lines[sourceCodeRef.FromLine], sourceCodeRef.ToChar); - return Lines[sourceCodeRef.FromLine].Substring(from, to - from); - } - - StringBuilder sb = new StringBuilder(); - - for (int i = sourceCodeRef.FromLine; i <= sourceCodeRef.ToLine; i++) - { - if (i == sourceCodeRef.FromLine) - { - int from = AdjustStrIndex(Lines[i], sourceCodeRef.FromChar); - sb.Append(Lines[i].Substring(from)); - } - else if (i == sourceCodeRef.ToLine) - { - int to = AdjustStrIndex(Lines[i], sourceCodeRef.ToChar); - sb.Append(Lines[i].Substring(0, to + 1)); - } - else - { - sb.Append(Lines[i]); - } - } - - return sb.ToString(); - } - - private int AdjustStrIndex(string str, int loc) - { - return Math.Max(Math.Min(str.Length, loc), 0); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceRef.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceRef.cs deleted file mode 100755 index 10c2fecd..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/SourceRef.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Class representing a reference to source code interval - /// - public class SourceRef - { - /// - /// Gets a value indicating whether this location is inside CLR . - /// - public bool IsClrLocation { get; private set; } - - /// - /// Gets the index of the source. - /// - public int SourceIdx { get; private set; } - /// - /// Gets from which column the source code ref starts - /// - public int FromChar { get; private set; } - /// - /// Gets to which column the source code ref ends - /// - public int ToChar { get; private set; } - /// - /// Gets from which line the source code ref starts - /// - public int FromLine { get; private set; } - /// - /// Gets to which line the source code ref ends - /// - public int ToLine { get; private set; } - /// - /// Gets a value indicating whether this instance is a stop "step" in source mode - /// - public bool IsStepStop { get; private set; } - - /// - /// Gets a value indicating whether this instance is a breakpoint - /// - public bool Breakpoint; - /// - /// Gets a value indicating whether this instance cannot be set as a breakpoint - /// - public bool CannotBreakpoint { get; private set; } - - internal static SourceRef GetClrLocation() - { - return new SourceRef(0, 0, 0, 0, 0, false) { IsClrLocation = true }; - } - - public SourceRef(SourceRef src, bool isStepStop) - { - SourceIdx = src.SourceIdx; - FromChar = src.FromChar; - ToChar = src.ToChar; - FromLine = src.FromLine; - ToLine = src.ToLine; - IsStepStop = isStepStop; - } - - - public SourceRef(int sourceIdx, int from, int to, int fromline, int toline, bool isStepStop) - { - SourceIdx = sourceIdx; - FromChar = from; - ToChar = to; - FromLine = fromline; - ToLine = toline; - IsStepStop = isStepStop; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return string.Format("[{0}]{1} ({2}, {3}) -> ({4}, {5})", - SourceIdx, IsStepStop ? "*" : " ", - FromLine, FromChar, - ToLine, ToChar); - } - - internal int GetLocationDistance(int sourceIdx, int line, int col) - { - const int PER_LINE_FACTOR = 1600; // we avoid computing real lines length and approximate with heuristics.. - - if (sourceIdx != SourceIdx) - return int.MaxValue; - - if (FromLine == ToLine) - { - if (line == FromLine) - { - if (col >= FromChar && col <= ToChar) - return 0; - else if (col < FromChar) - return FromChar - col; - else - return col - ToChar; - } - else - { - return Math.Abs(line - FromLine) * PER_LINE_FACTOR; - } - } - else if (line == FromLine) - { - if (col < FromChar) - return FromChar - col; - else - return 0; - } - else if (line == ToLine) - { - if (col > ToChar) - return col - ToChar; - else - return 0; - } - else if (line > FromLine && line < ToLine) - { - return 0; - } - else if (line < FromLine) - { - return (FromLine - line) * PER_LINE_FACTOR; - } - else - { - return (line - ToLine) * PER_LINE_FACTOR; - } - } - - /// - /// Gets whether the source ref includes the specified location - /// - /// Index of the source. - /// The line. - /// The column. - /// - public bool IncludesLocation(int sourceIdx, int line, int col) - { - if (sourceIdx != SourceIdx || line < FromLine || line > ToLine) - return false; - - if (FromLine == ToLine) - return col >= FromChar && col <= ToChar; - if (line == FromLine) - return col >= FromChar; - if (line == ToLine) - return col <= ToChar; - - return true; - } - - /// - /// Sets the CannotBreakpoint flag. - /// - /// - public SourceRef SetNoBreakPoint() - { - CannotBreakpoint = true; - return this; - } - - /// - /// Formats the location according to script preferences - /// - /// The script. - /// if set to true the classic Lua format is forced. - /// - public string FormatLocation(Script script, bool forceClassicFormat = false) - { - SourceCode sc = script.GetSourceCode(this.SourceIdx); - - if (this.IsClrLocation) - return "[clr]"; - - if (script.Options.UseLuaErrorLocations || forceClassicFormat) - { - return string.Format("{0}:{1}", sc.Name, this.FromLine); - } - else if (this.FromLine == this.ToLine) - { - if (this.FromChar == this.ToChar) - { - return string.Format("{0}:({1},{2})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar); - } - else - { - return string.Format("{0}:({1},{2}-{4})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar); - } - } - else - { - return string.Format("{0}:({1},{2}-{3},{4})", sc.Name, this.FromLine, this.FromChar, this.ToLine, this.ToChar); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchItem.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchItem.cs deleted file mode 100644 index 740f2bb7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchItem.cs +++ /dev/null @@ -1,60 +0,0 @@ - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// A watch item for the debugger to consume. - /// Most properties make or not sense depending on the WatchType. - /// - public class WatchItem - { - /// - /// Gets or sets the address of the item - /// - public int Address { get; set; } - /// - /// Gets or sets the base pointer (base value of v-stack at entering the function). - /// Valid only for call-stack items - /// - public int BasePtr { get; set; } - /// - /// Gets or sets the return address. - /// Valid only for call-stack items - /// - public int RetAddress { get; set; } - /// - /// Gets or sets the name of the item - /// - public string Name { get; set; } - /// - /// Gets or sets the value of the item - /// - public DynValue Value { get; set; } - /// - /// Gets or sets the symbol reference of the item - /// - public SymbolRef LValue { get; set; } - /// - /// Gets or sets a value indicating whether this instance is generating an error. - /// - public bool IsError { get; set; } - /// - /// Gets or sets the source location this item refers to. - /// - public SourceRef Location { get; set; } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return string.Format("{0}:{1}:{2}:{3}:{4}:{5}", - Address, BasePtr, RetAddress, Name ?? "(null)", - Value != null ? Value.ToString() : "(null)", - LValue != null ? LValue.ToString() : "(null)"); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchType.cs deleted file mode 100644 index 85930208..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Debugging/WatchType.cs +++ /dev/null @@ -1,38 +0,0 @@ - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Enumeration of the possible watch types - /// - public enum WatchType - { - /// - /// A real variable watch - /// - Watches, - /// - /// The status of the v-stack - /// - VStack, - /// - /// The call stack - /// - CallStack, - /// - /// The list of coroutines - /// - Coroutines, - /// - /// Topmost local variables - /// - Locals, - /// - /// The list of currently active coroutines - /// - Threads, - /// - /// The maximum value of this enum - /// - MaxValue - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounter.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounter.cs deleted file mode 100644 index aa182019..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounter.cs +++ /dev/null @@ -1,31 +0,0 @@ - -namespace MoonSharp.Interpreter.Diagnostics -{ - /// - /// Enumeration of the possible performance counters - /// - public enum PerformanceCounter - { - /// - /// Measures the time spent parsing the source creating the AST - /// - AstCreation, - /// - /// Measures the time spent converting ASTs in bytecode - /// - Compilation, - /// - /// Measures the time spent in executing scripts - /// - Execution, - /// - /// Measures the on the fly creation/compilation of functions in userdata descriptors - /// - AdaptersCompilation, - - /// - /// Sentinel value to get the enum size - /// - LastValue - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounterType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounterType.cs deleted file mode 100644 index 9b427d41..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounterType.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace MoonSharp.Interpreter.Diagnostics -{ - /// - /// Enumeration of unit of measures of the performance counters - /// - public enum PerformanceCounterType - { - /// - /// The performance counter is specified in bytes (of memory) - /// - MemoryBytes, - /// - /// The performance counter is specified in milliseconds - /// - TimeMilliseconds, - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/DummyPerformanceStopwatch.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/DummyPerformanceStopwatch.cs deleted file mode 100644 index 896b74fc..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/DummyPerformanceStopwatch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Diagnostics.PerformanceCounters -{ - class DummyPerformanceStopwatch : IPerformanceStopwatch, IDisposable - { - public static DummyPerformanceStopwatch Instance = new DummyPerformanceStopwatch(); - PerformanceResult m_Result; - - private DummyPerformanceStopwatch() - { - m_Result = new PerformanceResult() - { - Counter = 0, - Global = true, - Instances = 0, - Name = "::dummy::", - Type = PerformanceCounterType.TimeMilliseconds - }; - } - - - public IDisposable Start() - { - return this; - } - - public PerformanceResult GetResult() - { - return m_Result; - } - - public void Dispose() - { - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/GlobalPerformanceStopwatch.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/GlobalPerformanceStopwatch.cs deleted file mode 100644 index a3b13278..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/GlobalPerformanceStopwatch.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Diagnostics.PerformanceCounters -{ - /// - /// This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - /// You are free to reuse this instance after calling Dispose. - /// - internal class GlobalPerformanceStopwatch : IPerformanceStopwatch - { - private class GlobalPerformanceStopwatch_StopwatchObject : IDisposable - { - Stopwatch m_Stopwatch; - GlobalPerformanceStopwatch m_Parent; - - public GlobalPerformanceStopwatch_StopwatchObject(GlobalPerformanceStopwatch parent) - { - m_Parent = parent; - m_Stopwatch = Stopwatch.StartNew(); - } - - public void Dispose() - { - m_Stopwatch.Stop(); - m_Parent.SignalStopwatchTerminated(m_Stopwatch); - } - } - - int m_Count = 0; - long m_Elapsed = 0; - PerformanceCounter m_Counter; - - public GlobalPerformanceStopwatch(PerformanceCounter perfcounter) - { - m_Counter = perfcounter; - } - - private void SignalStopwatchTerminated(Stopwatch sw) - { - m_Elapsed += sw.ElapsedMilliseconds; - m_Count += 1; - } - - public IDisposable Start() - { - return new GlobalPerformanceStopwatch_StopwatchObject(this); - } - - public PerformanceResult GetResult() - { - return new PerformanceResult() - { - Type = PerformanceCounterType.TimeMilliseconds, - Global = false, - Name = m_Counter.ToString(), - Instances = m_Count, - Counter = m_Elapsed - }; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/IPerformanceStopwatch.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/IPerformanceStopwatch.cs deleted file mode 100644 index 16ab7c0b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/IPerformanceStopwatch.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Diagnostics.PerformanceCounters -{ - internal interface IPerformanceStopwatch - { - IDisposable Start(); - PerformanceResult GetResult(); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/PerformanceStopwatch.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/PerformanceStopwatch.cs deleted file mode 100644 index 97b956cb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceCounters/PerformanceStopwatch.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Diagnostics.PerformanceCounters -{ - /// - /// This class is not *really* IDisposable.. it's just use to have a RAII like pattern. - /// You are free to reuse this instance after calling Dispose. - /// - internal class PerformanceStopwatch : IDisposable, IPerformanceStopwatch - { - Stopwatch m_Stopwatch = new Stopwatch(); - int m_Count = 0; - int m_Reentrant = 0; - PerformanceCounter m_Counter; - - public PerformanceStopwatch(PerformanceCounter perfcounter) - { - m_Counter = perfcounter; - } - - - public IDisposable Start() - { - if (m_Reentrant == 0) - { - m_Count += 1; - m_Stopwatch.Start(); - } - - m_Reentrant += 1; - - return this; - } - - public void Dispose() - { - m_Reentrant -= 1; - - if (m_Reentrant == 0) - { - m_Stopwatch.Stop(); - } - } - - public PerformanceResult GetResult() - { - return new PerformanceResult() - { - Type = PerformanceCounterType.TimeMilliseconds, - Global = false, - Name = m_Counter.ToString(), - Instances = m_Count, - Counter = m_Stopwatch.ElapsedMilliseconds - }; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceResult.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceResult.cs deleted file mode 100644 index 2d278715..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceResult.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Diagnostics -{ - /// - /// The result of a performance counter - /// - public class PerformanceResult - { - /// - /// Gets the name of the performance counter which generated this result. - /// - public string Name { get; internal set; } - /// - /// Gets the quantity monitored - see Type to understand what this field contains - /// - public long Counter { get; internal set; } - /// - /// Gets the number of instances which led to the specified counter being incremented - e.g. the times a specific - /// code is executed, or object instanced - /// - public int Instances { get; internal set; } - /// - /// Gets a value indicating whether this is global or relative to the resource - /// for which it's called. - /// - public bool Global { get; internal set; } - /// - /// Gets the unit of measure of the Counter field. - /// - public PerformanceCounterType Type { get; internal set; } - - /// - /// Returns a that represents this instance. - /// - public override string ToString() - { - return string.Format("{0}{1} : {2} times / {3} {4}", - Name, - Global ? "(g)" : "", - Instances, - Counter, - PerformanceCounterTypeToString(Type)); - } - - /// - /// Converts a PerformanceCounterType to a string. - /// - /// The type. - public static string PerformanceCounterTypeToString(PerformanceCounterType Type) - { - switch (Type) - { - case PerformanceCounterType.MemoryBytes: - return "bytes"; - case PerformanceCounterType.TimeMilliseconds: - return "ms"; - default: - throw new InvalidOperationException("PerformanceCounterType has invalid value " + Type.ToString()); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceStatistics.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceStatistics.cs deleted file mode 100644 index c4de85cf..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Diagnostics/PerformanceStatistics.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Text; -using MoonSharp.Interpreter.Diagnostics.PerformanceCounters; - -namespace MoonSharp.Interpreter.Diagnostics -{ - /// - /// A single object of this type exists for every script and gives access to performance statistics. - /// - public class PerformanceStatistics - { - IPerformanceStopwatch[] m_Stopwatches = new IPerformanceStopwatch[(int)PerformanceCounter.LastValue]; - static IPerformanceStopwatch[] m_GlobalStopwatches = new IPerformanceStopwatch[(int)PerformanceCounter.LastValue]; - bool m_Enabled = false; - - - /// - /// Gets or sets a value indicating whether this collection of performance stats is enabled. - /// - /// - /// true if enabled; otherwise, false. - /// - public bool Enabled - { - get { return m_Enabled; } - set - { - if (value && !m_Enabled) - { - if (m_GlobalStopwatches[(int)PerformanceCounter.AdaptersCompilation] == null) - m_GlobalStopwatches[(int)PerformanceCounter.AdaptersCompilation] = new GlobalPerformanceStopwatch(PerformanceCounter.AdaptersCompilation); - - for (int i = 0; i < (int)PerformanceCounter.LastValue; i++) - m_Stopwatches[i] = m_GlobalStopwatches[i] ?? new PerformanceStopwatch((PerformanceCounter)i); - } - else if (!value && m_Enabled) - { - m_Stopwatches = new IPerformanceStopwatch[(int)PerformanceCounter.LastValue]; - m_GlobalStopwatches = new IPerformanceStopwatch[(int)PerformanceCounter.LastValue]; - } - - m_Enabled = value; - } - } - - - /// - /// Gets the result of the specified performance counter . - /// - /// The PerformanceCounter. - /// - public PerformanceResult GetPerformanceCounterResult(PerformanceCounter pc) - { - var pco = m_Stopwatches[(int)pc]; - return (pco != null) ? pco.GetResult() : null; - } - - /// - /// Starts a stopwatch. - /// - /// - internal IDisposable StartStopwatch(PerformanceCounter pc) - { - var pco = m_Stopwatches[(int)pc]; - return (pco != null) ? pco.Start() : null; - } - - /// - /// Starts a stopwatch. - /// - /// - internal static IDisposable StartGlobalStopwatch(PerformanceCounter pc) - { - var pco = m_GlobalStopwatches[(int)pc]; - return (pco != null) ? pco.Start() : null; - } - - /// - /// Gets a string with a complete performance log. - /// - /// - public string GetPerformanceLog() - { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < (int)PerformanceCounter.LastValue; i++) - { - var res = this.GetPerformanceCounterResult((PerformanceCounter)i); - if (res != null) - sb.AppendLine(res.ToString()); - } - - return sb.ToString(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/DynamicExpressionException.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/DynamicExpressionException.cs deleted file mode 100755 index 97a1e960..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/DynamicExpressionException.cs +++ /dev/null @@ -1,34 +0,0 @@ - -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Exception thrown when a dynamic expression is invalid - /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] -#endif - public class DynamicExpressionException : ScriptRuntimeException - { - /// - /// Initializes a new instance of the class. - /// - /// The format. - /// The arguments. - public DynamicExpressionException(string format, params object[] args) - : base(": " + format, args) - { - - } - /// - /// Initializes a new instance of the class. - /// - /// The message. - public DynamicExpressionException(string message) - : base(": " + message) - { - - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InternalErrorException.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InternalErrorException.cs deleted file mode 100755 index 651d2eea..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InternalErrorException.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Exception thrown when an inconsistent state is reached in the interpreter - /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] -#endif - public class InternalErrorException : InterpreterException - { - internal InternalErrorException(string message) - : base(message) - { - - } - - internal InternalErrorException(string format, params object[] args) - : base(format, args) - { - - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InterpreterException.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InterpreterException.cs deleted file mode 100755 index a63fe83c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/InterpreterException.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter -{ - /// - /// Base type of all exceptions thrown in MoonSharp - /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] -#endif - public class InterpreterException : Exception - { - /// - /// Initializes a new instance of the class. - /// - /// The ex. - protected InterpreterException(Exception ex, string message) - : base(message, ex) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The ex. - protected InterpreterException(Exception ex) - : base(ex.Message, ex) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The message that describes the error. - protected InterpreterException(string message) - : base(message) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The format. - /// The arguments. - protected InterpreterException(string format, params object[] args) - : base(string.Format(format, args)) - { - - } - - /// - /// Gets the instruction pointer of the execution (if it makes sense) - /// - public int InstructionPtr { get; internal set; } - - /// - /// Gets the interpreter call stack. - /// - public IList CallStack { get; internal set; } - - /// - /// Gets the decorated message (error message plus error location in script) if possible. - /// - public string DecoratedMessage { get; internal set; } - - - /// - /// Gets or sets a value indicating whether the message should not be decorated - /// - public bool DoNotDecorateMessage { get; set; } - - - internal void DecorateMessage(Script script, SourceRef sref, int ip = -1) - { - if (string.IsNullOrEmpty(this.DecoratedMessage)) - { - if (DoNotDecorateMessage) - { - this.DecoratedMessage = this.Message; - return; - } - else if (sref != null) - { - this.DecoratedMessage = string.Format("{0}: {1}", sref.FormatLocation(script), this.Message); - } - else - { - this.DecoratedMessage = string.Format("bytecode:{0}: {1}", ip, this.Message); - } - } - } - - - /// - /// Rethrows this instance if - /// - /// - public virtual void Rethrow() - { - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/ScriptRuntimeException.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/ScriptRuntimeException.cs deleted file mode 100755 index 1dfb721d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/ScriptRuntimeException.cs +++ /dev/null @@ -1,520 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter -{ - /// - /// Exception for all runtime errors. In addition to constructors, it offers a lot of static methods - /// generating more "standard" Lua errors. - /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] -#endif - public class ScriptRuntimeException : InterpreterException - { - /// - /// Initializes a new instance of the class. - /// - /// The ex. - public ScriptRuntimeException(Exception ex) - : base(ex) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The ex. - public ScriptRuntimeException(ScriptRuntimeException ex) - : base(ex, ex.DecoratedMessage) - { - this.DecoratedMessage = Message; - this.DoNotDecorateMessage = true; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The message that describes the error. - public ScriptRuntimeException(string message) - : base(message) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The format. - /// The arguments. - public ScriptRuntimeException(string format, params object[] args) - : base(format, args) - { - - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an arithmetic operation was attempted on non-numbers - /// - /// The left operand. - /// The right operand (or null). - /// The exception to be raised. - /// If both are numbers - public static ScriptRuntimeException ArithmeticOnNonNumber(DynValue l, DynValue r = null) - { - if (l.Type != DataType.Number && l.Type != DataType.String) - return new ScriptRuntimeException("attempt to perform arithmetic on a {0} value", l.Type.ToLuaTypeString()); - else if (r != null && r.Type != DataType.Number && r.Type != DataType.String) - return new ScriptRuntimeException("attempt to perform arithmetic on a {0} value", r.Type.ToLuaTypeString()); - else if (l.Type == DataType.String || (r != null && r.Type == DataType.String)) - return new ScriptRuntimeException("attempt to perform arithmetic on a string value"); - else - throw new InternalErrorException("ArithmeticOnNonNumber - both are numbers"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a concat operation was attempted on non-strings - /// - /// The left operand. - /// The right operand. - /// The exception to be raised. - /// If both are numbers or strings - public static ScriptRuntimeException ConcatOnNonString(DynValue l, DynValue r) - { - if (l.Type != DataType.Number && l.Type != DataType.String) - return new ScriptRuntimeException("attempt to concatenate a {0} value", l.Type.ToLuaTypeString()); - else if (r != null && r.Type != DataType.Number && r.Type != DataType.String) - return new ScriptRuntimeException("attempt to concatenate a {0} value", r.Type.ToLuaTypeString()); - else - throw new InternalErrorException("ConcatOnNonString - both are numbers/strings"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a len operator was applied on an invalid operand - /// - /// The operand. - /// The exception to be raised. - public static ScriptRuntimeException LenOnInvalidType(DynValue r) - { - return new ScriptRuntimeException("attempt to get length of a {0} value", r.Type.ToLuaTypeString()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a comparison operator was applied on an invalid combination of operand types - /// - /// The left operand. - /// The right operand. - /// The exception to be raised. - public static ScriptRuntimeException CompareInvalidType(DynValue l, DynValue r) - { - if (l.Type.ToLuaTypeString() == r.Type.ToLuaTypeString()) - return new ScriptRuntimeException("attempt to compare two {0} values", l.Type.ToLuaTypeString()); - else - return new ScriptRuntimeException("attempt to compare {0} with {1}", l.Type.ToLuaTypeString(), r.Type.ToLuaTypeString()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with a bad argument - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// The error message. - /// The exception to be raised. - public static ScriptRuntimeException BadArgument(int argNum, string funcName, string message) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' ({2})", argNum + 1, funcName, message); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with a bad userdata argument - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// The expected System.Type. - /// The object which was used. - /// True if nils were allowed in this call. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgumentUserData(int argNum, string funcName, Type expected, object got, bool allowNil) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' (userdata<{2}>{3} expected, got {4})", - argNum + 1, - funcName, - expected.Name, - allowNil ? "nil or " : "", - got != null ? "userdata<" + got.GetType().Name + ">" : "null" - ); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with a bad argument - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// The expected data type. - /// The data type received. - /// True if nils were allowed in this call. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgument(int argNum, string funcName, DataType expected, DataType got, bool allowNil) - { - return BadArgument(argNum, funcName, expected.ToErrorTypeString(), got.ToErrorTypeString(), allowNil); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with a bad argument - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// The expected type description. - /// The description of the type received. - /// True if nils were allowed in this call. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgument(int argNum, string funcName, string expected, string got, bool allowNil) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' ({2}{3} expected, got {4})", - argNum + 1, funcName, allowNil ? "nil or " : "", expected, got); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with no value when a value was required. - /// - /// This function creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - /// while creates a message like "bad argument #xxx to 'yyy' (value expected)" - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// The expected data type. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgumentNoValue(int argNum, string funcName, DataType expected) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' ({2} expected, got no value)", - argNum + 1, funcName, expected.ToErrorTypeString()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an out of range index was specified - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgumentIndexOutOfRange(string funcName, int argNum) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' (index out of range)", argNum + 1, funcName); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with a negative number when a positive one was expected. - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgumentNoNegativeNumbers(int argNum, string funcName) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' (not a non-negative number in proper range)", - argNum + 1, funcName); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a function was called with no value when a value was required. - /// This function creates a message like "bad argument #xxx to 'yyy' (value expected)" - /// while creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)" - /// - /// The argument number (0-based). - /// Name of the function generating this error. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException BadArgumentValueExpected(int argNum, string funcName) - { - return new ScriptRuntimeException("bad argument #{0} to '{1}' (value expected)", - argNum + 1, funcName); - } - - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an invalid attempt to index the specified object was made - /// - /// The object. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException IndexType(DynValue obj) - { - return new ScriptRuntimeException("attempt to index a {0} value", obj.Type.ToLuaTypeString()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a loop was detected when performing __index over metatables. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException LoopInIndex() - { - return new ScriptRuntimeException("loop in gettable"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a loop was detected when performing __newindex over metatables. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException LoopInNewIndex() - { - return new ScriptRuntimeException("loop in settable"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a loop was detected when performing __call over metatables. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException LoopInCall() - { - return new ScriptRuntimeException("loop in call"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a table indexing operation used nil as the key. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException TableIndexIsNil() - { - return new ScriptRuntimeException("table index is nil"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a table indexing operation used a NaN as the key. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException TableIndexIsNaN() - { - return new ScriptRuntimeException("table index is NaN"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a conversion to number failed. - /// - /// - /// Selects the correct error message: - /// 0 - "value must be a number" - /// 1 - "'for' initial value must be a number" - /// 2 - "'for' step must be a number" - /// 3 - "'for' limit must be a number" - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException ConvertToNumberFailed(int stage) - { - switch (stage) - { - case 1: - return new ScriptRuntimeException("'for' initial value must be a number"); - case 2: - return new ScriptRuntimeException("'for' step must be a number"); - case 3: - return new ScriptRuntimeException("'for' limit must be a number"); - default: - return new ScriptRuntimeException("value must be a number"); - } - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a conversion of a CLR type to a Lua type has failed. - /// - /// The object which could not be converted. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException ConvertObjectFailed(object obj) - { - return new ScriptRuntimeException("cannot convert clr type {0}", obj.GetType()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a conversion of a Lua type to a CLR type has failed. - /// - /// The Lua type. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException ConvertObjectFailed(DataType t) - { - return new ScriptRuntimeException("cannot convert a {0} to a clr type", t.ToString().ToLowerInvariant()); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a constrained conversion of a Lua type to a CLR type has failed. - /// - /// The Lua type. - /// The expected CLR type. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException ConvertObjectFailed(DataType t, Type t2) - { - return new ScriptRuntimeException("cannot convert a {0} to a clr type {1}", t.ToString().ToLowerInvariant(), t2.FullName); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// a userdata of a specific CLR type was expected and a non-userdata type was passed. - /// - /// The Lua type. - /// The expected CLR type. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException UserDataArgumentTypeMismatch(DataType t, Type clrType) - { - return new ScriptRuntimeException("cannot find a conversion from a MoonSharp {0} to a clr {1}", t.ToString().ToLowerInvariant(), clrType.FullName); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to index an invalid member of a userdata was done. - /// - /// The name of the userdata type. - /// The field name. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException UserDataMissingField(string typename, string fieldname) - { - return new ScriptRuntimeException("cannot access field {0} of userdata<{1}>", fieldname, typename); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt resume a coroutine in an invalid state was done. - /// - /// The state of the coroutine. - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException CannotResumeNotSuspended(CoroutineState state) - { - if (state == CoroutineState.Dead) - return new ScriptRuntimeException("cannot resume dead coroutine"); - else - return new ScriptRuntimeException("cannot resume non-suspended coroutine"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to yield across a CLR boundary was made. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException CannotYield() - { - return new ScriptRuntimeException("attempt to yield across a CLR-call boundary"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to yield from the main coroutine was made. - /// - /// - /// The exception to be raised. - /// - public static ScriptRuntimeException CannotYieldMain() - { - return new ScriptRuntimeException("attempt to yield from outside a coroutine"); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to call a non-function was made - /// - /// The lua non-function data type. - /// The debug text to aid location (appears as "near 'xxx'"). - /// - public static ScriptRuntimeException AttemptToCallNonFunc(DataType type, string debugText = null) - { - string functype = type.ToErrorTypeString(); - - if (debugText != null) - return new ScriptRuntimeException("attempt to call a {0} value near '{1}'", functype, debugText); - else - return new ScriptRuntimeException("attempt to call a {0} value", functype); - } - - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to access a non-static member from a static userdata was made - /// - /// The member descriptor. - public static ScriptRuntimeException AccessInstanceMemberOnStatics(IMemberDescriptor desc) - { - return new ScriptRuntimeException("attempt to access instance member {0} from a static userdata", desc.Name); - } - - /// - /// Creates a ScriptRuntimeException with a predefined error message specifying that - /// an attempt to access a non-static member from a static userdata was made - /// - /// The type descriptor. - /// The member descriptor. - /// - public static ScriptRuntimeException AccessInstanceMemberOnStatics(IUserDataDescriptor typeDescr, IMemberDescriptor desc) - { - return new ScriptRuntimeException("attempt to access instance member {0}.{1} from a static userdata", typeDescr.Name, desc.Name); - } - - /// - /// Rethrows this instance if - /// - /// - public override void Rethrow() - { - if (Script.GlobalOptions.RethrowExceptionNested) - throw new ScriptRuntimeException(this); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/SyntaxErrorException.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/SyntaxErrorException.cs deleted file mode 100755 index 8bb572f6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Errors/SyntaxErrorException.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Tree; - -namespace MoonSharp.Interpreter -{ - /// - /// Exception for all parsing/lexing errors. - /// -#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] -#endif - public class SyntaxErrorException : InterpreterException - { - internal Token Token { get; private set; } - - /// - /// Gets or sets a value indicating whether this exception was caused by premature stream termination (that is, unexpected EOF). - /// This can be used in REPL interfaces to tell between unrecoverable errors and those which can be recovered by extra input. - /// - public bool IsPrematureStreamTermination { get; set; } - - internal SyntaxErrorException(Token t, string format, params object[] args) - : base(format, args) - { - Token = t; - } - - internal SyntaxErrorException(Token t, string message) - : base(message) - { - Token = t; - } - - internal SyntaxErrorException(Script script, SourceRef sref, string format, params object[] args) - : base(format, args) - { - DecorateMessage(script, sref); - } - - internal SyntaxErrorException(Script script, SourceRef sref, string message) - : base(message) - { - DecorateMessage(script, sref); - } - - private SyntaxErrorException(SyntaxErrorException syntaxErrorException) - : base(syntaxErrorException, syntaxErrorException.DecoratedMessage) - { - this.Token = syntaxErrorException.Token; - this.DecoratedMessage = Message; - } - - internal void DecorateMessage(Script script) - { - if (Token != null) - { - DecorateMessage(script, Token.GetSourceRef(false)); - } - } - - /// - /// Rethrows this instance if - /// - /// - public override void Rethrow() - { - if (Script.GlobalOptions.RethrowExceptionNested) - throw new SyntaxErrorException(this); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/DynamicExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/DynamicExpression.cs deleted file mode 100644 index e53b92c6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/DynamicExpression.cs +++ /dev/null @@ -1,114 +0,0 @@ -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter -{ - /// - /// Represents a dynamic expression in the script - /// - public class DynamicExpression : IScriptPrivateResource - { - DynamicExprExpression m_Exp; - DynValue m_Constant; - - /// - /// The code which generated this expression - /// - public readonly string ExpressionCode; - - internal DynamicExpression(Script S, string strExpr, DynamicExprExpression expr) - { - ExpressionCode = strExpr; - OwnerScript = S; - m_Exp = expr; - } - - internal DynamicExpression(Script S, string strExpr, DynValue constant) - { - ExpressionCode = strExpr; - OwnerScript = S; - m_Constant = constant; - } - - /// - /// Evaluates the expression - /// - /// The context. - /// - public DynValue Evaluate(ScriptExecutionContext context = null) - { - context = context ?? OwnerScript.CreateDynamicExecutionContext(); - - this.CheckScriptOwnership(context.GetScript()); - - if (m_Constant != null) - return m_Constant; - - return m_Exp.Eval(context); - } - - /// - /// Finds a symbol in the expression - /// - /// The context. - /// - public SymbolRef FindSymbol(ScriptExecutionContext context) - { - this.CheckScriptOwnership(context.GetScript()); - - if (m_Exp != null) - return m_Exp.FindDynamic(context); - else - return null; - } - - /// - /// Gets the script owning this resource. - /// - /// - /// The script owning this resource. - /// - public Script OwnerScript - { - get; - private set; - } - - /// - /// Determines whether this instance is a constant expression - /// - /// - public bool IsConstant() - { - return m_Constant != null; - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return ExpressionCode.GetHashCode(); - } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - DynamicExpression o = obj as DynamicExpression; - - if (o == null) - return false; - - return o.ExpressionCode == this.ExpressionCode; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/InstructionFieldUsage.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/InstructionFieldUsage.cs deleted file mode 100644 index ca018ecd..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/InstructionFieldUsage.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Execution -{ - [Flags] - internal enum InstructionFieldUsage - { - None = 0, - Symbol = 0x1, - SymbolList = 0x2, - Name = 0x4, - Value = 0x8, - NumVal = 0x10, - NumVal2 = 0x20, - NumValAsCodeAddress = 0x8010 - } - - internal static class InstructionFieldUsage_Extensions - { - internal static InstructionFieldUsage GetFieldUsage(this OpCode op) - { - switch (op) - { - case OpCode.TblInitN: - case OpCode.Scalar: - case OpCode.IterUpd: - case OpCode.IterPrep: - case OpCode.NewTable: - case OpCode.Concat: - case OpCode.LessEq: - case OpCode.Less: - case OpCode.Eq: - case OpCode.Add: - case OpCode.Sub: - case OpCode.Mul: - case OpCode.Div: - case OpCode.Mod: - case OpCode.Not: - case OpCode.Len: - case OpCode.Neg: - case OpCode.Power: - case OpCode.CNot: - case OpCode.ToBool: - return InstructionFieldUsage.None; - case OpCode.Pop: - case OpCode.Copy: - case OpCode.TblInitI: - case OpCode.ExpTuple: - case OpCode.Incr: - case OpCode.ToNum: - case OpCode.Ret: - case OpCode.MkTuple: - return InstructionFieldUsage.NumVal; - case OpCode.Jump: - case OpCode.Jf: - case OpCode.JNil: - case OpCode.JFor: - case OpCode.JtOrPop: - case OpCode.JfOrPop: - return InstructionFieldUsage.NumValAsCodeAddress; - case OpCode.Swap: - case OpCode.Clean: - return InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; - case OpCode.Local: - case OpCode.Upvalue: - return InstructionFieldUsage.Symbol; - case OpCode.IndexSet: - case OpCode.IndexSetN: - case OpCode.IndexSetL: - return InstructionFieldUsage.Symbol | InstructionFieldUsage.Value | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; - case OpCode.StoreLcl: - case OpCode.StoreUpv: - return InstructionFieldUsage.Symbol | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; - case OpCode.Index: - case OpCode.IndexL: - case OpCode.IndexN: - case OpCode.Literal: - return InstructionFieldUsage.Value; - case OpCode.Args: - return InstructionFieldUsage.SymbolList; - case OpCode.BeginFn: - return InstructionFieldUsage.SymbolList | InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2; - case OpCode.Closure: - return InstructionFieldUsage.SymbolList | InstructionFieldUsage.NumVal; - case OpCode.Nop: - case OpCode.Debug: - case OpCode.Invalid: - return InstructionFieldUsage.Name; - case OpCode.Call: - case OpCode.ThisCall: - return InstructionFieldUsage.NumVal | InstructionFieldUsage.Name; - case OpCode.Meta: - return InstructionFieldUsage.NumVal | InstructionFieldUsage.NumVal2 | InstructionFieldUsage.Value | InstructionFieldUsage.Name; - default: - throw new NotImplementedException(string.Format("InstructionFieldUsage for instruction {0}", (int)op)); - } - } - } - - - - - - - - - - - - - - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScope.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScope.cs deleted file mode 100644 index 63a83282..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScope.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Execution.Scopes; -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Execution -{ - internal class BuildTimeScope - { - List m_Frames = new List(); - List m_ClosureBuilders = new List(); - - - public void PushFunction(IClosureBuilder closureBuilder, bool hasVarArgs) - { - m_ClosureBuilders.Add(closureBuilder); - m_Frames.Add(new BuildTimeScopeFrame(hasVarArgs)); - } - - public void PushBlock() - { - m_Frames.Last().PushBlock(); - } - - public RuntimeScopeBlock PopBlock() - { - return m_Frames.Last().PopBlock(); - } - - public RuntimeScopeFrame PopFunction() - { - var last = m_Frames.Last(); - last.ResolveLRefs(); - m_Frames.RemoveAt(m_Frames.Count - 1); - - m_ClosureBuilders.RemoveAt(m_ClosureBuilders.Count - 1); - - return last.GetRuntimeFrameData(); - } - - - public SymbolRef Find(string name) - { - SymbolRef local = m_Frames.Last().Find(name); - - if (local != null) - return local; - - for (int i = m_Frames.Count - 2; i >= 0; i--) - { - SymbolRef symb = m_Frames[i].Find(name); - - if (symb != null) - { - symb = CreateUpValue(this, symb, i, m_Frames.Count - 2); - - if (symb != null) - return symb; - } - } - - return CreateGlobalReference(name); - } - - public SymbolRef CreateGlobalReference(string name) - { - if (name == WellKnownSymbols.ENV) - throw new InternalErrorException("_ENV passed in CreateGlobalReference"); - - SymbolRef env = Find(WellKnownSymbols.ENV); - return SymbolRef.Global(name, env); - } - - - public void ForceEnvUpValue() - { - Find(WellKnownSymbols.ENV); - } - - private SymbolRef CreateUpValue(BuildTimeScope buildTimeScope, SymbolRef symb, int closuredFrame, int currentFrame) - { - // it's a 0-level upvalue. Just create it and we're done. - if (closuredFrame == currentFrame) - return m_ClosureBuilders[currentFrame + 1].CreateUpvalue(this, symb); - - SymbolRef upvalue = CreateUpValue(buildTimeScope, symb, closuredFrame, currentFrame - 1); - - return m_ClosureBuilders[currentFrame + 1].CreateUpvalue(this, upvalue); - } - - public SymbolRef DefineLocal(string name) - { - return m_Frames.Last().DefineLocal(name); - } - - public SymbolRef TryDefineLocal(string name) - { - return m_Frames.Last().TryDefineLocal(name); - } - - public bool CurrentFunctionHasVarArgs() - { - return m_Frames.Last().HasVarArgs; - } - - internal void DefineLabel(LabelStatement label) - { - m_Frames.Last().DefineLabel(label); - } - - internal void RegisterGoto(GotoStatement gotostat) - { - m_Frames.Last().RegisterGoto(gotostat); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeBlock.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeBlock.cs deleted file mode 100644 index 78987b41..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeBlock.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Execution.Scopes -{ - internal class BuildTimeScopeBlock - { - internal BuildTimeScopeBlock Parent { get; private set; } - internal List ChildNodes { get; private set; } - - internal RuntimeScopeBlock ScopeBlock { get; private set; } - - Dictionary m_DefinedNames = new Dictionary(); - - - - internal void Rename(string name) - { - SymbolRef sref = m_DefinedNames[name]; - m_DefinedNames.Remove(name); - m_DefinedNames.Add(string.Format("@{0}_{1}", name, Guid.NewGuid().ToString("N")), sref); - } - - internal BuildTimeScopeBlock(BuildTimeScopeBlock parent) - { - Parent = parent; - ChildNodes = new List(); - ScopeBlock = new RuntimeScopeBlock(); - } - - - internal BuildTimeScopeBlock AddChild() - { - BuildTimeScopeBlock block = new BuildTimeScopeBlock(this); - ChildNodes.Add(block); - return block; - } - - internal SymbolRef Find(string name) - { - return m_DefinedNames.GetOrDefault(name); - } - - internal SymbolRef Define(string name) - { - SymbolRef l = SymbolRef.Local(name, -1); - m_DefinedNames.Add(name, l); - m_LastDefinedName = name; - return l; - } - - internal int ResolveLRefs(BuildTimeScopeFrame buildTimeScopeFrame) - { - int firstVal = -1; - int lastVal = -1; - - foreach (SymbolRef lref in m_DefinedNames.Values) - { - int pos = buildTimeScopeFrame.AllocVar(lref); - - if (firstVal < 0) - firstVal = pos; - - lastVal = pos; - } - - this.ScopeBlock.From = firstVal; - this.ScopeBlock.ToInclusive = this.ScopeBlock.To = lastVal; - - if (firstVal < 0) - this.ScopeBlock.From = buildTimeScopeFrame.GetPosForNextVar(); - - foreach (var child in ChildNodes) - { - this.ScopeBlock.ToInclusive = Math.Max(this.ScopeBlock.ToInclusive, child.ResolveLRefs(buildTimeScopeFrame)); - } - - if (m_LocalLabels != null) - foreach (var label in m_LocalLabels.Values) - label.SetScope(this.ScopeBlock); - - return this.ScopeBlock.ToInclusive; - } - - - List m_PendingGotos; - Dictionary m_LocalLabels; - string m_LastDefinedName; - - internal void DefineLabel(LabelStatement label) - { - if (m_LocalLabels == null) - m_LocalLabels = new Dictionary(); - - if (m_LocalLabels.ContainsKey(label.Label)) - { - throw new SyntaxErrorException(label.NameToken, "label '{0}' already defined on line {1}", label.Label, m_LocalLabels[label.Label].SourceRef.FromLine); - } - else - { - m_LocalLabels.Add(label.Label, label); - label.SetDefinedVars(m_DefinedNames.Count, m_LastDefinedName); - } - } - - internal void RegisterGoto(GotoStatement gotostat) - { - if (m_PendingGotos == null) - m_PendingGotos = new List(); - - m_PendingGotos.Add(gotostat); - gotostat.SetDefinedVars(m_DefinedNames.Count, m_LastDefinedName); - } - - internal void ResolveGotos() - { - if (m_PendingGotos == null) - return; - - foreach (GotoStatement gotostat in m_PendingGotos) - { - LabelStatement label; - - if (m_LocalLabels != null && m_LocalLabels.TryGetValue(gotostat.Label, out label)) - { - if (label.DefinedVarsCount > gotostat.DefinedVarsCount) - throw new SyntaxErrorException(gotostat.GotoToken, - " at line {1} jumps into the scope of local '{2}'", gotostat.Label, - gotostat.GotoToken.FromLine, - label.LastDefinedVarName); - - label.RegisterGoto(gotostat); - } - else - { - if (Parent == null) - throw new SyntaxErrorException(gotostat.GotoToken, "no visible label '{0}' for at line {1}", gotostat.Label, - gotostat.GotoToken.FromLine); - - Parent.RegisterGoto(gotostat); - } - } - - m_PendingGotos.Clear(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeFrame.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeFrame.cs deleted file mode 100644 index 7d22709f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/BuildTimeScopeFrame.cs +++ /dev/null @@ -1,105 +0,0 @@ -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Execution.Scopes -{ - internal class BuildTimeScopeFrame - { - BuildTimeScopeBlock m_ScopeTreeRoot; - BuildTimeScopeBlock m_ScopeTreeHead; - RuntimeScopeFrame m_ScopeFrame = new RuntimeScopeFrame(); - - public bool HasVarArgs { get; private set;} - - internal BuildTimeScopeFrame(bool hasVarArgs) - { - HasVarArgs = hasVarArgs; - m_ScopeTreeHead = m_ScopeTreeRoot = new BuildTimeScopeBlock(null); - } - - internal void PushBlock() - { - m_ScopeTreeHead = m_ScopeTreeHead.AddChild(); - } - - internal RuntimeScopeBlock PopBlock() - { - var tree = m_ScopeTreeHead; - - m_ScopeTreeHead.ResolveGotos(); - - m_ScopeTreeHead = m_ScopeTreeHead.Parent; - - if (m_ScopeTreeHead == null) - throw new InternalErrorException("Can't pop block - stack underflow"); - - return tree.ScopeBlock; - } - - internal RuntimeScopeFrame GetRuntimeFrameData() - { - if (m_ScopeTreeHead != m_ScopeTreeRoot) - throw new InternalErrorException("Misaligned scope frames/blocks!"); - - m_ScopeFrame.ToFirstBlock = m_ScopeTreeRoot.ScopeBlock.To; - - return m_ScopeFrame; - } - - internal SymbolRef Find(string name) - { - for (var tree = m_ScopeTreeHead; tree != null; tree = tree.Parent) - { - SymbolRef l = tree.Find(name); - - if (l != null) - return l; - } - - return null; - } - - internal SymbolRef DefineLocal(string name) - { - return m_ScopeTreeHead.Define(name); - } - - internal SymbolRef TryDefineLocal(string name) - { - if (m_ScopeTreeHead.Find(name) != null) - { - m_ScopeTreeHead.Rename(name); - } - - return m_ScopeTreeHead.Define(name); - } - - internal void ResolveLRefs() - { - m_ScopeTreeRoot.ResolveGotos(); - - m_ScopeTreeRoot.ResolveLRefs(this); - } - - internal int AllocVar(SymbolRef var) - { - var.i_Index = m_ScopeFrame.DebugSymbols.Count; - m_ScopeFrame.DebugSymbols.Add(var); - return var.i_Index; - } - - internal int GetPosForNextVar() - { - return m_ScopeFrame.DebugSymbols.Count; - } - - internal void DefineLabel(LabelStatement label) - { - m_ScopeTreeHead.DefineLabel(label); - } - - internal void RegisterGoto(GotoStatement gotostat) - { - m_ScopeTreeHead.RegisterGoto(gotostat); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/ClosureContext.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/ClosureContext.cs deleted file mode 100644 index 095fcd5b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/ClosureContext.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace MoonSharp.Interpreter.Execution -{ - /// - /// The scope of a closure (container of upvalues) - /// - internal class ClosureContext : List - { - /// - /// Gets the symbols. - /// - public string[] Symbols { get; private set; } - - internal ClosureContext(SymbolRef[] symbols, IEnumerable values) - { - Symbols = symbols.Select(s => s.i_Name).ToArray(); - this.AddRange(values); - } - - internal ClosureContext() - { - Symbols = new string[0]; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/IClosureBuilder.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/IClosureBuilder.cs deleted file mode 100644 index e13b3b97..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/IClosureBuilder.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace MoonSharp.Interpreter.Execution -{ - internal interface IClosureBuilder - { - SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol); - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/LoopTracker.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/LoopTracker.cs deleted file mode 100644 index d9dd8292..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/LoopTracker.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MoonSharp.Interpreter.DataStructs; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Execution -{ - interface ILoop - { - void CompileBreak(ByteCode bc); - bool IsBoundary(); - } - - - internal class LoopTracker - { - public FastStack Loops = new FastStack(16384); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeBlock.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeBlock.cs deleted file mode 100644 index 46dca397..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeBlock.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Execution -{ - internal class RuntimeScopeBlock - { - public int From { get; internal set; } - public int To { get; internal set; } - public int ToInclusive { get; internal set; } - - public override string ToString() - { - return String.Format("ScopeBlock : {0} -> {1} --> {2}", From, To, ToInclusive); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeFrame.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeFrame.cs deleted file mode 100644 index 0738dc3b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/Scopes/RuntimeScopeFrame.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Execution -{ - internal class RuntimeScopeFrame - { - public List DebugSymbols { get; private set; } - public int Count { get { return DebugSymbols.Count; } } - public int ToFirstBlock { get; internal set; } - - public RuntimeScopeFrame() - { - DebugSymbols = new List(); - } - - public override string ToString() - { - return string.Format("ScopeFrame : #{0}", Count); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptExecutionContext.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptExecutionContext.cs deleted file mode 100644 index 0a42ccfb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptExecutionContext.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution.VM; -using MoonSharp.Interpreter.Interop.LuaStateInterop; - -namespace MoonSharp.Interpreter -{ - /// - /// Class giving access to details of the environment where the script is executing - /// - public class ScriptExecutionContext : IScriptPrivateResource - { - Processor m_Processor; - CallbackFunction m_Callback; - - internal ScriptExecutionContext(Processor p, CallbackFunction callBackFunction, SourceRef sourceRef, bool isDynamic = false) - { - IsDynamicExecution = isDynamic; - m_Processor = p; - m_Callback = callBackFunction; - CallingLocation = sourceRef; - } - - /// - /// Gets a value indicating whether this instance is running a dynamic execution. - /// Under a dynamic execution, most methods of ScriptExecutionContext are not reliable as the - /// processing engine of the script is not "really" running or is not available. - /// - public bool IsDynamicExecution - { - get; - private set; - } - - /// - /// Gets the location of the code calling back - /// - public SourceRef CallingLocation - { - get; - private set; - } - - /// - /// Gets or sets the additional data associated to this CLR function call. - /// - public object AdditionalData - { - get { return (m_Callback != null) ? m_Callback.AdditionalData : null; } - set - { - if (m_Callback == null) throw new InvalidOperationException("Cannot set additional data on a context which has no callback"); - m_Callback.AdditionalData = value; - } - } - - - /// - /// Gets the metatable associated with the given value. - /// - /// The value. - /// - public Table GetMetatable(DynValue value) - { - return m_Processor.GetMetatable(value); - } - - - /// - /// Gets the specified metamethod associated with the given value. - /// - /// The value. - /// The metamethod name. - /// - public DynValue GetMetamethod(DynValue value, string metamethod) - { - return m_Processor.GetMetamethod(value, metamethod); - } - - /// - /// prepares a tail call request for the specified metamethod, or null if no metamethod is found. - /// - public DynValue GetMetamethodTailCall(DynValue value, string metamethod, params DynValue[] args) - { - DynValue meta = this.GetMetamethod(value, metamethod); - if (meta == null) return null; - return DynValue.NewTailCallReq(meta, args); - } - - /// - /// Gets the metamethod to be used for a binary operation using op1 and op2. - /// - public DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventName) - { - return m_Processor.GetBinaryMetamethod(op1, op2, eventName); - } - - /// - /// Gets the script object associated with this request - /// - /// - public Script GetScript() - { - return m_Processor.GetScript(); - } - - /// - /// Gets the coroutine which is performing the call - /// - public Coroutine GetCallingCoroutine() - { - return m_Processor.AssociatedCoroutine; - } - - /// - /// Calls a callback function implemented in "classic way". - /// Useful to port C code from Lua, or C# code from UniLua and KopiLua. - /// Lua : http://www.lua.org/ - /// UniLua : http://github.com/xebecnan/UniLua - /// KopiLua : http://github.com/NLua/KopiLua - /// - /// The arguments. - /// Name of the function - for error messages. - /// The callback. - /// - public DynValue EmulateClassicCall(CallbackArguments args, string functionName, Func callback) - { - LuaState L = new LuaState(this, args, functionName); - int retvals = callback(L); - return L.GetReturnValue(retvals); - } - - /// - /// Calls the specified function, supporting most cases. The called function must not yield. - /// - /// The function; it must be a Function or ClrFunction or have a call metamethod defined. - /// The arguments. - /// - /// If the function yields, returns a tail call request with continuations/handlers or, of course, if it encounters errors. - public DynValue Call(DynValue func, params DynValue[] args) - { - if (func.Type == DataType.Function) - { - return this.GetScript().Call(func, args); - } - else if (func.Type == DataType.ClrFunction) - { - while (true) - { - DynValue ret = func.Callback.Invoke(this, args, false); - - if (ret.Type == DataType.YieldRequest) - { - throw ScriptRuntimeException.CannotYield(); - } - else if (ret.Type == DataType.TailCallRequest) - { - var tail = ret.TailCallData; - - if (tail.Continuation != null || tail.ErrorHandler != null) - { - throw new ScriptRuntimeException("the function passed cannot be called directly. wrap in a script function instead."); - } - else - { - args = tail.Args; - func = tail.Function; - } - } - else - { - return ret; - } - } - } - else - { - int maxloops = 10; - - while (maxloops > 0) - { - DynValue v = this.GetMetamethod(func, "__call"); - - if (v == null && v.IsNil()) - { - throw ScriptRuntimeException.AttemptToCallNonFunc(func.Type); - } - - func = v; - - if (func.Type == DataType.Function || func.Type == DataType.ClrFunction) - { - return Call(func, args); - } - } - - throw ScriptRuntimeException.LoopInCall(); - } - } - - /// - /// Tries to get the reference of a symbol in the current execution state - /// - public DynValue EvaluateSymbol(SymbolRef symref) - { - if (symref == null) - return DynValue.Nil; - - return m_Processor.GetGenericSymbol(symref); - } - - /// - /// Tries to get the value of a symbol in the current execution state - /// - public DynValue EvaluateSymbolByName(string symbol) - { - return this.EvaluateSymbol(this.FindSymbolByName(symbol)); - } - - /// - /// Finds a symbol by name in the current execution state - /// - public SymbolRef FindSymbolByName(string symbol) - { - return m_Processor.FindSymbolByName(symbol); - } - - /// - /// Gets the current global env, or null if not found. - /// - public Table CurrentGlobalEnv - { - get - { - DynValue env = EvaluateSymbolByName(WellKnownSymbols.ENV); - - if (env == null || env.Type != DataType.Table) - return null; - else return env.Table; - } - } - - /// - /// Performs a message decoration before unwinding after an error. To be used in the implementation of xpcall like functions. - /// - /// The message handler. - /// The exception. - public void PerformMessageDecorationBeforeUnwind(DynValue messageHandler, ScriptRuntimeException exception) - { - if (messageHandler != null) - exception.DecoratedMessage = m_Processor.PerformMessageDecorationBeforeUnwind(messageHandler, exception.Message, CallingLocation); - else - exception.DecoratedMessage = exception.Message; - } - - - /// - /// Gets the script owning this resource. - /// - /// - /// The script owning this resource. - /// - public Script OwnerScript - { - get { return this.GetScript(); } - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptLoadingContext.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptLoadingContext.cs deleted file mode 100644 index 69093c10..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/ScriptLoadingContext.cs +++ /dev/null @@ -1,21 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Tree; - -namespace MoonSharp.Interpreter.Execution -{ - class ScriptLoadingContext - { - public Script Script { get; private set; } - public BuildTimeScope Scope { get; set; } - public SourceCode Source { get; set; } - public bool Anonymous { get; set; } - public bool IsDynamicExpression { get; set; } - public Lexer Lexer { get; set; } - - public ScriptLoadingContext(Script s) - { - Script = s; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ByteCode.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ByteCode.cs deleted file mode 100755 index 41a66e89..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ByteCode.cs +++ /dev/null @@ -1,331 +0,0 @@ -#define EMIT_DEBUG_OPS - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - internal class ByteCode : RefIdObject - { - public List Code = new List(); - public Script Script { get; private set; } - private List m_SourceRefStack = new List(); - private SourceRef m_CurrentSourceRef = null; - - internal LoopTracker LoopTracker = new LoopTracker(); - - public ByteCode(Script script) - { - Script = script; - } - - - public IDisposable EnterSource(SourceRef sref) - { - return new SourceCodeStackGuard(sref, this); - } - - - private class SourceCodeStackGuard : IDisposable - { - ByteCode m_Bc; - - public SourceCodeStackGuard(SourceRef sref, ByteCode bc) - { - m_Bc = bc; - m_Bc.PushSourceRef(sref); - } - - public void Dispose() - { - m_Bc.PopSourceRef(); - } - } - - - public void PushSourceRef(SourceRef sref) - { - m_SourceRefStack.Add(sref); - m_CurrentSourceRef = sref; - } - - public void PopSourceRef() - { - m_SourceRefStack.RemoveAt(m_SourceRefStack.Count - 1); - m_CurrentSourceRef = (m_SourceRefStack.Count > 0) ? m_SourceRefStack[m_SourceRefStack.Count - 1] : null; - } - - #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) && (!(NETFX_CORE)) - public void Dump(string file) - { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < Code.Count; i++) - { - if (Code[i].OpCode == OpCode.Debug) - sb.AppendFormat(" {0}\n", Code[i]); - else - sb.AppendFormat("{0:X8} {1}\n", i, Code[i]); - } - - File.WriteAllText(file, sb.ToString()); - } - #endif - - public int GetJumpPointForNextInstruction() - { - return Code.Count; - } - public int GetJumpPointForLastInstruction() - { - return Code.Count - 1; - } - - public Instruction GetLastInstruction() - { - return Code[Code.Count - 1]; - } - - private Instruction AppendInstruction(Instruction c) - { - Code.Add(c); - return c; - } - - public Instruction Emit_Nop(string comment) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Nop, Name = comment }); - } - - public Instruction Emit_Invalid(string type) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Invalid, Name = type }); - } - - public Instruction Emit_Pop(int num = 1) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Pop, NumVal = num }); - } - - public void Emit_Call(int argCount, string debugName) - { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Call, NumVal = argCount, Name = debugName }); - } - - public void Emit_ThisCall(int argCount, string debugName) - { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ThisCall, NumVal = argCount, Name = debugName }); - } - - public Instruction Emit_Literal(DynValue value) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Literal, Value = value }); - } - - public Instruction Emit_Jump(OpCode jumpOpCode, int idx, int optPar = 0) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = jumpOpCode, NumVal = idx, NumVal2 = optPar }); - } - - public Instruction Emit_MkTuple(int cnt) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.MkTuple, NumVal = cnt }); - } - - public Instruction Emit_Operator(OpCode opcode) - { - var i = AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = opcode }); - - if (opcode == OpCode.LessEq) - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.CNot }); - - if (opcode == OpCode.Eq || opcode == OpCode.Less) - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ToBool }); - - return i; - } - - - [Conditional("EMIT_DEBUG_OPS")] - public void Emit_Debug(string str) - { - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) }); - } - - public Instruction Emit_Enter(RuntimeScopeBlock runtimeScopeBlock) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); - } - - public Instruction Emit_Leave(RuntimeScopeBlock runtimeScopeBlock) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.To }); - } - - public Instruction Emit_Exit(RuntimeScopeBlock runtimeScopeBlock) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.From, NumVal2 = runtimeScopeBlock.ToInclusive }); - } - - public Instruction Emit_Clean(RuntimeScopeBlock runtimeScopeBlock) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Clean, NumVal = runtimeScopeBlock.To + 1, NumVal2 = runtimeScopeBlock.ToInclusive }); - } - - public Instruction Emit_Closure(SymbolRef[] symbols, int jmpnum) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Closure, SymbolList = symbols, NumVal = jmpnum }); - } - - public Instruction Emit_Args(params SymbolRef[] symbols) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Args, SymbolList = symbols }); - } - - public Instruction Emit_Ret(int retvals) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Ret, NumVal = retvals }); - } - - public Instruction Emit_ToNum(int stage = 0) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ToNum, NumVal = stage }); - } - - public Instruction Emit_Incr(int i) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Incr, NumVal = i }); - } - - public Instruction Emit_NewTable(bool shared) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.NewTable, NumVal = shared ? 1 : 0 }); - } - - public Instruction Emit_IterPrep() - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IterPrep }); - } - - public Instruction Emit_ExpTuple(int stackOffset) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.ExpTuple, NumVal = stackOffset }); - } - - public Instruction Emit_IterUpd() - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IterUpd }); - } - - public Instruction Emit_Meta(string funcName, OpCodeMetadataType metaType, DynValue value = null) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) - { - OpCode = OpCode.Meta, - Name = funcName, - NumVal2 = (int)metaType, - Value = value - }); - } - - - public Instruction Emit_BeginFn(RuntimeScopeFrame stackFrame) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) - { - OpCode = OpCode.BeginFn, - SymbolList = stackFrame.DebugSymbols.ToArray(), - NumVal = stackFrame.Count, - NumVal2 = stackFrame.ToFirstBlock, - }); - } - - public Instruction Emit_Scalar() - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Scalar }); - } - - public int Emit_Load(SymbolRef sym) - { - switch (sym.Type) - { - case SymbolRefType.Global: - Emit_Load(sym.i_Env); - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Index, Value = DynValue.NewString(sym.i_Name) }); - return 2; - case SymbolRefType.Local: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Local, Symbol = sym }); - return 1; - case SymbolRefType.Upvalue: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Upvalue, Symbol = sym }); - return 1; - default: - throw new InternalErrorException("Unexpected symbol type : {0}", sym); - } - } - - public int Emit_Store(SymbolRef sym, int stackofs, int tupleidx) - { - switch (sym.Type) - { - case SymbolRefType.Global: - Emit_Load(sym.i_Env); - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.IndexSet, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx, Value = DynValue.NewString(sym.i_Name) }); - return 2; - case SymbolRefType.Local: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.StoreLcl, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); - return 1; - case SymbolRefType.Upvalue: - AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.StoreUpv, Symbol = sym, NumVal = stackofs, NumVal2 = tupleidx }); - return 1; - default: - throw new InternalErrorException("Unexpected symbol type : {0}", sym); - } - } - - public Instruction Emit_TblInitN() - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.TblInitN }); - } - - public Instruction Emit_TblInitI(bool lastpos) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.TblInitI, NumVal = lastpos ? 1 : 0 }); - } - - public Instruction Emit_Index(DynValue index = null, bool isNameIndex = false, bool isExpList = false) - { - OpCode o; - if (isNameIndex) o = OpCode.IndexN; - else if (isExpList) o = OpCode.IndexL; - else o = OpCode.Index; - - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = o, Value = index }); - } - - public Instruction Emit_IndexSet(int stackofs, int tupleidx, DynValue index = null, bool isNameIndex = false, bool isExpList = false) - { - OpCode o; - if (isNameIndex) o = OpCode.IndexSetN; - else if (isExpList) o = OpCode.IndexSetL; - else o = OpCode.IndexSet; - - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = o, NumVal = stackofs, NumVal2 = tupleidx, Value = index }); - } - - public Instruction Emit_Copy(int numval) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Copy, NumVal = numval }); - } - - public Instruction Emit_Swap(int p1, int p2) - { - return AppendInstruction(new Instruction(m_CurrentSourceRef) { OpCode = OpCode.Swap, NumVal = p1, NumVal2 = p2 }); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItem.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItem.cs deleted file mode 100644 index 9d29fb9c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItem.cs +++ /dev/null @@ -1,25 +0,0 @@ -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - internal class CallStackItem - { - public int Debug_EntryPoint; - public SymbolRef[] Debug_Symbols; - - public SourceRef CallingSourceRef; - - public CallbackFunction ClrFunction; - public CallbackFunction Continuation; - public CallbackFunction ErrorHandler; - public DynValue ErrorHandlerBeforeUnwind; - - public int BasePointer; - public int ReturnAddress; - public DynValue[] LocalScope; - public ClosureContext ClosureScope; - - public CallStackItemFlags Flags; - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItemFlags.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItemFlags.cs deleted file mode 100644 index 9e6d6eae..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/CallStackItemFlags.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Execution.VM -{ - [Flags] - internal enum CallStackItemFlags - { - None = 0, - - EntryPoint = 1, - ResumeEntryPoint = 3, - CallEntryPoint = 5, - - TailCall = 0x10, - MethodCall = 0x20, - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ExecutionState.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ExecutionState.cs deleted file mode 100644 index ed35fc3d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/ExecutionState.cs +++ /dev/null @@ -1,12 +0,0 @@ -using MoonSharp.Interpreter.DataStructs; - -namespace MoonSharp.Interpreter.Execution.VM -{ - internal sealed class ExecutionState - { - public FastStack ValueStack = new FastStack(131072); - public FastStack ExecutionStack = new FastStack(131072); - public int InstructionPtr = 0; - public CoroutineState State = CoroutineState.NotStarted; - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Instruction.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Instruction.cs deleted file mode 100644 index c6034014..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Instruction.cs +++ /dev/null @@ -1,226 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - internal class Instruction - { - internal OpCode OpCode; - internal SymbolRef Symbol; - internal SymbolRef[] SymbolList; - internal string Name; - internal DynValue Value; - internal int NumVal; - internal int NumVal2; - internal SourceRef SourceCodeRef; - - internal Instruction(SourceRef sourceref) - { - SourceCodeRef = sourceref; - } - - public override string ToString() - { - string append = this.OpCode.ToString().ToUpperInvariant(); - - int usage = (int)OpCode.GetFieldUsage(); - - if (usage != 0) - append += GenSpaces(); - - if ((this.OpCode == VM.OpCode.Meta) ||((usage & ((int)InstructionFieldUsage.NumValAsCodeAddress)) == (int)InstructionFieldUsage.NumValAsCodeAddress)) - append += " " + NumVal.ToString("X8"); - else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) - append += " " + NumVal.ToString(); - - if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) - append += " " + NumVal2.ToString(); - - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - append += " " + Name; - - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - append += " " + PurifyFromNewLines(Value); - - if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) - append += " " + Symbol; - - if (((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) && (SymbolList != null)) - append += " " + string.Join(",", SymbolList.Select(s => s.ToString()).ToArray()); - - return append; - } - - private string PurifyFromNewLines(DynValue Value) - { - if (Value == null) - return ""; - - return Value.ToString().Replace('\n', ' ').Replace('\r', ' '); - } - - private string GenSpaces() - { - return new string(' ', 10 - this.OpCode.ToString().Length); - } - - internal void WriteBinary(BinaryWriter wr, int baseAddress, Dictionary symbolMap) - { - wr.Write((byte)this.OpCode); - - int usage = (int)OpCode.GetFieldUsage(); - - if ((usage & ((int)InstructionFieldUsage.NumValAsCodeAddress)) == (int)InstructionFieldUsage.NumValAsCodeAddress) - wr.Write(this.NumVal - baseAddress); - else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) - wr.Write(this.NumVal); - - if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) - wr.Write(this.NumVal2); - - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - wr.Write(Name ?? ""); - - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - DumpValue(wr, Value); - - if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) - WriteSymbol(wr, Symbol, symbolMap); - - if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) - { - wr.Write(this.SymbolList.Length); - for (int i = 0; i < this.SymbolList.Length; i++) - WriteSymbol(wr, SymbolList[i], symbolMap); - } - } - - private static void WriteSymbol(BinaryWriter wr, SymbolRef symbolRef, Dictionary symbolMap) - { - int id = (symbolRef == null) ? -1 : symbolMap[symbolRef]; - wr.Write(id); - } - - private static SymbolRef ReadSymbol(BinaryReader rd, SymbolRef[] deserializedSymbols) - { - int id = rd.ReadInt32(); - - if (id < 0) return null; - return deserializedSymbols[id]; - } - - internal static Instruction ReadBinary(SourceRef chunkRef, BinaryReader rd, int baseAddress, Table envTable, SymbolRef[] deserializedSymbols) - { - Instruction that = new Instruction(chunkRef); - - that.OpCode = (OpCode)rd.ReadByte(); - - int usage = (int)that.OpCode.GetFieldUsage(); - - if ((usage & ((int)InstructionFieldUsage.NumValAsCodeAddress)) == (int)InstructionFieldUsage.NumValAsCodeAddress) - that.NumVal = rd.ReadInt32() + baseAddress; - else if ((usage & ((int)InstructionFieldUsage.NumVal)) != 0) - that.NumVal = rd.ReadInt32(); - - if ((usage & ((int)InstructionFieldUsage.NumVal2)) != 0) - that.NumVal2 = rd.ReadInt32(); - - if ((usage & ((int)InstructionFieldUsage.Name)) != 0) - that.Name = rd.ReadString(); - - if ((usage & ((int)InstructionFieldUsage.Value)) != 0) - that.Value = ReadValue(rd, envTable); - - if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) - that.Symbol = ReadSymbol(rd, deserializedSymbols); - - if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) - { - int len = rd.ReadInt32(); - that.SymbolList = new SymbolRef[len]; - - for (int i = 0; i < that.SymbolList.Length; i++) - that.SymbolList[i] = ReadSymbol(rd, deserializedSymbols); - } - - return that; - } - - private static DynValue ReadValue(BinaryReader rd, Table envTable) - { - bool isnull = !rd.ReadBoolean(); - - if (isnull) return null; - - DataType dt = (DataType)rd.ReadByte(); - - switch (dt) - { - case DataType.Nil: - return DynValue.NewNil(); - case DataType.Void: - return DynValue.Void; - case DataType.Boolean: - return DynValue.NewBoolean(rd.ReadBoolean()); - case DataType.Number: - return DynValue.NewNumber(rd.ReadDouble()); - case DataType.String: - return DynValue.NewString(rd.ReadString()); - case DataType.Table : - return DynValue.NewTable(envTable); - default: - throw new NotSupportedException(string.Format("Unsupported type in chunk dump : {0}", dt)); - } - } - - - private void DumpValue(BinaryWriter wr, DynValue value) - { - if (value == null) - { - wr.Write(false); - return; - } - - wr.Write(true); - wr.Write((byte)value.Type); - - switch (value.Type) - { - case DataType.Nil: - case DataType.Void: - case DataType.Table: - break; - case DataType.Boolean: - wr.Write(value.Boolean); - break; - case DataType.Number: - wr.Write(value.Number); - break; - case DataType.String: - wr.Write(value.String); - break; - default: - throw new NotSupportedException(string.Format("Unsupported type in chunk dump : {0}", value.Type)); - } - } - - internal void GetSymbolReferences(out SymbolRef[] symbolList, out SymbolRef symbol) - { - int usage = (int)OpCode.GetFieldUsage(); - - symbol = null; - symbolList = null; - - if ((usage & ((int)InstructionFieldUsage.Symbol)) != 0) - symbol = this.Symbol; - - if ((usage & ((int)InstructionFieldUsage.SymbolList)) != 0) - symbolList = this.SymbolList; - - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCode.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCode.cs deleted file mode 100644 index 15ba552b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCode.cs +++ /dev/null @@ -1,77 +0,0 @@ - -namespace MoonSharp.Interpreter.Execution.VM -{ - internal enum OpCode - { - // Meta-opcodes - Nop, // Does not perform any operation. - Debug, // Does not perform any operation. Used to help debugging. - - // Stack ops and assignment - Pop, // Discards the topmost n elements from the v-stack. - Copy, // Copies the n-th value of the stack on the top - Swap, // Swaps two entries relative to the v-stack - Literal, // Pushes a literal (constant value) on the stack. - Closure, // Creates a closure on the top of the v-stack, using the symbols for upvalues and num-val for entry point of the function. - NewTable, // Creates a new empty table on the stack - TblInitN, // Initializes a table named entry - TblInitI, // Initializes a table positional entry - - StoreLcl, Local, - StoreUpv, Upvalue, - IndexSet, Index, - IndexSetN, IndexN, - IndexSetL, IndexL, - - // Stack-frame ops and calls - Clean, // Cleansup locals setting them as null - - Meta, // Injects function metadata used for reflection things (dumping, debugging) - BeginFn, // Adjusts for start of function, taking in parameters and allocating locals - Args, // Takes the arguments passed to a function and sets the appropriate symbols in the local scope - Call, // Calls the function specified on the specified element from the top of the v-stack. If the function is a MoonSharp function, it pushes its numeric value on the v-stack, then pushes the current PC onto the x-stack, enters the function closure and jumps to the function first instruction. If the function is a CLR function, it pops the function value from the v-stack, then invokes the function synchronously and finally pushes the result on the v-stack. - ThisCall, // Same as call, but the call is a ':' method invocation - Ret, // Pops the top n values of the v-stack. Then pops an X value from the v-stack. Then pops X values from the v-stack. Afterwards, it pushes the top n values popped in the first step, pops the top of the x-stack and jumps to that location. - - // Jumps - Jump, // Jumps to the specified PC - Jf, // Pops the top of the v-stack and jumps to the specified location if it's false - JNil, // Jumps if the top of the stack is nil - JFor, // Peeks at the top, top-1 and top-2 values of the v-stack which it assumes to be numbers. Then if top-1 is less than zero, checks if top is <= top-2, otherwise it checks that top is >= top-2. Then if the condition is false, it jumps. - JtOrPop, // Peeks at the topmost value of the v-stack as a boolean. If true, it performs a jump, otherwise it removes the topmost value from the v-stack. - JfOrPop, // Peeks at the topmost value of the v-stack as a boolean. If false, it performs a jump, otherwise it removes the topmost value from the v-stack. - - // Operators - Concat, // Concatenation of the two topmost operands on the v-stack - LessEq, // Compare <= of the two topmost operands on the v-stack - Less, // Compare < of the two topmost operands on the v-stack - Eq, // Compare == of the two topmost operands on the v-stack - Add, // Addition of the two topmost operands on the v-stack - Sub, // Subtraction of the two topmost operands on the v-stack - Mul, // Multiplication of the two topmost operands on the v-stack - Div, // Division of the two topmost operands on the v-stack - Mod, // Modulus of the two topmost operands on the v-stack - Not, // Logical inversion of the topmost operand on the v-stack - Len, // Size operator of the topmost operand on the v-stack - Neg, // Negation (unary minus) operator of the topmost operand on the v-stack - Power, // Power of the two topmost operands on the v-stack - CNot, // Conditional NOT - takes second operand from the v-stack (must be bool), if true execs a NOT otherwise execs a TOBOOL - - - // Type conversions and manipulations - MkTuple, // Creates a tuple from the topmost n values - Scalar, // Converts the topmost tuple to a scalar - Incr, // Performs an add operation, without extracting the operands from the v-stack and assuming the operands are numbers. - ToNum, // Converts the top of the stack to a number - ToBool, // Converts the top of the stack to a boolean - ExpTuple, // Expands a tuple on the stack - - - // Iterators - IterPrep, // Prepares an iterator for execution - IterUpd, // Updates the var part of an iterator - - // Meta - Invalid, // Crashes the executor with an unrecoverable NotImplementedException. This MUST always be the last opcode in enum - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCodeMetadataType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCodeMetadataType.cs deleted file mode 100644 index 8b5dd3fd..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/OpCodeMetadataType.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Execution.VM -{ - public enum OpCodeMetadataType - { - ChunkEntrypoint, - FunctionEntrypoint, - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/DebugContext.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/DebugContext.cs deleted file mode 100644 index eabe0f9d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/DebugContext.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - private class DebugContext - { - public bool DebuggerEnabled = true; - public IDebugger DebuggerAttached = null; - public DebuggerAction.ActionType DebuggerCurrentAction = DebuggerAction.ActionType.None; - public int DebuggerCurrentActionTarget = -1; - public SourceRef LastHlRef = null; - public int ExStackDepthAtStep = -1; - public List BreakPoints = new List(); - public bool LineBasedBreakPoints = false; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor.cs deleted file mode 100755 index 7e2a068f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using MoonSharp.Interpreter.DataStructs; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - ByteCode m_RootChunk; - - FastStack m_ValueStack = new FastStack(131072); - FastStack m_ExecutionStack = new FastStack(131072); - List m_CoroutinesStack; - - Table m_GlobalTable; - Script m_Script; - Processor m_Parent = null; - CoroutineState m_State; - bool m_CanYield = true; - int m_SavedInstructionPtr = -1; - DebugContext m_Debug; - - public Processor(Script script, Table globalContext, ByteCode byteCode) - { - m_CoroutinesStack = new List(); - - m_Debug = new DebugContext(); - m_RootChunk = byteCode; - m_GlobalTable = globalContext; - m_Script = script; - m_State = CoroutineState.Main; - DynValue.NewCoroutine(new Coroutine(this)); // creates an associated coroutine for the main processor - } - - private Processor(Processor parentProcessor) - { - m_Debug = parentProcessor.m_Debug; - m_RootChunk = parentProcessor.m_RootChunk; - m_GlobalTable = parentProcessor.m_GlobalTable; - m_Script = parentProcessor.m_Script; - m_Parent = parentProcessor; - m_State = CoroutineState.NotStarted; - } - - - - public DynValue Call(DynValue function, DynValue[] args) - { - List coroutinesStack = m_Parent != null ? m_Parent.m_CoroutinesStack : this.m_CoroutinesStack; - - if (coroutinesStack.Count > 0 && coroutinesStack[coroutinesStack.Count - 1] != this) - return coroutinesStack[coroutinesStack.Count - 1].Call(function, args); - - EnterProcessor(); - - try - { - var stopwatch = this.m_Script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Execution); - - m_CanYield = false; - - try - { - int entrypoint = PushClrToScriptStackFrame(CallStackItemFlags.CallEntryPoint, function, args); - return Processing_Loop(entrypoint); - } - finally - { - m_CanYield = true; - - if (stopwatch != null) - stopwatch.Dispose(); - } - } - finally - { - LeaveProcessor(); - } - } - - // pushes all what's required to perform a clr-to-script function call. function can be null if it's already - // at vstack top. - private int PushClrToScriptStackFrame(CallStackItemFlags flags, DynValue function, DynValue[] args) - { - if (function == null) - function = m_ValueStack.Peek(); - else - m_ValueStack.Push(function); // func val - - args = Internal_AdjustTuple(args); - - for (int i = 0; i < args.Length; i++) - m_ValueStack.Push(args[i]); - - m_ValueStack.Push(DynValue.NewNumber(args.Length)); // func args count - - m_ExecutionStack.Push(new CallStackItem() - { - BasePointer = m_ValueStack.Count, - Debug_EntryPoint = function.Function.EntryPointByteCodeLocation, - ReturnAddress = -1, - ClosureScope = function.Function.ClosureContext, - CallingSourceRef = SourceRef.GetClrLocation(), - Flags = flags - }); - - return function.Function.EntryPointByteCodeLocation; - } - - - int m_OwningThreadID = -1; - int m_ExecutionNesting = 0; - - private void LeaveProcessor() - { - m_ExecutionNesting -= 1; - m_OwningThreadID = -1; - - if (m_Parent != null) - { - m_Parent.m_CoroutinesStack.RemoveAt(m_Parent.m_CoroutinesStack.Count - 1); - } - - if (m_ExecutionNesting == 0 && m_Debug != null && m_Debug.DebuggerEnabled - && m_Debug.DebuggerAttached != null) - { - m_Debug.DebuggerAttached.SignalExecutionEnded(); - } - } - - int GetThreadId() - { - #if ENABLE_DOTNET || NETFX_CORE - return 1; - #else - return Thread.CurrentThread.ManagedThreadId; - #endif - } - - private void EnterProcessor() - { - int threadID = GetThreadId(); - - if (m_OwningThreadID >= 0 && m_OwningThreadID != threadID && m_Script.Options.CheckThreadAccess) - { - string msg = string.Format("Cannot enter the same MoonSharp processor from two different threads : {0} and {1}", m_OwningThreadID, threadID); - throw new InvalidOperationException(msg); - } - - m_OwningThreadID = threadID; - - m_ExecutionNesting += 1; - - if (m_Parent != null) - { - m_Parent.m_CoroutinesStack.Add(this); - } - } - - internal SourceRef GetCoroutineSuspendedLocation() - { - return GetCurrentSourceRef(m_SavedInstructionPtr); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_BinaryDump.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_BinaryDump.cs deleted file mode 100644 index 549ee9d3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_BinaryDump.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.IO; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - const ulong DUMP_CHUNK_MAGIC = 0x1A0D234E4F4F4D1D; - const int DUMP_CHUNK_VERSION = 0x150; - - internal static bool IsDumpStream(Stream stream) - { - if (stream.Length >= 8) - { - using (BinaryReader br = new BinaryReader(stream, Encoding.UTF8)) - { - ulong magic = br.ReadUInt64(); - stream.Seek(-8, SeekOrigin.Current); - return magic == DUMP_CHUNK_MAGIC; - } - } - return false; - } - - internal int Dump(Stream stream, int baseAddress, bool hasUpvalues) - { - using (BinaryWriter bw = new BinDumpBinaryWriter(stream, Encoding.UTF8)) - { - Dictionary symbolMap = new Dictionary(); - - Instruction meta = FindMeta(ref baseAddress); - - if (meta == null) - throw new ArgumentException("baseAddress"); - - bw.Write(DUMP_CHUNK_MAGIC); - bw.Write(DUMP_CHUNK_VERSION); - bw.Write(hasUpvalues); - bw.Write(meta.NumVal); - - for (int i = 0; i <= meta.NumVal; i++) - { - SymbolRef[] symbolList; - SymbolRef symbol; - - m_RootChunk.Code[baseAddress + i].GetSymbolReferences(out symbolList, out symbol); - - if (symbol != null) - AddSymbolToMap(symbolMap, symbol); - - if (symbolList != null) - foreach (var s in symbolList) - AddSymbolToMap(symbolMap, s); - } - - foreach (SymbolRef sr in symbolMap.Keys.ToArray()) - { - if (sr.i_Env != null) - AddSymbolToMap(symbolMap, sr.i_Env); - } - - SymbolRef[] allSymbols = new SymbolRef[symbolMap.Count]; - - foreach (KeyValuePair pair in symbolMap) - { - allSymbols[pair.Value] = pair.Key; - } - - bw.Write(symbolMap.Count); - - foreach (SymbolRef sym in allSymbols) - sym.WriteBinary(bw); - - foreach (SymbolRef sym in allSymbols) - sym.WriteBinaryEnv(bw, symbolMap); - - for (int i = 0; i <= meta.NumVal; i++) - m_RootChunk.Code[baseAddress + i].WriteBinary(bw, baseAddress, symbolMap); - - return meta.NumVal + baseAddress + 1; - } - } - - private void AddSymbolToMap(Dictionary symbolMap, SymbolRef s) - { - if (!symbolMap.ContainsKey(s)) - symbolMap.Add(s, symbolMap.Count); - } - - internal int Undump(Stream stream, int sourceID, Table envTable, out bool hasUpvalues) - { - int baseAddress = m_RootChunk.Code.Count; - SourceRef sourceRef = new SourceRef(sourceID, 0, 0, 0, 0, false); - - using (BinaryReader br = new BinDumpBinaryReader(stream, Encoding.UTF8)) - { - ulong headerMark = br.ReadUInt64(); - - if (headerMark != DUMP_CHUNK_MAGIC) - throw new ArgumentException("Not a MoonSharp chunk"); - - int version = br.ReadInt32(); - - if (version != DUMP_CHUNK_VERSION) - throw new ArgumentException("Invalid version"); - - hasUpvalues = br.ReadBoolean(); - - int len = br.ReadInt32(); - - int numSymbs = br.ReadInt32(); - SymbolRef[] allSymbs = new SymbolRef[numSymbs]; - - for (int i = 0; i < numSymbs; i++) - allSymbs[i] = SymbolRef.ReadBinary(br); - - for (int i = 0; i < numSymbs; i++) - allSymbs[i].ReadBinaryEnv(br, allSymbs); - - for (int i = 0; i <= len; i++) - { - Instruction I = Instruction.ReadBinary(sourceRef, br, baseAddress, envTable, allSymbs); - m_RootChunk.Code.Add(I); - } - - return baseAddress; - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Coroutines.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Coroutines.cs deleted file mode 100644 index a9664670..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Coroutines.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Execution.VM -{ - // This part is practically written procedural style - it looks more like C than C#. - // This is intentional so to avoid this-calls and virtual-calls as much as possible. - // Same reason for the "sealed" declaration. - sealed partial class Processor - { - public DynValue Coroutine_Create(Closure closure) - { - // create a processor instance - Processor P = new Processor(this); - - // Put the closure as first value on the stack, for future reference - P.m_ValueStack.Push(DynValue.NewClosure(closure)); - - // Return the coroutine handle - return DynValue.NewCoroutine(new Coroutine(P)); - } - - public CoroutineState State { get { return m_State; } } - public Coroutine AssociatedCoroutine { get; set; } - - public DynValue Coroutine_Resume(DynValue[] args) - { - EnterProcessor(); - - try - { - int entrypoint = 0; - - if (m_State != CoroutineState.NotStarted && m_State != CoroutineState.Suspended && m_State != CoroutineState.ForceSuspended) - throw ScriptRuntimeException.CannotResumeNotSuspended(m_State); - - if (m_State == CoroutineState.NotStarted) - { - entrypoint = PushClrToScriptStackFrame(CallStackItemFlags.ResumeEntryPoint, null, args); - } - else if (m_State == CoroutineState.Suspended) - { - m_ValueStack.Push(DynValue.NewTuple(args)); - entrypoint = m_SavedInstructionPtr; - } - else if (m_State == CoroutineState.ForceSuspended) - { - if (args != null && args.Length > 0) - throw new ArgumentException("When resuming a force-suspended coroutine, args must be empty."); - - entrypoint = m_SavedInstructionPtr; - } - - m_State = CoroutineState.Running; - DynValue retVal = Processing_Loop(entrypoint); - - if (retVal.Type == DataType.YieldRequest) - { - if (retVal.YieldRequest.Forced) - { - m_State = CoroutineState.ForceSuspended; - return retVal; - } - else - { - m_State = CoroutineState.Suspended; - return DynValue.NewTuple(retVal.YieldRequest.ReturnValues); - } - } - else - { - m_State = CoroutineState.Dead; - return retVal; - } - } - catch (Exception) - { - // Unhandled exception - move to dead - m_State = CoroutineState.Dead; - throw; - } - finally - { - LeaveProcessor(); - } - } - - - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Debugger.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Debugger.cs deleted file mode 100755 index f7878780..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Debugger.cs +++ /dev/null @@ -1,411 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - // This part is practically written procedural style - it looks more like C than C#. - // This is intentional so to avoid this-calls and virtual-calls as much as possible. - // Same reason for the "sealed" declaration. - sealed partial class Processor - { - internal Instruction FindMeta(ref int baseAddress) - { - Instruction meta = m_RootChunk.Code[baseAddress]; - - // skip nops - while (meta.OpCode == OpCode.Nop) - { - baseAddress++; - meta = m_RootChunk.Code[baseAddress]; - } - - if (meta.OpCode != OpCode.Meta) - return null; - - return meta; - } - - - internal void AttachDebugger(IDebugger debugger) - { - m_Debug.DebuggerAttached = debugger; - m_Debug.LineBasedBreakPoints = (debugger.GetDebuggerCaps() & DebuggerCaps.HasLineBasedBreakpoints) != 0; - debugger.SetDebugService(new DebugService(m_Script, this)); - } - - internal bool DebuggerEnabled - { - get { return m_Debug.DebuggerEnabled; } - set { m_Debug.DebuggerEnabled = value; } - } - - - private void ListenDebugger(Instruction instr, int instructionPtr) - { - bool isOnDifferentRef = false; - - if (instr.SourceCodeRef != null && m_Debug.LastHlRef != null) - { - if (m_Debug.LineBasedBreakPoints) - { - isOnDifferentRef = instr.SourceCodeRef.SourceIdx != m_Debug.LastHlRef.SourceIdx || - instr.SourceCodeRef.FromLine != m_Debug.LastHlRef.FromLine; - } - else - { - isOnDifferentRef = instr.SourceCodeRef != m_Debug.LastHlRef; - } - } - else if (m_Debug.LastHlRef == null) - { - isOnDifferentRef = instr.SourceCodeRef != null; - } - - - if (m_Debug.DebuggerAttached.IsPauseRequested() || - (instr.SourceCodeRef != null && instr.SourceCodeRef.Breakpoint && isOnDifferentRef)) - { - m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.None; - m_Debug.DebuggerCurrentActionTarget = -1; - } - - switch (m_Debug.DebuggerCurrentAction) - { - case DebuggerAction.ActionType.Run: - if (m_Debug.LineBasedBreakPoints) - m_Debug.LastHlRef = instr.SourceCodeRef; - return; - case DebuggerAction.ActionType.ByteCodeStepOver: - if (m_Debug.DebuggerCurrentActionTarget != instructionPtr) return; - break; - case DebuggerAction.ActionType.ByteCodeStepOut: - case DebuggerAction.ActionType.StepOut: - if (m_ExecutionStack.Count >= m_Debug.ExStackDepthAtStep) return; - break; - case DebuggerAction.ActionType.StepIn: - if ((m_ExecutionStack.Count >= m_Debug.ExStackDepthAtStep) && (instr.SourceCodeRef == null || instr.SourceCodeRef == m_Debug.LastHlRef)) return; - break; - case DebuggerAction.ActionType.StepOver: - if (instr.SourceCodeRef == null || instr.SourceCodeRef == m_Debug.LastHlRef || m_ExecutionStack.Count > m_Debug.ExStackDepthAtStep) return; - break; - } - - - RefreshDebugger(false, instructionPtr); - - while (true) - { - var action = m_Debug.DebuggerAttached.GetAction(instructionPtr, instr.SourceCodeRef); - - switch (action.Action) - { - case DebuggerAction.ActionType.StepIn: - case DebuggerAction.ActionType.StepOver: - case DebuggerAction.ActionType.StepOut: - case DebuggerAction.ActionType.ByteCodeStepOut: - m_Debug.DebuggerCurrentAction = action.Action; - m_Debug.LastHlRef = instr.SourceCodeRef; - m_Debug.ExStackDepthAtStep = m_ExecutionStack.Count; - return; - case DebuggerAction.ActionType.ByteCodeStepIn: - m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.ByteCodeStepIn; - m_Debug.DebuggerCurrentActionTarget = -1; - return; - case DebuggerAction.ActionType.ByteCodeStepOver: - m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.ByteCodeStepOver; - m_Debug.DebuggerCurrentActionTarget = instructionPtr + 1; - return; - case DebuggerAction.ActionType.Run: - m_Debug.DebuggerCurrentAction = DebuggerAction.ActionType.Run; - m_Debug.LastHlRef = instr.SourceCodeRef; - m_Debug.DebuggerCurrentActionTarget = -1; - return; - case DebuggerAction.ActionType.ToggleBreakpoint: - ToggleBreakPoint(action, null); - RefreshDebugger(true, instructionPtr); - break; - case DebuggerAction.ActionType.ResetBreakpoints: - ResetBreakPoints(action); - RefreshDebugger(true, instructionPtr); - break; - case DebuggerAction.ActionType.SetBreakpoint: - ToggleBreakPoint(action, true); - RefreshDebugger(true, instructionPtr); - break; - case DebuggerAction.ActionType.ClearBreakpoint: - ToggleBreakPoint(action, false); - RefreshDebugger(true, instructionPtr); - break; - case DebuggerAction.ActionType.Refresh: - RefreshDebugger(false, instructionPtr); - break; - case DebuggerAction.ActionType.HardRefresh: - RefreshDebugger(true, instructionPtr); - break; - case DebuggerAction.ActionType.None: - default: - break; - } - } - } - - private void ResetBreakPoints(DebuggerAction action) - { - SourceCode src = m_Script.GetSourceCode(action.SourceID); - ResetBreakPoints(src, new HashSet(action.Lines)); - } - - internal HashSet ResetBreakPoints(SourceCode src, HashSet lines) - { - HashSet result = new HashSet(); - - foreach (SourceRef srf in src.Refs) - { - if (srf.CannotBreakpoint) - continue; - - srf.Breakpoint = lines.Contains(srf.FromLine); - - if (srf.Breakpoint) - result.Add(srf.FromLine); - } - - return result; - } - - private bool ToggleBreakPoint(DebuggerAction action, bool? state) - { - SourceCode src = m_Script.GetSourceCode(action.SourceID); - - bool found = false; - foreach (SourceRef srf in src.Refs) - { - if (srf.CannotBreakpoint) - continue; - - if (srf.IncludesLocation(action.SourceID, action.SourceLine, action.SourceCol)) - { - found = true; - - //System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on contains", srf, srf.Type)); - - if (state == null) - srf.Breakpoint = !srf.Breakpoint; - else - srf.Breakpoint = state.Value; - - if (srf.Breakpoint) - { - m_Debug.BreakPoints.Add(srf); - } - else - { - m_Debug.BreakPoints.Remove(srf); - } - } - } - - if (!found) - { - int minDistance = int.MaxValue; - SourceRef nearest = null; - - foreach (SourceRef srf in src.Refs) - { - if (srf.CannotBreakpoint) - continue; - - int dist = srf.GetLocationDistance(action.SourceID, action.SourceLine, action.SourceCol); - - if (dist < minDistance) - { - minDistance = dist; - nearest = srf; - } - } - - if (nearest != null) - { - //System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on distance {2}", nearest, nearest.Type, minDistance)); - - if (state == null) - nearest.Breakpoint = !nearest.Breakpoint; - else - nearest.Breakpoint = state.Value; - - if (nearest.Breakpoint) - { - m_Debug.BreakPoints.Add(nearest); - } - else - { - m_Debug.BreakPoints.Remove(nearest); - } - - return true; - } - else - return false; - } - else - return true; - } - - private void RefreshDebugger(bool hard, int instructionPtr) - { - SourceRef sref = GetCurrentSourceRef(instructionPtr); - ScriptExecutionContext context = new ScriptExecutionContext(this, null, sref); - - List watchList = m_Debug.DebuggerAttached.GetWatchItems(); - List callStack = Debugger_GetCallStack(sref); - List watches = Debugger_RefreshWatches(context, watchList); - List vstack = Debugger_RefreshVStack(); - List locals = Debugger_RefreshLocals(context); - List threads = Debugger_RefreshThreads(context); - - m_Debug.DebuggerAttached.Update(WatchType.CallStack, callStack); - m_Debug.DebuggerAttached.Update(WatchType.Watches, watches); - m_Debug.DebuggerAttached.Update(WatchType.VStack, vstack); - m_Debug.DebuggerAttached.Update(WatchType.Locals, locals); - m_Debug.DebuggerAttached.Update(WatchType.Threads, threads); - - if (hard) - m_Debug.DebuggerAttached.RefreshBreakpoints(m_Debug.BreakPoints); - } - - private List Debugger_RefreshThreads(ScriptExecutionContext context) - { - List coroutinesStack = m_Parent != null ? m_Parent.m_CoroutinesStack : this.m_CoroutinesStack; - - return coroutinesStack.Select(c => new WatchItem() - { - Address = c.AssociatedCoroutine.ReferenceID, - Name = "coroutine #" + c.AssociatedCoroutine.ReferenceID.ToString() - }).ToList(); - } - - private List Debugger_RefreshVStack() - { - List lwi = new List(); - for (int i = 0; i < Math.Min(32, m_ValueStack.Count); i++) - { - lwi.Add(new WatchItem() - { - Address = i, - Value = m_ValueStack.Peek(i) - }); - } - - return lwi; - } - - private List Debugger_RefreshWatches(ScriptExecutionContext context, List watchList) - { - return watchList.Select(w => Debugger_RefreshWatch(context, w)).ToList(); - } - - private List Debugger_RefreshLocals(ScriptExecutionContext context) - { - List locals = new List(); - var top = this.m_ExecutionStack.Peek(); - - if (top != null && top.Debug_Symbols != null && top.LocalScope != null) - { - int len = Math.Min(top.Debug_Symbols.Length, top.LocalScope.Length); - - for (int i = 0; i < len; i++) - { - locals.Add(new WatchItem() - { - IsError = false, - LValue = top.Debug_Symbols[i], - Value = top.LocalScope[i], - Name = top.Debug_Symbols[i].i_Name - }); - } - } - - return locals; - } - - private WatchItem Debugger_RefreshWatch(ScriptExecutionContext context, DynamicExpression dynExpr) - { - try - { - SymbolRef L = dynExpr.FindSymbol(context); - DynValue v = dynExpr.Evaluate(context); - - return new WatchItem() - { - IsError = dynExpr.IsConstant(), - LValue = L, - Value = v, - Name = dynExpr.ExpressionCode - }; - } - catch (Exception ex) - { - return new WatchItem() - { - IsError = true, - Value = DynValue.NewString(ex.Message), - Name = dynExpr.ExpressionCode - }; - } - } - - internal List Debugger_GetCallStack(SourceRef startingRef) - { - List wis = new List(); - - for (int i = 0; i < m_ExecutionStack.Count; i++) - { - var c = m_ExecutionStack.Peek(i); - - var I = m_RootChunk.Code[c.Debug_EntryPoint]; - - string callname = I.OpCode == OpCode.Meta ? I.Name : null; - - if (c.ClrFunction != null) - { - wis.Add(new WatchItem() - { - Address = -1, - BasePtr = -1, - RetAddress = c.ReturnAddress, - Location = startingRef, - Name = c.ClrFunction.Name - }); - } - else - { - wis.Add(new WatchItem() - { - Address = c.Debug_EntryPoint, - BasePtr = c.BasePointer, - RetAddress = c.ReturnAddress, - Name = callname, - Location = startingRef, - }); - } - - startingRef = c.CallingSourceRef; - - if (c.Continuation != null) - { - wis.Add(new WatchItem() - { - Name = c.Continuation.Name, - Location = SourceRef.GetClrLocation() - }); - } - - - } - - return wis; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Errors.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Errors.cs deleted file mode 100644 index 65e78659..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Errors.cs +++ /dev/null @@ -1,36 +0,0 @@ -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - private SourceRef GetCurrentSourceRef(int instructionPtr) - { - if (instructionPtr >= 0 && instructionPtr < m_RootChunk.Code.Count) - { - return m_RootChunk.Code[instructionPtr].SourceCodeRef; - } - return null; - } - - - private void FillDebugData(InterpreterException ex, int ip) - { - // adjust IP - if (ip == YIELD_SPECIAL_TRAP) - ip = m_SavedInstructionPtr; - else - ip -= 1; - - ex.InstructionPtr = ip; - - SourceRef sref = GetCurrentSourceRef(ip); - - ex.DecorateMessage(m_Script, sref, ip); - - ex.CallStack = Debugger_GetCallStack(sref); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_IExecutionContext.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_IExecutionContext.cs deleted file mode 100644 index e826f240..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_IExecutionContext.cs +++ /dev/null @@ -1,94 +0,0 @@ - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - internal Table GetMetatable(DynValue value) - { - if (value.Type == DataType.Table) - { - return value.Table.MetaTable; - } - else if (value.Type.CanHaveTypeMetatables()) - { - return m_Script.GetTypeMetatable(value.Type); - } - else - { - return null; - } - } - - internal DynValue GetBinaryMetamethod(DynValue op1, DynValue op2, string eventName) - { - var op1_MetaTable = GetMetatable(op1); - if (op1_MetaTable != null) - { - DynValue meta1 = op1_MetaTable.RawGet(eventName); - if (meta1 != null && meta1.IsNotNil()) - return meta1; - } - - var op2_MetaTable = GetMetatable(op2); - if (op2_MetaTable != null) - { - DynValue meta2 = op2_MetaTable.RawGet(eventName); - if (meta2 != null && meta2.IsNotNil()) - return meta2; - } - - if (op1.Type == DataType.UserData) - { - DynValue meta = op1.UserData.Descriptor.MetaIndex(this.m_Script, - op1.UserData.Object, eventName); - - if (meta != null) - return meta; - } - - if (op2.Type == DataType.UserData) - { - DynValue meta = op2.UserData.Descriptor.MetaIndex(this.m_Script, - op2.UserData.Object, eventName); - - if (meta != null) - return meta; - } - - return null; - } - - internal DynValue GetMetamethod(DynValue value, string metamethod) - { - if (value.Type == DataType.UserData) - { - DynValue v = value.UserData.Descriptor.MetaIndex(m_Script, value.UserData.Object, metamethod); - if (v != null) - return v; - } - - return GetMetamethodRaw(value, metamethod); - } - - - internal DynValue GetMetamethodRaw(DynValue value, string metamethod) - { - var metatable = GetMetatable(value); - - if (metatable == null) - return null; - - var metameth = metatable.RawGet(metamethod); - - if (metameth == null || metameth.IsNil()) - return null; - - return metameth; - } - - internal Script GetScript() - { - return m_Script; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_InstructionLoop.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_InstructionLoop.cs deleted file mode 100644 index ec6c05b1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_InstructionLoop.cs +++ /dev/null @@ -1,1370 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.DataStructs; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Interop; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - const int YIELD_SPECIAL_TRAP = -99; - - internal long AutoYieldCounter = 0; - - private DynValue Processing_Loop(int instructionPtr) - { - // This is the main loop of the processor, has a weird control flow and needs to be as fast as possible. - // This sentence is just a convoluted way to say "don't complain about gotos". - - long executedInstructions = 0; - bool canAutoYield = (AutoYieldCounter > 0) && m_CanYield && (this.State != CoroutineState.Main); - - repeat_execution: - - try - { - while (true) - { - Instruction i = m_RootChunk.Code[instructionPtr]; - - if (m_Debug.DebuggerAttached != null) - { - ListenDebugger(i, instructionPtr); - } - - ++executedInstructions; - - if (canAutoYield && executedInstructions > AutoYieldCounter) - { - m_SavedInstructionPtr = instructionPtr; - return DynValue.NewForcedYieldReq(); - } - - ++instructionPtr; - - switch (i.OpCode) - { - case OpCode.Nop: - case OpCode.Debug: - case OpCode.Meta: - break; - case OpCode.Pop: - m_ValueStack.RemoveLast(i.NumVal); - break; - case OpCode.Copy: - m_ValueStack.Push(m_ValueStack.Peek(i.NumVal)); - break; - case OpCode.Swap: - ExecSwap(i); - break; - case OpCode.Literal: - m_ValueStack.Push(i.Value); - break; - case OpCode.Add: - instructionPtr = ExecAdd(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Concat: - instructionPtr = ExecConcat(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Neg: - instructionPtr = ExecNeg(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Sub: - instructionPtr = ExecSub(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Mul: - instructionPtr = ExecMul(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Div: - instructionPtr = ExecDiv(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Mod: - instructionPtr = ExecMod(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Power: - instructionPtr = ExecPower(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Eq: - instructionPtr = ExecEq(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.LessEq: - instructionPtr = ExecLessEq(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Less: - instructionPtr = ExecLess(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Len: - instructionPtr = ExecLen(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Call: - case OpCode.ThisCall: - instructionPtr = Internal_ExecCall(i.NumVal, instructionPtr, null, null, i.OpCode == OpCode.ThisCall, i.Name); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Scalar: - m_ValueStack.Push(m_ValueStack.Pop().ToScalar()); - break; - case OpCode.Not: - ExecNot(i); - break; - case OpCode.CNot: - ExecCNot(i); - break; - case OpCode.JfOrPop: - case OpCode.JtOrPop: - instructionPtr = ExecShortCircuitingOperator(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.JNil: - { - DynValue v = m_ValueStack.Pop().ToScalar(); - - if (v.Type == DataType.Nil || v.Type == DataType.Void) - instructionPtr = i.NumVal; - } - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Jf: - instructionPtr = JumpBool(i, false, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Jump: - instructionPtr = i.NumVal; - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.MkTuple: - ExecMkTuple(i); - break; - case OpCode.Clean: - ClearBlockData(i); - break; - case OpCode.Closure: - ExecClosure(i); - break; - case OpCode.BeginFn: - ExecBeginFn(i); - break; - case OpCode.ToBool: - m_ValueStack.Push(DynValue.NewBoolean(m_ValueStack.Pop().ToScalar().CastToBool())); - break; - case OpCode.Args: - ExecArgs(i); - break; - case OpCode.Ret: - instructionPtr = ExecRet(i); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - if (instructionPtr < 0) - goto return_to_native_code; - break; - case OpCode.Incr: - ExecIncr(i); - break; - case OpCode.ToNum: - ExecToNum(i); - break; - case OpCode.JFor: - instructionPtr = ExecJFor(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.NewTable: - if (i.NumVal == 0) - m_ValueStack.Push(DynValue.NewTable(this.m_Script)); - else - m_ValueStack.Push(DynValue.NewPrimeTable()); - break; - case OpCode.IterPrep: - ExecIterPrep(i); - break; - case OpCode.IterUpd: - ExecIterUpd(i); - break; - case OpCode.ExpTuple: - ExecExpTuple(i); - break; - case OpCode.Local: - var scope = m_ExecutionStack.Peek().LocalScope; - var index = i.Symbol.i_Index; - m_ValueStack.Push(scope[index].AsReadOnly()); - break; - case OpCode.Upvalue: - m_ValueStack.Push(m_ExecutionStack.Peek().ClosureScope[i.Symbol.i_Index].AsReadOnly()); - break; - case OpCode.StoreUpv: - ExecStoreUpv(i); - break; - case OpCode.StoreLcl: - ExecStoreLcl(i); - break; - case OpCode.TblInitN: - ExecTblInitN(i); - break; - case OpCode.TblInitI: - ExecTblInitI(i); - break; - case OpCode.Index: - case OpCode.IndexN: - case OpCode.IndexL: - instructionPtr = ExecIndex(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.IndexSet: - case OpCode.IndexSetN: - case OpCode.IndexSetL: - instructionPtr = ExecIndexSet(i, instructionPtr); - if (instructionPtr == YIELD_SPECIAL_TRAP) goto yield_to_calling_coroutine; - break; - case OpCode.Invalid: - throw new NotImplementedException(string.Format("Invalid opcode : {0}", i.Name)); - default: - throw new NotImplementedException(string.Format("Execution for {0} not implented yet!", i.OpCode)); - } - } - - yield_to_calling_coroutine: - - DynValue yieldRequest = m_ValueStack.Pop().ToScalar(); - - if (m_CanYield) - return yieldRequest; - else if (this.State == CoroutineState.Main) - throw ScriptRuntimeException.CannotYieldMain(); - else - throw ScriptRuntimeException.CannotYield(); - - } - catch (InterpreterException ex) - { - FillDebugData(ex, instructionPtr); - - if (!(ex is ScriptRuntimeException)) - { - ex.Rethrow(); - throw; - } - - if (m_Debug.DebuggerAttached != null) - { - if (m_Debug.DebuggerAttached.SignalRuntimeException((ScriptRuntimeException)ex)) - { - if (instructionPtr >= 0 && instructionPtr < this.m_RootChunk.Code.Count) - { - ListenDebugger(m_RootChunk.Code[instructionPtr], instructionPtr); - } - } - } - - for (int i = 0; i < m_ExecutionStack.Count; i++) - { - var c = m_ExecutionStack.Peek(i); - - if (c.ErrorHandlerBeforeUnwind != null) - ex.DecoratedMessage = PerformMessageDecorationBeforeUnwind(c.ErrorHandlerBeforeUnwind, ex.DecoratedMessage, GetCurrentSourceRef(instructionPtr)); - } - - - while (m_ExecutionStack.Count > 0) - { - CallStackItem csi = PopToBasePointer(); - - if (csi.ErrorHandler != null) - { - instructionPtr = csi.ReturnAddress; - - if (csi.ClrFunction == null) - { - var argscnt = (int)(m_ValueStack.Pop().Number); - m_ValueStack.RemoveLast(argscnt + 1); - } - - var cbargs = new DynValue[] { DynValue.NewString(ex.DecoratedMessage) }; - - DynValue handled = csi.ErrorHandler.Invoke(new ScriptExecutionContext(this, csi.ErrorHandler, GetCurrentSourceRef(instructionPtr)), cbargs); - - m_ValueStack.Push(handled); - - goto repeat_execution; - } - else if ((csi.Flags & CallStackItemFlags.EntryPoint) != 0) - { - ex.Rethrow(); - throw; - } - } - - ex.Rethrow(); - throw; - } - - return_to_native_code: - return m_ValueStack.Pop(); - - - } - - - internal string PerformMessageDecorationBeforeUnwind(DynValue messageHandler, string decoratedMessage, SourceRef sourceRef) - { - try - { - DynValue[] args = new DynValue[] { DynValue.NewString(decoratedMessage) }; - DynValue ret = DynValue.Nil; - - if (messageHandler.Type == DataType.Function) - { - ret = this.Call(messageHandler, args); - } - else if (messageHandler.Type == DataType.ClrFunction) - { - ScriptExecutionContext ctx = new ScriptExecutionContext(this, messageHandler.Callback, sourceRef); - ret = messageHandler.Callback.Invoke(ctx, args); - } - else - { - throw new ScriptRuntimeException("error handler not set to a function"); - } - - string newmsg = ret.ToPrintString(); - if (newmsg != null) - return newmsg; - } - catch (ScriptRuntimeException innerEx) - { - return innerEx.Message + "\n" + decoratedMessage; - } - - return decoratedMessage; - } - - - - private void AssignLocal(SymbolRef symref, DynValue value) - { - var stackframe = m_ExecutionStack.Peek(); - - DynValue v = stackframe.LocalScope[symref.i_Index]; - if (v == null) - stackframe.LocalScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); - } - - private void ExecStoreLcl(Instruction i) - { - DynValue value = GetStoreValue(i); - SymbolRef symref = i.Symbol; - - AssignLocal(symref, value); - } - - private void ExecStoreUpv(Instruction i) - { - DynValue value = GetStoreValue(i); - SymbolRef symref = i.Symbol; - - var stackframe = m_ExecutionStack.Peek(); - - DynValue v = stackframe.ClosureScope[symref.i_Index]; - if (v == null) - stackframe.ClosureScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); - } - - private void ExecSwap(Instruction i) - { - DynValue v1 = m_ValueStack.Peek(i.NumVal); - DynValue v2 = m_ValueStack.Peek(i.NumVal2); - - m_ValueStack.Set(i.NumVal, v2); - m_ValueStack.Set(i.NumVal2, v1); - } - - - private DynValue GetStoreValue(Instruction i) - { - int stackofs = i.NumVal; - int tupleidx = i.NumVal2; - - DynValue v = m_ValueStack.Peek(stackofs); - - if (v.Type == DataType.Tuple) - { - return (tupleidx < v.Tuple.Length) ? v.Tuple[tupleidx] : DynValue.NewNil(); - } - else - { - return (tupleidx == 0) ? v : DynValue.NewNil(); - } - } - - private void ExecClosure(Instruction i) - { - Closure c = new Closure(this.m_Script, i.NumVal, i.SymbolList, - i.SymbolList.Select(s => this.GetUpvalueSymbol(s)).ToList()); - - m_ValueStack.Push(DynValue.NewClosure(c)); - } - - private DynValue GetUpvalueSymbol(SymbolRef s) - { - if (s.Type == SymbolRefType.Local) - return m_ExecutionStack.Peek().LocalScope[s.i_Index]; - else if (s.Type == SymbolRefType.Upvalue) - return m_ExecutionStack.Peek().ClosureScope[s.i_Index]; - else - throw new Exception("unsupported symbol type"); - } - - private void ExecMkTuple(Instruction i) - { - Slice slice = new Slice(m_ValueStack, m_ValueStack.Count - i.NumVal, i.NumVal, false); - - var v = Internal_AdjustTuple(slice); - - m_ValueStack.RemoveLast(i.NumVal); - - m_ValueStack.Push(DynValue.NewTuple(v)); - } - - private void ExecToNum(Instruction i) - { - double? v = m_ValueStack.Pop().ToScalar().CastToNumber(); - if (v.HasValue) - m_ValueStack.Push(DynValue.NewNumber(v.Value)); - else - throw ScriptRuntimeException.ConvertToNumberFailed(i.NumVal); - } - - - private void ExecIterUpd(Instruction i) - { - DynValue v = m_ValueStack.Peek(0); - DynValue t = m_ValueStack.Peek(1); - t.Tuple[2] = v; - } - - private void ExecExpTuple(Instruction i) - { - DynValue t = m_ValueStack.Peek(i.NumVal); - - if (t.Type == DataType.Tuple) - { - for (int idx = 0; idx < t.Tuple.Length; idx++) - m_ValueStack.Push(t.Tuple[idx]); - } - else - { - m_ValueStack.Push(t); - } - - } - - private void ExecIterPrep(Instruction i) - { - DynValue v = m_ValueStack.Pop(); - - if (v.Type != DataType.Tuple) - { - v = DynValue.NewTuple(v, DynValue.Nil, DynValue.Nil); - } - - DynValue f = v.Tuple.Length >= 1 ? v.Tuple[0] : DynValue.Nil; - DynValue s = v.Tuple.Length >= 2 ? v.Tuple[1] : DynValue.Nil; - DynValue var = v.Tuple.Length >= 3 ? v.Tuple[2] : DynValue.Nil; - - // MoonSharp additions - given f, s, var - // 1) if f is not a function and has a __iterator metamethod, call __iterator to get the triplet - // 2) if f is a table with no __call metamethod, use a default table iterator - - if (f.Type != DataType.Function && f.Type != DataType.ClrFunction) - { - DynValue meta = this.GetMetamethod(f, "__iterator"); - - if (meta != null && !meta.IsNil()) - { - if (meta.Type != DataType.Tuple) - v = this.GetScript().Call(meta, f, s, var); - else - v = meta; - - f = v.Tuple.Length >= 1 ? v.Tuple[0] : DynValue.Nil; - s = v.Tuple.Length >= 2 ? v.Tuple[1] : DynValue.Nil; - var = v.Tuple.Length >= 3 ? v.Tuple[2] : DynValue.Nil; - - m_ValueStack.Push(DynValue.NewTuple(f, s, var)); - } - else if (f.Type == DataType.Table) - { - DynValue callmeta = this.GetMetamethod(f, "__call"); - - if (callmeta == null || callmeta.IsNil()) - { - m_ValueStack.Push(EnumerableWrapper.ConvertTable(f.Table)); - } - } - } - - m_ValueStack.Push(DynValue.NewTuple(f, s, var)); - } - - - private int ExecJFor(Instruction i, int instructionPtr) - { - double val = m_ValueStack.Peek(0).Number; - double step = m_ValueStack.Peek(1).Number; - double stop = m_ValueStack.Peek(2).Number; - - bool whileCond = (step > 0) ? val <= stop : val >= stop; - - if (!whileCond) - return i.NumVal; - else - return instructionPtr; - } - - - - private void ExecIncr(Instruction i) - { - DynValue top = m_ValueStack.Peek(0); - DynValue btm = m_ValueStack.Peek(i.NumVal); - - if (top.ReadOnly) - { - m_ValueStack.Pop(); - - if (top.ReadOnly) - top = top.CloneAsWritable(); - - m_ValueStack.Push(top); - } - - top.AssignNumber(top.Number + btm.Number); - } - - - private void ExecCNot(Instruction i) - { - DynValue v = m_ValueStack.Pop().ToScalar(); - DynValue not = m_ValueStack.Pop().ToScalar(); - - if (not.Type != DataType.Boolean) - throw new InternalErrorException("CNOT had non-bool arg"); - - if (not.CastToBool()) - m_ValueStack.Push(DynValue.NewBoolean(!(v.CastToBool()))); - else - m_ValueStack.Push(DynValue.NewBoolean(v.CastToBool())); - } - - private void ExecNot(Instruction i) - { - DynValue v = m_ValueStack.Pop().ToScalar(); - m_ValueStack.Push(DynValue.NewBoolean(!(v.CastToBool()))); - } - - private void ExecBeginFn(Instruction i) - { - CallStackItem cur = m_ExecutionStack.Peek(); - - cur.Debug_Symbols = i.SymbolList; - cur.LocalScope = new DynValue[i.NumVal]; - - ClearBlockData(i); - } - - private CallStackItem PopToBasePointer() - { - var csi = m_ExecutionStack.Pop(); - if (csi.BasePointer >= 0) - m_ValueStack.CropAtCount(csi.BasePointer); - return csi; - } - - private int PopExecStackAndCheckVStack(int vstackguard) - { - var xs = m_ExecutionStack.Pop(); - if (vstackguard != xs.BasePointer) - throw new InternalErrorException("StackGuard violation"); - - return xs.ReturnAddress; - } - - private IList CreateArgsListForFunctionCall(int numargs, int offsFromTop) - { - if (numargs == 0) return new DynValue[0]; - - DynValue lastParam = m_ValueStack.Peek(offsFromTop); - - if (lastParam.Type == DataType.Tuple && lastParam.Tuple.Length > 1) - { - List values = new List(); - - for (int idx = 0; idx < numargs - 1; idx++) - values.Add(m_ValueStack.Peek(numargs - idx - 1 + offsFromTop)); - - for (int idx = 0; idx < lastParam.Tuple.Length; idx++) - values.Add(lastParam.Tuple[idx]); - - return values; - } - else - { - return new Slice(m_ValueStack, m_ValueStack.Count - numargs - offsFromTop, numargs, false); - } - } - - - private void ExecArgs(Instruction I) - { - int numargs = (int)m_ValueStack.Peek(0).Number; - - // unpacks last tuple arguments to simplify a lot of code down under - var argsList = CreateArgsListForFunctionCall(numargs, 1); - - for (int i = 0; i < I.SymbolList.Length; i++) - { - if (i >= argsList.Count) - { - this.AssignLocal(I.SymbolList[i], DynValue.NewNil()); - } - else if ((i == I.SymbolList.Length - 1) && (I.SymbolList[i].i_Name == WellKnownSymbols.VARARGS)) - { - int len = argsList.Count - i; - DynValue[] varargs = new DynValue[len]; - - for (int ii = 0; ii < len; ii++, i++) - { - varargs[ii] = argsList[i].ToScalar().CloneAsWritable(); - } - - this.AssignLocal(I.SymbolList[I.SymbolList.Length - 1], DynValue.NewTuple(Internal_AdjustTuple(varargs))); - } - else - { - this.AssignLocal(I.SymbolList[i], argsList[i].ToScalar().CloneAsWritable()); - } - } - } - - - - - private int Internal_ExecCall(int argsCount, int instructionPtr, CallbackFunction handler = null, - CallbackFunction continuation = null, bool thisCall = false, string debugText = null, DynValue unwindHandler = null) - { - DynValue fn = m_ValueStack.Peek(argsCount); - CallStackItemFlags flags = (thisCall ? CallStackItemFlags.MethodCall : CallStackItemFlags.None); - - // if TCO threshold reached - if ((m_ExecutionStack.Count > this.m_Script.Options.TailCallOptimizationThreshold && m_ExecutionStack.Count > 1) - || (m_ValueStack.Count > this.m_Script.Options.TailCallOptimizationThreshold && m_ValueStack.Count > 1)) - { - // and the "will-be" return address is valid (we don't want to crash here) - if (instructionPtr >= 0 && instructionPtr < this.m_RootChunk.Code.Count) - { - Instruction I = this.m_RootChunk.Code[instructionPtr]; - - // and we are followed *exactly* by a RET 1 - if (I.OpCode == OpCode.Ret && I.NumVal == 1) - { - CallStackItem csi = m_ExecutionStack.Peek(); - - // if the current stack item has no "odd" things pending and neither has the new coming one.. - if (csi.ClrFunction == null && csi.Continuation == null && csi.ErrorHandler == null - && csi.ErrorHandlerBeforeUnwind == null && continuation == null && unwindHandler == null && handler == null) - { - instructionPtr = PerformTCO(instructionPtr, argsCount); - flags |= CallStackItemFlags.TailCall; - } - } - } - } - - - - if (fn.Type == DataType.ClrFunction) - { - //IList args = new Slice(m_ValueStack, m_ValueStack.Count - argsCount, argsCount, false); - IList args = CreateArgsListForFunctionCall(argsCount, 0); - // we expand tuples before callbacks - // args = DynValue.ExpandArgumentsToList(args); - SourceRef sref = GetCurrentSourceRef(instructionPtr); - - m_ExecutionStack.Push(new CallStackItem() - { - ClrFunction = fn.Callback, - ReturnAddress = instructionPtr, - CallingSourceRef = sref, - BasePointer = -1, - ErrorHandler = handler, - Continuation = continuation, - ErrorHandlerBeforeUnwind = unwindHandler, - Flags = flags, - }); - - var ret = fn.Callback.Invoke(new ScriptExecutionContext(this, fn.Callback, sref), args, isMethodCall: thisCall); - m_ValueStack.RemoveLast(argsCount + 1); - m_ValueStack.Push(ret); - - m_ExecutionStack.Pop(); - - return Internal_CheckForTailRequests(null, instructionPtr); - } - else if (fn.Type == DataType.Function) - { - m_ValueStack.Push(DynValue.NewNumber(argsCount)); - m_ExecutionStack.Push(new CallStackItem() - { - BasePointer = m_ValueStack.Count, - ReturnAddress = instructionPtr, - Debug_EntryPoint = fn.Function.EntryPointByteCodeLocation, - CallingSourceRef = GetCurrentSourceRef(instructionPtr), - ClosureScope = fn.Function.ClosureContext, - ErrorHandler = handler, - Continuation = continuation, - ErrorHandlerBeforeUnwind = unwindHandler, - Flags = flags, - }); - return fn.Function.EntryPointByteCodeLocation; - } - - // fallback to __call metamethod - var m = GetMetamethod(fn, "__call"); - - if (m != null && m.IsNotNil()) - { - DynValue[] tmp = new DynValue[argsCount + 1]; - for (int i = 0; i < argsCount + 1; i++) - tmp[i] = m_ValueStack.Pop(); - - m_ValueStack.Push(m); - - for (int i = argsCount; i >= 0; i--) - m_ValueStack.Push(tmp[i]); - - return Internal_ExecCall(argsCount + 1, instructionPtr, handler, continuation); - } - - throw ScriptRuntimeException.AttemptToCallNonFunc(fn.Type, debugText); - } - - private int PerformTCO(int instructionPtr, int argsCount) - { - DynValue[] args = new DynValue[argsCount + 1]; - - // Remove all cur args and func ptr - for (int i = 0; i <= argsCount; i++) - args[i] = m_ValueStack.Pop(); - - // perform a fake RET - CallStackItem csi = PopToBasePointer(); - int retpoint = csi.ReturnAddress; - var argscnt = (int)(m_ValueStack.Pop().Number); - m_ValueStack.RemoveLast(argscnt + 1); - - // Re-push all cur args and func ptr - for (int i = argsCount; i >= 0; i--) - m_ValueStack.Push(args[i]); - - return retpoint; - } - - - - - private int ExecRet(Instruction i) - { - CallStackItem csi; - int retpoint = 0; - - if (i.NumVal == 0) - { - csi = PopToBasePointer(); - retpoint = csi.ReturnAddress; - var argscnt = (int)(m_ValueStack.Pop().Number); - m_ValueStack.RemoveLast(argscnt + 1); - m_ValueStack.Push(DynValue.Void); - } - else if (i.NumVal == 1) - { - var retval = m_ValueStack.Pop(); - csi = PopToBasePointer(); - retpoint = csi.ReturnAddress; - var argscnt = (int)(m_ValueStack.Pop().Number); - m_ValueStack.RemoveLast(argscnt + 1); - m_ValueStack.Push(retval); - retpoint = Internal_CheckForTailRequests(i, retpoint); - } - else - { - throw new InternalErrorException("RET supports only 0 and 1 ret val scenarios"); - } - - if (csi.Continuation != null) - m_ValueStack.Push(csi.Continuation.Invoke(new ScriptExecutionContext(this, csi.Continuation, i.SourceCodeRef), - new DynValue[1] { m_ValueStack.Pop() })); - - return retpoint; - } - - - - private int Internal_CheckForTailRequests(Instruction i, int instructionPtr) - { - DynValue tail = m_ValueStack.Peek(0); - - if (tail.Type == DataType.TailCallRequest) - { - m_ValueStack.Pop(); // discard tail call request - - TailCallData tcd = tail.TailCallData; - - m_ValueStack.Push(tcd.Function); - - for (int ii = 0; ii < tcd.Args.Length; ii++) - m_ValueStack.Push(tcd.Args[ii]); - - return Internal_ExecCall(tcd.Args.Length, instructionPtr, tcd.ErrorHandler, tcd.Continuation, false, null, tcd.ErrorHandlerBeforeUnwind); - } - else if (tail.Type == DataType.YieldRequest) - { - m_SavedInstructionPtr = instructionPtr; - return YIELD_SPECIAL_TRAP; - } - - - return instructionPtr; - } - - - - private int JumpBool(Instruction i, bool expectedValueForJump, int instructionPtr) - { - DynValue op = m_ValueStack.Pop().ToScalar(); - - if (op.CastToBool() == expectedValueForJump) - return i.NumVal; - - return instructionPtr; - } - - private int ExecShortCircuitingOperator(Instruction i, int instructionPtr) - { - bool expectedValToShortCircuit = i.OpCode == OpCode.JtOrPop; - - DynValue op = m_ValueStack.Peek().ToScalar(); - - if (op.CastToBool() == expectedValToShortCircuit) - { - return i.NumVal; - } - else - { - m_ValueStack.Pop(); - return instructionPtr; - } - } - - - private int ExecAdd(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(ln.Value + rn.Value)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__add", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - } - - private int ExecSub(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(ln.Value - rn.Value)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__sub", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - } - - - private int ExecMul(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(ln.Value * rn.Value)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__mul", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - } - - private int ExecMod(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - double mod = Math.IEEERemainder(ln.Value, rn.Value); - if (mod < 0) mod += rn.Value; - m_ValueStack.Push(DynValue.NewNumber(mod)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__mod", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - } - - private int ExecDiv(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(ln.Value / rn.Value)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__div", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - } - private int ExecPower(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - double? rn = r.CastToNumber(); - double? ln = l.CastToNumber(); - - if (ln.HasValue && rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(Math.Pow(ln.Value, rn.Value))); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__pow", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); - } - - } - - private int ExecNeg(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - double? rn = r.CastToNumber(); - - if (rn.HasValue) - { - m_ValueStack.Push(DynValue.NewNumber(-rn.Value)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeUnaryMetaMethod(r, "__unm", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ArithmeticOnNonNumber(r); - } - } - - - private int ExecEq(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - // first we do a brute force equals over the references - if (object.ReferenceEquals(r, l)) - { - m_ValueStack.Push(DynValue.True); - return instructionPtr; - } - - // then if they are userdatas, attempt meta - if (l.Type == DataType.UserData || r.Type == DataType.UserData) - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__eq", instructionPtr); - if (ip >= 0) return ip; - } - - // then if types are different, ret false - if (r.Type != l.Type) - { - if ((l.Type == DataType.Nil && r.Type == DataType.Void) || (l.Type == DataType.Void && r.Type == DataType.Nil)) - m_ValueStack.Push(DynValue.True); - else - m_ValueStack.Push(DynValue.False); - - return instructionPtr; - } - - // then attempt metatables for tables - if ((l.Type == DataType.Table) && (GetMetatable(l) != null) && (GetMetatable(l) == GetMetatable(r))) - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__eq", instructionPtr); - if (ip >= 0) return ip; - } - - // else perform standard comparison - m_ValueStack.Push(DynValue.NewBoolean(r.Equals(l))); - return instructionPtr; - } - - private int ExecLess(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - if (l.Type == DataType.Number && r.Type == DataType.Number) - { - m_ValueStack.Push(DynValue.NewBoolean(l.Number < r.Number)); - } - else if (l.Type == DataType.String && r.Type == DataType.String) - { - m_ValueStack.Push(DynValue.NewBoolean(l.String.CompareTo(r.String) < 0)); - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__lt", instructionPtr); - if (ip < 0) - throw ScriptRuntimeException.CompareInvalidType(l, r); - else - return ip; - } - - return instructionPtr; - } - - - private int ExecLessEq(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - if (l.Type == DataType.Number && r.Type == DataType.Number) - { - m_ValueStack.Push(DynValue.False); - m_ValueStack.Push(DynValue.NewBoolean(l.Number <= r.Number)); - } - else if (l.Type == DataType.String && r.Type == DataType.String) - { - m_ValueStack.Push(DynValue.False); - m_ValueStack.Push(DynValue.NewBoolean(l.String.CompareTo(r.String) <= 0)); - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__le", instructionPtr, DynValue.False); - if (ip < 0) - { - ip = Internal_InvokeBinaryMetaMethod(r, l, "__lt", instructionPtr, DynValue.True); - - if (ip < 0) - throw ScriptRuntimeException.CompareInvalidType(l, r); - else - return ip; - } - else - return ip; - } - - return instructionPtr; - } - - private int ExecLen(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - - if (r.Type == DataType.String) - m_ValueStack.Push(DynValue.NewNumber(r.String.Length)); - else - { - int ip = Internal_InvokeUnaryMetaMethod(r, "__len", instructionPtr); - if (ip >= 0) - return ip; - else if (r.Type == DataType.Table) - m_ValueStack.Push(DynValue.NewNumber(r.Table.Length)); - - else throw ScriptRuntimeException.LenOnInvalidType(r); - } - - return instructionPtr; - } - - - private int ExecConcat(Instruction i, int instructionPtr) - { - DynValue r = m_ValueStack.Pop().ToScalar(); - DynValue l = m_ValueStack.Pop().ToScalar(); - - string rs = r.CastToString(); - string ls = l.CastToString(); - - if (rs != null && ls != null) - { - m_ValueStack.Push(DynValue.NewString(ls + rs)); - return instructionPtr; - } - else - { - int ip = Internal_InvokeBinaryMetaMethod(l, r, "__concat", instructionPtr); - if (ip >= 0) return ip; - else throw ScriptRuntimeException.ConcatOnNonString(l, r); - } - - } - - - private void ExecTblInitI(Instruction i) - { - // stack: tbl - val - DynValue val = m_ValueStack.Pop(); - DynValue tbl = m_ValueStack.Peek(); - - if (tbl.Type != DataType.Table) - throw new InternalErrorException("Unexpected type in table ctor : {0}", tbl); - - tbl.Table.InitNextArrayKeys(val, i.NumVal != 0); - } - - private void ExecTblInitN(Instruction i) - { - // stack: tbl - key - val - DynValue val = m_ValueStack.Pop(); - DynValue key = m_ValueStack.Pop(); - DynValue tbl = m_ValueStack.Peek(); - - if (tbl.Type != DataType.Table) - throw new InternalErrorException("Unexpected type in table ctor : {0}", tbl); - - tbl.Table.Set(key, val.ToScalar()); - } - - private int ExecIndexSet(Instruction i, int instructionPtr) - { - int nestedMetaOps = 100; // sanity check, to avoid potential infinite loop here - - // stack: vals.. - base - index - bool isNameIndex = i.OpCode == OpCode.IndexSetN; - bool isMultiIndex = (i.OpCode == OpCode.IndexSetL); - - DynValue originalIdx = i.Value ?? m_ValueStack.Pop(); - DynValue idx = originalIdx.ToScalar(); - DynValue obj = m_ValueStack.Pop().ToScalar(); - var value = GetStoreValue(i); - DynValue h = null; - - - while (nestedMetaOps > 0) - { - --nestedMetaOps; - - if (obj.Type == DataType.Table) - { - if (!isMultiIndex) - { - if (!obj.Table.Get(idx).IsNil()) - { - obj.Table.Set(idx, value); - return instructionPtr; - } - } - - h = GetMetamethodRaw(obj, "__newindex"); - - if (h == null || h.IsNil()) - { - if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index a table. userdata expected"); - - obj.Table.Set(idx, value); - return instructionPtr; - } - } - else if (obj.Type == DataType.UserData) - { - UserData ud = obj.UserData; - - if (!ud.Descriptor.SetIndex(this.GetScript(), ud.Object, originalIdx, value, isNameIndex)) - { - throw ScriptRuntimeException.UserDataMissingField(ud.Descriptor.Name, idx.String); - } - - return instructionPtr; - } - else - { - h = GetMetamethodRaw(obj, "__newindex"); - - if (h == null || h.IsNil()) - throw ScriptRuntimeException.IndexType(obj); - } - - if (h.Type == DataType.Function || h.Type == DataType.ClrFunction) - { - if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index through metamethods. userdata expected"); - m_ValueStack.Pop(); // burn extra value ? - - m_ValueStack.Push(h); - m_ValueStack.Push(obj); - m_ValueStack.Push(idx); - m_ValueStack.Push(value); - return Internal_ExecCall(3, instructionPtr); - } - else - { - obj = h; - h = null; - } - } - throw ScriptRuntimeException.LoopInNewIndex(); - } - - private int ExecIndex(Instruction i, int instructionPtr) - { - int nestedMetaOps = 100; // sanity check, to avoid potential infinite loop here - - // stack: base - index - bool isNameIndex = i.OpCode == OpCode.IndexN; - - bool isMultiIndex = (i.OpCode == OpCode.IndexL); - - DynValue originalIdx = i.Value ?? m_ValueStack.Pop(); - DynValue idx = originalIdx.ToScalar(); - DynValue obj = m_ValueStack.Pop().ToScalar(); - - DynValue h = null; - - - while (nestedMetaOps > 0) - { - --nestedMetaOps; - - if (obj.Type == DataType.Table) - { - if (!isMultiIndex) - { - var v = obj.Table.Get(idx); - - if (!v.IsNil()) - { - m_ValueStack.Push(v.AsReadOnly()); - return instructionPtr; - } - } - - h = GetMetamethodRaw(obj, "__index"); - - if (h == null || h.IsNil()) - { - if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index a table. userdata expected"); - - m_ValueStack.Push(DynValue.Nil); - return instructionPtr; - } - } - else if (obj.Type == DataType.UserData) - { - UserData ud = obj.UserData; - - var v = ud.Descriptor.Index(this.GetScript(), ud.Object, originalIdx, isNameIndex); - - if (v == null) - { - throw ScriptRuntimeException.UserDataMissingField(ud.Descriptor.Name, idx.String); - } - - m_ValueStack.Push(v.AsReadOnly()); - return instructionPtr; - } - else - { - h = GetMetamethodRaw(obj, "__index"); - - if (h == null || h.IsNil()) - throw ScriptRuntimeException.IndexType(obj); - } - - if (h.Type == DataType.Function || h.Type == DataType.ClrFunction) - { - if (isMultiIndex) throw new ScriptRuntimeException("cannot multi-index through metamethods. userdata expected"); - m_ValueStack.Push(h); - m_ValueStack.Push(obj); - m_ValueStack.Push(idx); - return Internal_ExecCall(2, instructionPtr); - } - else - { - obj = h; - h = null; - } - } - - throw ScriptRuntimeException.LoopInIndex(); - } - - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Scope.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Scope.cs deleted file mode 100644 index f08ccff4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_Scope.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - private void ClearBlockData(Instruction I) - { - int from = I.NumVal; - int to = I.NumVal2; - - var array = this.m_ExecutionStack.Peek().LocalScope; - - if (to >= 0 && from >= 0 && to >= from) - { - Array.Clear(array, from, to - from + 1); - } - } - - - public DynValue GetGenericSymbol(SymbolRef symref) - { - switch (symref.i_Type) - { - case SymbolRefType.DefaultEnv: - return DynValue.NewTable(this.GetScript().Globals); - case SymbolRefType.Global: - return GetGlobalSymbol(GetGenericSymbol(symref.i_Env), symref.i_Name); - case SymbolRefType.Local: - return GetTopNonClrFunction().LocalScope[symref.i_Index]; - case SymbolRefType.Upvalue: - return GetTopNonClrFunction().ClosureScope[symref.i_Index]; - default: - throw new InternalErrorException("Unexpected {0} LRef at resolution: {1}", symref.i_Type, symref.i_Name); - } - } - - private DynValue GetGlobalSymbol(DynValue dynValue, string name) - { - if (dynValue.Type != DataType.Table) - throw new InvalidOperationException(string.Format("_ENV is not a table but a {0}", dynValue.Type)); - - return dynValue.Table.Get(name); - } - - private void SetGlobalSymbol(DynValue dynValue, string name, DynValue value) - { - if (dynValue.Type != DataType.Table) - throw new InvalidOperationException(string.Format("_ENV is not a table but a {0}", dynValue.Type)); - - dynValue.Table.Set(name, value ?? DynValue.Nil); - } - - - public void AssignGenericSymbol(SymbolRef symref, DynValue value) - { - switch (symref.i_Type) - { - case SymbolRefType.Global: - SetGlobalSymbol(GetGenericSymbol(symref.i_Env), symref.i_Name, value); - break; - case SymbolRefType.Local: - { - var stackframe = GetTopNonClrFunction(); - - DynValue v = stackframe.LocalScope[symref.i_Index]; - if (v == null) - stackframe.LocalScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); - } - break; - case SymbolRefType.Upvalue: - { - var stackframe = GetTopNonClrFunction(); - - DynValue v = stackframe.ClosureScope[symref.i_Index]; - if (v == null) - stackframe.ClosureScope[symref.i_Index] = v = DynValue.NewNil(); - - v.Assign(value); - } - break; - case SymbolRefType.DefaultEnv: - { - throw new ArgumentException("Can't AssignGenericSymbol on a DefaultEnv symbol"); - } - default: - throw new InternalErrorException("Unexpected {0} LRef at resolution: {1}", symref.i_Type, symref.i_Name); - } - } - - CallStackItem GetTopNonClrFunction() - { - CallStackItem stackframe = null; - - for (int i = 0; i < m_ExecutionStack.Count; i++) - { - stackframe = m_ExecutionStack.Peek(i); - - if (stackframe.ClrFunction == null) - break; - } - - return stackframe; - } - - - public SymbolRef FindSymbolByName(string name) - { - if (m_ExecutionStack.Count > 0) - { - CallStackItem stackframe = GetTopNonClrFunction(); - - if (stackframe != null) - { - if (stackframe.Debug_Symbols != null) - { - for (int i = stackframe.Debug_Symbols.Length - 1; i >= 0; i--) - { - var l = stackframe.Debug_Symbols[i]; - - if (l.i_Name == name && stackframe.LocalScope[i] != null) - return l; - } - } - - - var closure = stackframe.ClosureScope; - - if (closure != null) - { - for (int i = 0; i < closure.Symbols.Length; i++) - if (closure.Symbols[i] == name) - return SymbolRef.Upvalue(name, i); - } - } - } - - if (name != WellKnownSymbols.ENV) - { - SymbolRef env = FindSymbolByName(WellKnownSymbols.ENV); - return SymbolRef.Global(name, env); - } - else - { - return SymbolRef.DefaultEnv; - } - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_UtilityFunctions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_UtilityFunctions.cs deleted file mode 100644 index 3ad7253d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Execution/VM/Processor/Processor_UtilityFunctions.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Execution.VM -{ - sealed partial class Processor - { - private DynValue[] Internal_AdjustTuple(IList values) - { - if (values == null || values.Count == 0) - return new DynValue[0]; - - if (values[values.Count - 1].Type == DataType.Tuple) - { - int baseLen = values.Count - 1 + values[values.Count - 1].Tuple.Length; - DynValue[] result = new DynValue[baseLen]; - - for (int i = 0; i < values.Count - 1; i++) - { - result[i] = values[i].ToScalar(); - } - - for (int i = 0; i < values[values.Count - 1].Tuple.Length; i++) - { - result[values.Count + i - 1] = values[values.Count - 1].Tuple[i]; - } - - if (result[result.Length - 1].Type == DataType.Tuple) - return Internal_AdjustTuple(result); - else - return result; - } - else - { - DynValue[] result = new DynValue[values.Count]; - - for (int i = 0; i < values.Count; i++) - { - result[i] = values[i].ToScalar(); - } - - return result; - } - } - - - - private int Internal_InvokeUnaryMetaMethod(DynValue op1, string eventName, int instructionPtr) - { - DynValue m = null; - - if (op1.Type == DataType.UserData) - { - m = op1.UserData.Descriptor.MetaIndex(m_Script, op1.UserData.Object, eventName); - } - - if (m == null) - { - var op1_MetaTable = GetMetatable(op1); - - if (op1_MetaTable != null) - { - DynValue meta1 = op1_MetaTable.RawGet(eventName); - if (meta1 != null && meta1.IsNotNil()) - m = meta1; - } - } - - if (m != null) - { - m_ValueStack.Push(m); - m_ValueStack.Push(op1); - return Internal_ExecCall(1, instructionPtr); - } - else - { - return -1; - } - } - private int Internal_InvokeBinaryMetaMethod(DynValue l, DynValue r, string eventName, int instructionPtr, DynValue extraPush = null) - { - var m = GetBinaryMetamethod(l, r, eventName); - - if (m != null) - { - if (extraPush != null) - m_ValueStack.Push(extraPush); - - m_ValueStack.Push(m); - m_ValueStack.Push(l); - m_ValueStack.Push(r); - return Internal_ExecCall(2, instructionPtr); - } - else - { - return -1; - } - } - - - - - private DynValue[] StackTopToArray(int items, bool pop) - { - DynValue[] values = new DynValue[items]; - - if (pop) - { - for (int i = 0; i < items; i++) - { - values[i] = m_ValueStack.Pop(); - } - } - else - { - for (int i = 0; i < items; i++) - { - values[i] = m_ValueStack[m_ValueStack.Count - 1 - i]; - } - } - - return values; - } - - private DynValue[] StackTopToArrayReverse(int items, bool pop) - { - DynValue[] values = new DynValue[items]; - - if (pop) - { - for (int i = 0; i < items; i++) - { - values[items - 1 - i] = m_ValueStack.Pop(); - } - } - else - { - for (int i = 0; i < items; i++) - { - values[items - 1 - i] = m_ValueStack[m_ValueStack.Count - 1 - i]; - } - } - - return values; - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryReader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryReader.cs deleted file mode 100755 index f10b98d4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryReader.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// "Optimized" BinaryReader which shares strings and use a dumb compression for integers - /// - public class BinDumpBinaryReader : BinaryReader - { - public BinDumpBinaryReader(Stream s) : base(s) { } - public BinDumpBinaryReader(Stream s, Encoding e) : base(s, e) { } - - List m_Strings = new List(); - - public override int ReadInt32() - { - sbyte b = base.ReadSByte(); - - if (b == 0x7F) - return (int)base.ReadInt16(); - else if (b == 0x7E) - return (int)base.ReadInt32(); - else - return (int)b; - } - - public override uint ReadUInt32() - { - byte b = base.ReadByte(); - - if (b == 0x7F) - return (uint)base.ReadUInt16(); - else if (b == 0x7E) - return (uint)base.ReadUInt32(); - else - return (uint)b; - } - - public override string ReadString() - { - int pos = ReadInt32(); - - if (pos < m_Strings.Count) - { - return m_Strings[pos]; - } - else if (pos == m_Strings.Count) - { - string str = base.ReadString(); - m_Strings.Add(str); - return str; - } - else - { - throw new IOException("string map failure"); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryWriter.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryWriter.cs deleted file mode 100755 index bd360fd6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/BinDumpBinaryWriter.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// "Optimized" BinaryWriter which shares strings and use a dumb compression for integers - /// - public class BinDumpBinaryWriter : BinaryWriter - { - Dictionary m_StringMap = new Dictionary(); - - public BinDumpBinaryWriter(Stream s) : base(s) { } - public BinDumpBinaryWriter(Stream s, Encoding e) : base(s, e) { } - - public override void Write(uint value) - { - byte v8 = (byte)value; - - if ((uint)v8 == value && (v8 != 0x7F) && (v8 != 0x7E)) - { - base.Write(v8); - } - else - { - ushort v16 = (ushort)value; - - if ((uint)v16 == value) - { - base.Write((byte)0x7F); - base.Write(v16); - } - else - { - base.Write((byte)0x7E); - base.Write(value); - } - } - } - - public override void Write(int value) - { - sbyte vsbyte = (sbyte)value; - - if ((int)vsbyte == value && (vsbyte != 0x7F) && (vsbyte != 0x7E)) - { - base.Write(vsbyte); - } - else - { - short vshort = (short)value; - - if ((int)vshort == value) - { - base.Write((sbyte)0x7F); - base.Write(vshort); - } - else - { - base.Write((sbyte)0x7E); - base.Write(value); - } - } - } - - public override void Write(string value) - { - int pos; - - if (m_StringMap.TryGetValue(value, out pos)) - { - this.Write(m_StringMap[value]); - } - else - { - pos = m_StringMap.Count; - m_StringMap[value] = pos; - - this.Write(pos); - base.Write(value); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/UndisposableStream.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/UndisposableStream.cs deleted file mode 100755 index 622b929b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/IO/UndisposableStream.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.IO; - -namespace MoonSharp.Interpreter.IO -{ - /// - /// An adapter over Stream which bypasses the Dispose and Close methods. - /// Used to work around the pesky wrappers .NET has over Stream (BinaryReader, StreamWriter, etc.) which think they - /// own the Stream and close them when they shouldn't. Damn. - /// - public class UndisposableStream : Stream - { - Stream m_Stream; - - public UndisposableStream(Stream stream) - { - m_Stream = stream; - } - - protected override void Dispose(bool disposing) - { - } - -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) - public override void Close() - { - } -#endif - - - public override bool CanRead - { - get { return m_Stream.CanRead; } - } - - public override bool CanSeek - { - get { return m_Stream.CanSeek; } - } - - public override bool CanWrite - { - get { return m_Stream.CanWrite; } - } - - public override void Flush() - { - m_Stream.Flush(); - } - - public override long Length - { - get { return m_Stream.Length; } - } - - public override long Position - { - get { return m_Stream.Position; } - set { m_Stream.Position = value; } - } - - public override int Read(byte[] buffer, int offset, int count) - { - return m_Stream.Read(buffer, offset, count); - } - - public override long Seek(long offset, SeekOrigin origin) - { - return m_Stream.Seek(offset, origin); - } - - public override void SetLength(long value) - { - m_Stream.SetLength(value); - } - - public override void Write(byte[] buffer, int offset, int count) - { - m_Stream.Write(buffer, offset, count); - } - -#if (!(NETFX_CORE)) - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return m_Stream.BeginRead(buffer, offset, count, callback, state); - } - - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return m_Stream.BeginWrite(buffer, offset, count, callback, state); - } - - public override void EndWrite(IAsyncResult asyncResult) - { - m_Stream.EndWrite(asyncResult); - } - - public override int EndRead(IAsyncResult asyncResult) - { - return m_Stream.EndRead(asyncResult); - } -#endif - public override bool CanTimeout - { - get { return m_Stream.CanTimeout; } - } - - - public override bool Equals(object obj) - { - return m_Stream.Equals(obj); - } - - public override int GetHashCode() - { - return m_Stream.GetHashCode(); - } - - - public override int ReadByte() - { - return m_Stream.ReadByte(); - } - - public override int ReadTimeout - { - get - { - return m_Stream.ReadTimeout; - } - set - { - m_Stream.ReadTimeout = value; - } - } - - public override string ToString() - { - return m_Stream.ToString(); - } - - public override void WriteByte(byte value) - { - m_Stream.WriteByte(value); - } - - public override int WriteTimeout - { - get - { - return m_Stream.WriteTimeout; - } - set - { - m_Stream.WriteTimeout = value; - } - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHiddenAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHiddenAttribute.cs deleted file mode 100644 index 7012483d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHiddenAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Forces a class member visibility to scripts. Can be used to hide public members. Equivalent to MoonSharpVisible(false). - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field - | AttributeTargets.Constructor | AttributeTargets.Event, Inherited = true, AllowMultiple = false)] - public sealed class MoonSharpHiddenAttribute : Attribute - { - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHideMemberAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHideMemberAttribute.cs deleted file mode 100644 index cc5df024..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpHideMemberAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Lists a userdata member not to be exposed to scripts referencing it by name. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = true)] - public sealed class MoonSharpHideMemberAttribute : Attribute - { - /// - /// Gets the name of the member to be hidden. - /// - public string MemberName { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// Name of the member to hide. - public MoonSharpHideMemberAttribute(string memberName) - { - MemberName = memberName; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpPropertyAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpPropertyAttribute.cs deleted file mode 100644 index a3fe6fec..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpPropertyAttribute.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - - /// - /// Marks a property as a configruation property - /// - [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)] - public sealed class MoonSharpPropertyAttribute : Attribute - { - /// - /// The metamethod name (like '__div', '__ipairs', etc.) - /// - public string Name { get; private set; } - - - /// - /// Initializes a new instance of the class. - /// - public MoonSharpPropertyAttribute() - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// The name for this property - public MoonSharpPropertyAttribute(string name) - { - Name = name; - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataAttribute.cs deleted file mode 100644 index ec2c5c64..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataAttribute.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Marks a type of automatic registration as userdata (which happens only if UserData.RegisterAssembly is called). - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)] - public sealed class MoonSharpUserDataAttribute : Attribute - { - /// - /// The interop access mode - /// - public InteropAccessMode AccessMode { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public MoonSharpUserDataAttribute() - { - AccessMode = InteropAccessMode.Default; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataMetamethodAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataMetamethodAttribute.cs deleted file mode 100644 index 42fb93ba..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpUserDataMetamethodAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Marks a method as the handler of metamethods of a userdata type - /// - [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = true)] - public sealed class MoonSharpUserDataMetamethodAttribute : Attribute - { - /// - /// The metamethod name (like '__div', '__ipairs', etc.) - /// - public string Name { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The metamethod name (like '__div', '__ipairs', etc.) - public MoonSharpUserDataMetamethodAttribute(string name) - { - Name = name; - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpVisibleAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpVisibleAttribute.cs deleted file mode 100644 index 03b43369..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Attributes/MoonSharpVisibleAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Forces a class member visibility to scripts. Can be used to hide public members or to expose non-public ones. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field - | AttributeTargets.Constructor | AttributeTargets.Event, Inherited = true, AllowMultiple = false)] - public sealed class MoonSharpVisibleAttribute : Attribute - { - /// - /// Gets a value indicating whether this is set to "visible". - /// - public bool Visible { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// if set to true the member will be exposed to scripts, if false the member will be hidden. - public MoonSharpVisibleAttribute(bool visible) - { - Visible = visible; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs deleted file mode 100644 index 17ccd53b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs +++ /dev/null @@ -1,665 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// An abstract user data descriptor which accepts members described by objects and - /// correctly dispatches to them. - /// Metamethods are also by default dispatched to operator overloads and other similar methods - see - /// . - /// - public abstract class DispatchingUserDataDescriptor : IUserDataDescriptor, IOptimizableDescriptor - { - private int m_ExtMethodsVersion = 0; - private Dictionary m_MetaMembers = new Dictionary(); - private Dictionary m_Members = new Dictionary(); - - /// - /// The special name used by CLR for indexer getters - /// - protected const string SPECIALNAME_INDEXER_GET = "get_Item"; - /// - /// The special name used by CLR for indexer setters - /// - protected const string SPECIALNAME_INDEXER_SET = "set_Item"; - - /// - /// The special name used by CLR for explicit cast conversions - /// - protected const string SPECIALNAME_CAST_EXPLICIT = "op_Explicit"; - /// - /// The special name used by CLR for implicit cast conversions - /// - protected const string SPECIALNAME_CAST_IMPLICIT = "op_Implicit"; - - - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - public string Name { get; private set; } - /// - /// Gets the type this descriptor refers to - /// - public Type Type { get; private set; } - /// - /// Gets a human readable friendly name of the descriptor - /// - public string FriendlyName { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The type this descriptor refers to. - /// A friendly name for the type, or null. - protected DispatchingUserDataDescriptor(Type type, string friendlyName = null) - { - Type = type; - Name = type.FullName; - FriendlyName = friendlyName ?? type.Name; - } - - /// - /// Adds a member to the meta-members list. - /// - /// The name of the metamethod. - /// The desc. - /// - /// Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - /// - public void AddMetaMember(string name, IMemberDescriptor desc) - { - if (desc != null) - AddMemberTo(m_MetaMembers, name, desc); - } - - - /// - /// Adds a DynValue as a member - /// - /// The name. - /// The value. - public void AddDynValue(string name, DynValue value) - { - var desc = new DynValueMemberDescriptor(name, value); - AddMemberTo(m_Members, name, desc); - } - - /// - /// Adds a property to the member list - /// - /// The name. - /// The descriptor. - /// - /// Thrown if a name conflict is detected and one of the conflicting members does not support overloads. - /// - public void AddMember(string name, IMemberDescriptor desc) - { - if (desc != null) - AddMemberTo(m_Members, name, desc); - } - - /// - /// Gets the member names. - /// - public IEnumerable MemberNames - { - get { return m_Members.Keys; } - } - - /// - /// Gets the members. - /// - public IEnumerable> Members - { - get { return m_Members; } - } - - /// - /// Finds the member with a given name. If not found, null is returned. - /// - /// Name of the member. - /// - public IMemberDescriptor FindMember(string memberName) - { - return m_Members.GetOrDefault(memberName); - } - - /// - /// Removes the member with a given name. In case of overloaded functions, all overloads are removed. - /// - /// Name of the member. - public void RemoveMember(string memberName) - { - m_Members.Remove(memberName); - } - - /// - /// Gets the meta member names. - /// - public IEnumerable MetaMemberNames - { - get { return m_MetaMembers.Keys; } - } - - /// - /// Gets the meta members. - /// - public IEnumerable> MetaMembers - { - get { return m_MetaMembers; } - } - - /// - /// Finds the meta member with a given name. If not found, null is returned. - /// - /// Name of the member. - public IMemberDescriptor FindMetaMember(string memberName) - { - return m_MetaMembers.GetOrDefault(memberName); - } - - /// - /// Removes the meta member with a given name. In case of overloaded functions, all overloads are removed. - /// - /// Name of the member. - public void RemoveMetaMember(string memberName) - { - m_MetaMembers.Remove(memberName); - } - - - - - private void AddMemberTo(Dictionary members, string name, IMemberDescriptor desc) - { - IOverloadableMemberDescriptor odesc = desc as IOverloadableMemberDescriptor; - - if (odesc != null) - { - if (members.ContainsKey(name)) - { - OverloadedMethodMemberDescriptor overloads = members[name] as OverloadedMethodMemberDescriptor; - - if (overloads != null) - overloads.AddOverload(odesc); - else - throw new ArgumentException(string.Format("Multiple members named {0} are being added to type {1} and one or more of these members do not support overloads.", name, this.Type.FullName)); - } - else - { - members.Add(name, new OverloadedMethodMemberDescriptor(name, this.Type, odesc)); - } - } - else - { - if (members.ContainsKey(name)) - { - throw new ArgumentException(string.Format("Multiple members named {0} are being added to type {1} and one or more of these members do not support overloads.", name, this.Type.FullName)); - } - else - { - members.Add(name, desc); - } - } - } - - /// - /// Performs an "index" "get" operation. This tries to resolve minor variations of member names. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public virtual DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing) - { - if (!isDirectIndexing) - { - IMemberDescriptor mdesc = m_Members - .GetOrDefault(SPECIALNAME_INDEXER_GET) - .WithAccessOrNull(MemberDescriptorAccess.CanExecute); - - if (mdesc != null) - return ExecuteIndexer(mdesc, script, obj, index, null); - } - - index = index.ToScalar(); - - if (index.Type != DataType.String) - return null; - - DynValue v = TryIndex(script, obj, index.String); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndex(script, obj, UpperFirstLetter(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndex(script, obj, Camelify(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndex(script, obj, UpperFirstLetter(Camelify(index.String))); - - if (v == null && m_ExtMethodsVersion < UserData.GetExtensionMethodsChangeVersion()) - { - m_ExtMethodsVersion = UserData.GetExtensionMethodsChangeVersion(); - - v = TryIndexOnExtMethod(script, obj, index.String); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TryIndexOnExtMethod(script, obj, Camelify(index.String)); - if (v == null && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(Camelify(index.String))); - } - - return v; - } - - - /// - /// Tries to perform an indexing operation by checking newly added extension methods for the given indexName. - /// - /// The script. - /// The object. - /// Member name to be indexed. - /// - /// - private DynValue TryIndexOnExtMethod(Script script, object obj, string indexName) - { - List methods = UserData.GetExtensionMethodsByNameAndType(indexName, this.Type); - - if (methods != null && methods.Count > 0) - { - var ext = new OverloadedMethodMemberDescriptor(indexName, this.Type); - ext.SetExtensionMethodsSnapshot(UserData.GetExtensionMethodsChangeVersion(), methods); - m_Members.Add(indexName, ext); - return DynValue.NewCallback(ext.GetCallback(script, obj)); - } - - return null; - } - - /// - /// Determines whether the descriptor contains the specified member (by exact name) - /// - /// Name of the member. - /// - public bool HasMember(string exactName) - { - return m_Members.ContainsKey(exactName); - } - - /// - /// Determines whether the descriptor contains the specified member in the meta list (by exact name) - /// - /// Name of the meta-member. - /// - public bool HasMetaMember(string exactName) - { - return m_MetaMembers.ContainsKey(exactName); - } - - - /// - /// Tries to perform an indexing operation by checking methods and properties for the given indexName - /// - /// The script. - /// The object. - /// Member name to be indexed. - /// - protected virtual DynValue TryIndex(Script script, object obj, string indexName) - { - IMemberDescriptor desc; - - if (m_Members.TryGetValue(indexName, out desc)) - { - return desc.GetValue(script, obj); - } - - return null; - } - - /// - /// Performs an "index" "set" operation. This tries to resolve minor variations of member names. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public virtual bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing) - { - if (!isDirectIndexing) - { - IMemberDescriptor mdesc = m_Members - .GetOrDefault(SPECIALNAME_INDEXER_SET) - .WithAccessOrNull(MemberDescriptorAccess.CanExecute); - - if (mdesc != null) - { - ExecuteIndexer(mdesc, script, obj, index, value); - return true; - } - } - - index = index.ToScalar(); - - if (index.Type != DataType.String) - return false; - - bool v = TrySetIndex(script, obj, index.String, value); - if (!v && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter) v = TrySetIndex(script, obj, UpperFirstLetter(index.String), value); - if (!v && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify) v = TrySetIndex(script, obj, Camelify(index.String), value); - if (!v && (Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase) v = TrySetIndex(script, obj, UpperFirstLetter(Camelify(index.String)), value); - - return v; - } - - /// - /// Tries to perform an indexing "set" operation by checking methods and properties for the given indexName - /// - /// The script. - /// The object. - /// Member name to be indexed. - /// The value. - /// - protected virtual bool TrySetIndex(Script script, object obj, string indexName, DynValue value) - { - IMemberDescriptor descr = m_Members.GetOrDefault(indexName); - - if (descr != null) - { - descr.SetValue(script, obj, value); - return true; - } - else - { - return false; - } - } - - void IOptimizableDescriptor.Optimize() - { - foreach (var m in this.m_MetaMembers.Values.OfType()) - m.Optimize(); - - foreach (var m in this.m_Members.Values.OfType()) - m.Optimize(); - } - - /// - /// Converts the specified name from underscore_case to camelCase. - /// Just a wrapper over the method with the same name, - /// - /// The name. - /// - protected static string Camelify(string name) - { - return DescriptorHelpers.Camelify(name); - } - - /// - /// Converts the specified name to one with an uppercase first letter (something to Something). - /// Just a wrapper over the method with the same name, - /// - /// The name. - /// - protected static string UpperFirstLetter(string name) - { - return DescriptorHelpers.UpperFirstLetter(name); - } - - /// - /// Converts this userdata to string - /// - /// The object. - /// - public virtual string AsString(object obj) - { - return (obj != null) ? obj.ToString() : null; - } - - - - /// - /// Executes the specified indexer method. - /// - /// The method descriptor - /// The script. - /// The object. - /// The indexer parameter - /// The dynvalue to set on a setter, or null. - /// - /// - protected virtual DynValue ExecuteIndexer(IMemberDescriptor mdesc, Script script, object obj, DynValue index, DynValue value) - { - IList values; - - if (index.Type == DataType.Tuple) - { - if (value == null) - { - values = index.Tuple; - } - else - { - values = new List(index.Tuple); - values.Add(value); - } - } - else - { - if (value == null) - { - values = new DynValue[] { index }; - } - else - { - values = new DynValue[] { index, value }; - } - } - - CallbackArguments args = new CallbackArguments(values, false); - ScriptExecutionContext execCtx = script.CreateDynamicExecutionContext(); - - DynValue v = mdesc.GetValue(script, obj); - - if (v.Type != DataType.ClrFunction) - throw new ScriptRuntimeException("a clr callback was expected in member {0}, while a {1} was found", mdesc.Name, v.Type); - - return v.Callback.ClrCallback(execCtx, args); - } - - - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// See for further details. - /// - /// If a method exists marked with for the specific - /// metamethod requested, that method is returned. - /// - /// If the above fails, the following dispatching occur: - /// - /// __add, __sub, __mul, __div, __mod and __unm are dispatched to C# operator overloads (if they exist) - /// __eq is dispatched to System.Object.Equals. - /// __lt and __le are dispatched IComparable.Compare, if the type implements IComparable or IComparable{object} - /// __len is dispatched to Length and Count properties, if those exist. - /// __iterator is handled if the object implements IEnumerable or IEnumerator. - /// __tonumber is dispatched to implicit or explicit conversion operators to standard numeric types. - /// __tobool is dispatched to an implicit or explicit conversion operator to bool. If that fails, operator true is used. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The name of the metamember. - /// - /// - public virtual DynValue MetaIndex(Script script, object obj, string metaname) - { - IMemberDescriptor desc = m_MetaMembers.GetOrDefault(metaname); - - if (desc != null) - { - return desc.GetValue(script, obj); - } - - switch (metaname) - { - case "__add": - return DispatchMetaOnMethod(script, obj, "op_Addition"); - case "__sub": - return DispatchMetaOnMethod(script, obj, "op_Subtraction"); - case "__mul": - return DispatchMetaOnMethod(script, obj, "op_Multiply"); - case "__div": - return DispatchMetaOnMethod(script, obj, "op_Division"); - case "__mod": - return DispatchMetaOnMethod(script, obj, "op_Modulus"); - case "__unm": - return DispatchMetaOnMethod(script, obj, "op_UnaryNegation"); - case "__eq": - return MultiDispatchEqual(script, obj); - case "__lt": - return MultiDispatchLessThan(script, obj); - case "__le": - return MultiDispatchLessThanOrEqual(script, obj); - case "__len": - return TryDispatchLength(script, obj); - case "__tonumber": - return TryDispatchToNumber(script, obj); - case "__tobool": - return TryDispatchToBool(script, obj); - case "__iterator": - return ClrToScriptConversions.EnumerationToDynValue(script, obj); - default: - return null; - } - } - - #region MetaMethodsDispatching - - - private int PerformComparison(object obj, object p1, object p2) - { - IComparable comp = (IComparable)obj; - - if (comp != null) - { - if (object.ReferenceEquals(obj, p1)) - return comp.CompareTo(p2); - else if (object.ReferenceEquals(obj, p2)) - return -comp.CompareTo(p1); - } - - throw new InternalErrorException("unexpected case"); - } - - - private DynValue MultiDispatchLessThanOrEqual(Script script, object obj) - { - IComparable comp = obj as IComparable; - if (comp != null) - { - return DynValue.NewCallback( - (context, args) => - DynValue.NewBoolean(PerformComparison(obj, args[0].ToObject(), args[1].ToObject()) <= 0)); - } - - return null; - } - - private DynValue MultiDispatchLessThan(Script script, object obj) - { - IComparable comp = obj as IComparable; - if (comp != null) - { - return DynValue.NewCallback( - (context, args) => - DynValue.NewBoolean(PerformComparison(obj, args[0].ToObject(), args[1].ToObject()) < 0)); - } - - return null; - } - - private DynValue TryDispatchLength(Script script, object obj) - { - if (obj == null) return null; - - var lenprop = m_Members.GetOrDefault("Length"); - if (lenprop != null && lenprop.CanRead() && !lenprop.CanExecute()) return lenprop.GetGetterCallbackAsDynValue(script, obj); - - var countprop = m_Members.GetOrDefault("Count"); - if (countprop != null && countprop.CanRead() && !countprop.CanExecute()) return countprop.GetGetterCallbackAsDynValue(script, obj); - - return null; - } - - - private DynValue MultiDispatchEqual(Script script, object obj) - { - return DynValue.NewCallback( - (context, args) => DynValue.NewBoolean(CheckEquality(obj, args[0].ToObject(), args[1].ToObject()))); - } - - - private bool CheckEquality(object obj, object p1, object p2) - { - if (obj != null) - { - if (object.ReferenceEquals(obj, p1)) - return obj.Equals(p2); - else if (object.ReferenceEquals(obj, p2)) - return obj.Equals(p1); - } - - if (p1 != null) return p1.Equals(p2); - else if (p2 != null) return p2.Equals(p1); - else return true; - } - - private DynValue DispatchMetaOnMethod(Script script, object obj, string methodName) - { - IMemberDescriptor desc = m_Members.GetOrDefault(methodName); - - if (desc != null) - { - return desc.GetValue(script, obj); - } - else - return null; - } - - - private DynValue TryDispatchToNumber(Script script, object obj) - { - foreach (Type t in NumericConversions.NumericTypesOrdered) - { - var name = t.GetConversionMethodName(); - var v = DispatchMetaOnMethod(script, obj, name); - if (v != null) return v; - } - return null; - } - - - private DynValue TryDispatchToBool(Script script, object obj) - { - var name = typeof(bool).GetConversionMethodName(); - var v = DispatchMetaOnMethod(script, obj, name); - if (v != null) return v; - return DispatchMetaOnMethod(script, obj, "op_True"); - } - - #endregion - - - /// - /// Determines whether the specified object is compatible with the specified type. - /// Unless a very specific behaviour is needed, the correct implementation is a - /// simple " return type.IsInstanceOfType(obj); " - /// - /// The type. - /// The object. - /// - public virtual bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IMemberDescriptor.cs deleted file mode 100644 index 02dacfc7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IMemberDescriptor.cs +++ /dev/null @@ -1,147 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Base interface to describe access to members of a given type. - /// While it's not infrastructural to implement custom type descriptors, it's needed for - /// classes extending . - /// - public interface IMemberDescriptor - { - /// - /// Gets a value indicating whether the described member is static. - /// - bool IsStatic { get; } - /// - /// Gets the name of the member - /// - string Name { get; } - /// - /// Gets the types of access supported by this member - /// - MemberDescriptorAccess MemberAccess { get; } - /// - /// Gets the value of this member as a to be exposed to scripts. - /// Implementors should raise exceptions if the value cannot be read or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object owning this member, or null if static. - /// The value of this member as a . - DynValue GetValue(Script script, object obj); - /// - /// Sets the value of this member from a . - /// Implementors should raise exceptions if the value cannot be read or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object owning this member, or null if static. - /// The value to be set. - void SetValue(Script script, object obj, DynValue value); - } - - - /// - /// Extension methods for and . - /// - public static class MemberDescriptor - { - /// - /// Determines whether the specified MemberDescriptorAccess has ALL the specified flags. - /// - /// The access. - /// The flag. - /// - public static bool HasAllFlags(this MemberDescriptorAccess access, MemberDescriptorAccess flag) - { - return (access & flag) == flag; - } - - /// - /// Determines whether this instance can be read - /// - /// The descriptor instance. - /// - public static bool CanRead(this IMemberDescriptor desc) - { - return desc.MemberAccess.HasAllFlags(MemberDescriptorAccess.CanRead); - } - - /// - /// Determines whether this instance can be written to - /// - /// The descriptor instance. - /// - public static bool CanWrite(this IMemberDescriptor desc) - { - return desc.MemberAccess.HasAllFlags(MemberDescriptorAccess.CanWrite); - } - - /// - /// Determines whether this instance can be executed (called as a function) - /// - /// The descriptor instance. - /// - public static bool CanExecute(this IMemberDescriptor desc) - { - return desc.MemberAccess.HasAllFlags(MemberDescriptorAccess.CanExecute); - } - - /// - /// Gets the getter of the member as a DynValue containing a callback - /// - /// The descriptor instance. - /// The script. - /// The object. - /// - public static DynValue GetGetterCallbackAsDynValue(this IMemberDescriptor desc, Script script, object obj) - { - return DynValue.NewCallback((p1, p2) => desc.GetValue(script, obj)); - } - - /// - /// Returns the specified descriptor if it supports all the specified access modes, otherwise returns null. - /// - /// The descriptor instance. - /// The access mode(s). - /// - public static IMemberDescriptor WithAccessOrNull(this IMemberDescriptor desc, MemberDescriptorAccess access) - { - if (desc == null) - return null; - - if (desc.MemberAccess.HasAllFlags(access)) - return desc; - - return null; - } - - /// - /// Raises an appropriate ScriptRuntimeException if the specified access is not supported. - /// Checks are made for the MemberDescriptorAccess permissions AND for the access of instance - /// members through static userdatas. - /// - /// The desc. - /// The access. - /// The object to be checked for access. - public static void CheckAccess(this IMemberDescriptor desc, MemberDescriptorAccess access, object obj) - { - if (!desc.IsStatic && obj == null) - throw ScriptRuntimeException.AccessInstanceMemberOnStatics(desc); - - if (access.HasAllFlags(MemberDescriptorAccess.CanExecute) && !desc.CanExecute()) - throw new ScriptRuntimeException("userdata member {0} cannot be called.", desc.Name); - - if (access.HasAllFlags(MemberDescriptorAccess.CanWrite) && !desc.CanWrite()) - throw new ScriptRuntimeException("userdata member {0} cannot be assigned to.", desc.Name); - - if (access.HasAllFlags(MemberDescriptorAccess.CanRead) && !desc.CanRead()) - throw new ScriptRuntimeException("userdata member {0} cannot be read from.", desc.Name); - } - - - - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOptimizableDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOptimizableDescriptor.cs deleted file mode 100644 index 15edb797..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOptimizableDescriptor.cs +++ /dev/null @@ -1,15 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Interface for descriptors of any kind which support optimizations of their implementation according to InteropAccessMode - /// modes. This should seldom - if ever - be implemented in user code. - /// - public interface IOptimizableDescriptor - { - /// - /// Called by standard descriptors when background optimization or preoptimization needs to be performed. - /// - void Optimize(); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOverloadableMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOverloadableMemberDescriptor.cs deleted file mode 100644 index bfd37043..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/IOverloadableMemberDescriptor.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Specialized for members supporting overloads resolution. - /// - public interface IOverloadableMemberDescriptor : IMemberDescriptor - { - /// - /// Invokes the member from script. - /// Implementors should raise exceptions if the value cannot be executed or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args); - - /// - /// Gets the type which this extension method extends, null if this is not an extension method. - /// - Type ExtensionMethodType { get; } - - /// - /// Gets the type of the arguments of the underlying CLR function - /// - ParameterDescriptor[] Parameters { get; } - - /// - /// Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - Type VarArgsArrayType { get; } - /// - /// Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - Type VarArgsElementType { get; } - - /// - /// Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - /// - string SortDiscriminant { get; } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/MemberDescriptorAccess.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/MemberDescriptorAccess.cs deleted file mode 100644 index adbeac67..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/MemberDescriptorAccess.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Permissions for members access - /// - [Flags] - public enum MemberDescriptorAccess - { - /// - /// The member can be read from - /// - CanRead = 1, - /// - /// The member can be written to - /// - CanWrite = 2, - /// - /// The can be invoked - /// - CanExecute = 4 - } - - - - - - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/ParameterDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/ParameterDescriptor.cs deleted file mode 100755 index 547fe66c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/BasicDescriptors/ParameterDescriptor.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Descriptor of parameters used in implementations. - /// - public sealed class ParameterDescriptor : IWireableDescriptor - { - /// - /// Gets the name of the parameter - /// - public string Name { get; private set; } - /// - /// Gets the type of the parameter - /// - public Type Type { get; private set; } - /// - /// Gets a value indicating whether this instance has a default value. - /// - public bool HasDefaultValue { get; private set; } - /// - /// Gets the default value - /// - public object DefaultValue { get; private set; } - /// - /// Gets a value indicating whether this instance is an out parameter - /// - public bool IsOut { get; private set; } - /// - /// Gets a value indicating whether this instance is a "ref" parameter - /// - public bool IsRef { get; private set; } - /// - /// Gets a value indicating whether this instance is a variable arguments param - /// - public bool IsVarArgs { get; private set; } - /// - /// Gets a value indicating whether this instance has been restricted. - /// - public bool HasBeenRestricted { get { return m_OriginalType != null; } } - /// - /// Gets the original type of the parameter before any restriction has been applied. - /// - public Type OriginalType { get { return m_OriginalType ?? Type; } } - - - /// - /// If the type got restricted, the original type before the restriction. - /// - private Type m_OriginalType = null; - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The type. - /// if set to true the parameter has default value. - /// The default value. - /// if set to true, is an out param. - /// if set to true is a ref param. - /// if set to true is variable arguments param. - public ParameterDescriptor(string name, Type type, bool hasDefaultValue = false, object defaultValue = null, bool isOut = false, - bool isRef = false, bool isVarArgs = false) - { - Name = name; - Type = type; - HasDefaultValue = hasDefaultValue; - DefaultValue = defaultValue; - IsOut = isOut; - IsRef = isRef; - IsVarArgs = isVarArgs; - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The type. - /// if set to true the parameter has default value. - /// The default value. - /// if set to true, is an out param. - /// if set to true is a ref param. - /// if set to true is variable arguments param. - /// The type restriction, or nll. - public ParameterDescriptor(string name, Type type, bool hasDefaultValue, object defaultValue, bool isOut, - bool isRef, bool isVarArgs, Type typeRestriction) - { - Name = name; - Type = type; - HasDefaultValue = hasDefaultValue; - DefaultValue = defaultValue; - IsOut = isOut; - IsRef = isRef; - IsVarArgs = isVarArgs; - - if (typeRestriction != null) - { - RestrictType(typeRestriction); - } - } - - - /// - /// Initializes a new instance of the class. - /// - /// A ParameterInfo taken from reflection. - public ParameterDescriptor(ParameterInfo pi) - { - Name = pi.Name; - Type = pi.ParameterType; - HasDefaultValue = !(Framework.Do.IsDbNull(pi.DefaultValue)); - DefaultValue = pi.DefaultValue; - IsOut = pi.IsOut; - IsRef = pi.ParameterType.IsByRef; - IsVarArgs = (pi.ParameterType.IsArray && pi.GetCustomAttributes(typeof(ParamArrayAttribute), true).Any()); - } - - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return string.Format("{0} {1}{2}", Type.Name, Name, HasDefaultValue ? " = ..." : ""); - } - - /// - /// Restricts the type of this parameter to a tighter constraint. - /// Restrictions must be applied before the containing this - /// parameter is used in any way. - /// - /// The new type. - /// - /// Cannot restrict a ref/out or varargs param - /// or - /// Specified operation is not a restriction - /// - public void RestrictType(Type type) - { - if (IsOut || IsRef || IsVarArgs) - throw new InvalidOperationException("Cannot restrict a ref/out or varargs param"); - - if (!Framework.Do.IsAssignableFrom(Type, type)) - throw new InvalidOperationException("Specified operation is not a restriction"); - - m_OriginalType = Type; - Type = type; - } - - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table table) - { - table.Set("name", DynValue.NewString(Name)); - - if (Type.IsByRef) - table.Set("type", DynValue.NewString(Type.GetElementType().FullName)); - else - table.Set("type", DynValue.NewString(Type.FullName)); - - if (OriginalType.IsByRef) - table.Set("origtype", DynValue.NewString(OriginalType.GetElementType().FullName)); - else - table.Set("origtype", DynValue.NewString(OriginalType.FullName)); - - table.Set("default", DynValue.NewBoolean(HasDefaultValue)); - table.Set("out", DynValue.NewBoolean(IsOut)); - table.Set("ref", DynValue.NewBoolean(IsRef)); - table.Set("varargs", DynValue.NewBoolean(IsVarArgs)); - table.Set("restricted", DynValue.NewBoolean(HasBeenRestricted)); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ClrToScriptConversions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ClrToScriptConversions.cs deleted file mode 100755 index 7576ffdb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ClrToScriptConversions.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Interop.RegistrationPolicies; - -namespace MoonSharp.Interpreter.Interop.Converters -{ - internal static class ClrToScriptConversions - { - /// - /// Tries to convert a CLR object to a MoonSharp value, using "trivial" logic. - /// Skips on custom conversions, etc. - /// Does NOT throw on failure. - /// - internal static DynValue TryObjectToTrivialDynValue(Script script, object obj) - { - if (obj == null) - return DynValue.Nil; - - if (obj is DynValue) - return (DynValue)obj; - - Type t = obj.GetType(); - - if (obj is bool) - return DynValue.NewBoolean((bool)obj); - - if (obj is string || obj is StringBuilder || obj is char) - return DynValue.NewString(obj.ToString()); - - if (NumericConversions.NumericTypes.Contains(t)) - return DynValue.NewNumber(NumericConversions.TypeToDouble(t, obj)); - - if (obj is Table) - return DynValue.NewTable((Table)obj); - - return null; - } - - - /// - /// Tries to convert a CLR object to a MoonSharp value, using "simple" logic. - /// Does NOT throw on failure. - /// - internal static DynValue TryObjectToSimpleDynValue(Script script, object obj) - { - if (obj == null) - return DynValue.Nil; - - if (obj is DynValue) - return (DynValue)obj; - - - var converter = Script.GlobalOptions.CustomConverters.GetClrToScriptCustomConversion(obj.GetType()); - if (converter != null) - { - var v = converter(script, obj); - if (v != null) - return v; - } - - Type t = obj.GetType(); - - if (obj is bool) - return DynValue.NewBoolean((bool)obj); - - if (obj is string || obj is StringBuilder || obj is char) - return DynValue.NewString(obj.ToString()); - - if (obj is Closure) - return DynValue.NewClosure((Closure)obj); - - if (NumericConversions.NumericTypes.Contains(t)) - return DynValue.NewNumber(NumericConversions.TypeToDouble(t, obj)); - - if (obj is Table) - return DynValue.NewTable((Table)obj); - - if (obj is CallbackFunction) - return DynValue.NewCallback((CallbackFunction)obj); - - if (obj is Delegate) - { - Delegate d = (Delegate)obj; - - -#if NETFX_CORE - MethodInfo mi = d.GetMethodInfo(); -#else - MethodInfo mi = d.Method; -#endif - - if (CallbackFunction.CheckCallbackSignature(mi, false)) - return DynValue.NewCallback((Func)d); - } - - return null; - } - - - /// - /// Tries to convert a CLR object to a MoonSharp value, using more in-depth analysis - /// - internal static DynValue ObjectToDynValue(Script script, object obj) - { - DynValue v = TryObjectToSimpleDynValue(script, obj); - - if (v != null) return v; - - v = UserData.Create(obj); - if (v != null) return v; - - if (obj is Type) - v = UserData.CreateStatic(obj as Type); - - // unregistered enums go as integers - if (obj is Enum) - return DynValue.NewNumber(NumericConversions.TypeToDouble(Enum.GetUnderlyingType(obj.GetType()), obj)); - - if (v != null) return v; - - if (obj is Delegate) - return DynValue.NewCallback(CallbackFunction.FromDelegate(script, (Delegate)obj)); - - if (obj is MethodInfo) - { - MethodInfo mi = (MethodInfo)obj; - - if (mi.IsStatic) - { - return DynValue.NewCallback(CallbackFunction.FromMethodInfo(script, mi)); - } - } - - if (obj is System.Collections.IList) - { - Table t = TableConversions.ConvertIListToTable(script, (System.Collections.IList)obj); - return DynValue.NewTable(t); - } - - if (obj is System.Collections.IDictionary) - { - Table t = TableConversions.ConvertIDictionaryToTable(script, (System.Collections.IDictionary)obj); - return DynValue.NewTable(t); - } - - var enumerator = EnumerationToDynValue(script, obj); - if (enumerator != null) return enumerator; - - - throw ScriptRuntimeException.ConvertObjectFailed(obj); - } - - /// - /// Converts an IEnumerable or IEnumerator to a DynValue - /// - /// The script. - /// The object. - /// - public static DynValue EnumerationToDynValue(Script script, object obj) - { - if (obj is System.Collections.IEnumerable) - { - var enumer = (System.Collections.IEnumerable)obj; - return EnumerableWrapper.ConvertIterator(script, enumer.GetEnumerator()); - } - - if (obj is System.Collections.IEnumerator) - { - var enumer = (System.Collections.IEnumerator)obj; - return EnumerableWrapper.ConvertIterator(script, enumer); - } - - return null; - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/NumericConversions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/NumericConversions.cs deleted file mode 100644 index e022c486..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/NumericConversions.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Interop.Converters -{ - /// - /// Static functions to handle conversions of numeric types - /// - internal static class NumericConversions - { - static NumericConversions() - { - NumericTypesOrdered = new Type[] - { - typeof(double), - typeof(decimal), - typeof(float), - typeof(long), - typeof(int), - typeof(short), - typeof(sbyte), - typeof(ulong), - typeof(uint), - typeof(ushort), - typeof(byte), - }; - NumericTypes = new HashSet(NumericTypesOrdered); - } - - /// - /// HashSet of numeric types - /// - internal static readonly HashSet NumericTypes; - /// - /// Array of numeric types in order used for some conversions - /// - internal static readonly Type[] NumericTypesOrdered; - - /// - /// Converts a double to another type - /// - internal static object DoubleToType(Type type, double d) - { - type = Nullable.GetUnderlyingType(type) ?? type; - - if (type == typeof(double)) return d; - if (type == typeof(sbyte)) return (sbyte)d; - if (type == typeof(byte)) return (byte)d; - if (type == typeof(short)) return (short)d; - if (type == typeof(ushort)) return (ushort)d; - if (type == typeof(int)) return (int)d; - if (type == typeof(uint)) return (uint)d; - if (type == typeof(long)) return (long)d; - if (type == typeof(ulong)) return (ulong)d; - if (type == typeof(float)) return (float)d; - if (type == typeof(decimal)) return (decimal)d; - return d; - } - - /// - /// Converts a type to double - /// - internal static double TypeToDouble(Type type, object d) - { - if (type == typeof(double)) return (double)d; - if (type == typeof(sbyte)) return (double)(sbyte)d; - if (type == typeof(byte)) return (double)(byte)d; - if (type == typeof(short)) return (double)(short)d; - if (type == typeof(ushort)) return (double)(ushort)d; - if (type == typeof(int)) return (double)(int)d; - if (type == typeof(uint)) return (double)(uint)d; - if (type == typeof(long)) return (double)(long)d; - if (type == typeof(ulong)) return (double)(ulong)d; - if (type == typeof(float)) return (double)(float)d; - if (type == typeof(decimal)) return (double)(decimal)d; - return (double)d; - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ScriptToClrConversions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ScriptToClrConversions.cs deleted file mode 100755 index d12f80e4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/ScriptToClrConversions.cs +++ /dev/null @@ -1,316 +0,0 @@ -using System; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop.Converters -{ - internal static class ScriptToClrConversions - { - internal const int WEIGHT_MAX_VALUE = 100; - internal const int WEIGHT_CUSTOM_CONVERTER_MATCH = 100; - internal const int WEIGHT_EXACT_MATCH = 100; - internal const int WEIGHT_STRING_TO_STRINGBUILDER = 99; - internal const int WEIGHT_STRING_TO_CHAR = 98; - internal const int WEIGHT_NIL_TO_NULLABLE = 100; - internal const int WEIGHT_NIL_TO_REFTYPE = 100; - internal const int WEIGHT_VOID_WITH_DEFAULT = 50; - internal const int WEIGHT_VOID_WITHOUT_DEFAULT = 25; - internal const int WEIGHT_NIL_WITH_DEFAULT = 25; - internal const int WEIGHT_BOOL_TO_STRING = 5; - internal const int WEIGHT_NUMBER_TO_STRING = 50; - internal const int WEIGHT_NUMBER_TO_ENUM = 90; - internal const int WEIGHT_USERDATA_TO_STRING = 5; - internal const int WEIGHT_TABLE_CONVERSION = 90; - internal const int WEIGHT_NUMBER_DOWNCAST = 99; - internal const int WEIGHT_NO_MATCH = 0; - internal const int WEIGHT_NO_EXTRA_PARAMS_BONUS = 100; - internal const int WEIGHT_EXTRA_PARAMS_MALUS = 2; - internal const int WEIGHT_BYREF_BONUSMALUS = -10; - internal const int WEIGHT_VARARGS_MALUS = 1; - internal const int WEIGHT_VARARGS_EMPTY = 40; - - /// - /// Converts a DynValue to a CLR object [simple conversion] - /// - internal static object DynValueToObject(DynValue value) - { - var converter = Script.GlobalOptions.CustomConverters.GetScriptToClrCustomConversion(value.Type, typeof(System.Object)); - if (converter != null) - { - var v = converter(value); - if (v != null) - return v; - } - - switch (value.Type) - { - case DataType.Void: - case DataType.Nil: - return null; - case DataType.Boolean: - return value.Boolean; - case DataType.Number: - return value.Number; - case DataType.String: - return value.String; - case DataType.Function: - return value.Function; - case DataType.Table: - return value.Table; - case DataType.Tuple: - return value.Tuple; - case DataType.UserData: - if (value.UserData.Object != null) - return value.UserData.Object; - else if (value.UserData.Descriptor != null) - return value.UserData.Descriptor.Type; - else - return null; - case DataType.ClrFunction: - return value.Callback; - default: - throw ScriptRuntimeException.ConvertObjectFailed(value.Type); - } - } - - - /// - /// Converts a DynValue to a CLR object of a specific type - /// - internal static object DynValueToObjectOfType(DynValue value, Type desiredType, object defaultValue, bool isOptional) - { - if (desiredType.IsByRef) - desiredType = desiredType.GetElementType(); - - var converter = Script.GlobalOptions.CustomConverters.GetScriptToClrCustomConversion(value.Type, desiredType); - if (converter != null) - { - var v = converter(value); - if (v != null) return v; - } - - if (desiredType == typeof(DynValue)) - return value; - - if (desiredType == typeof(object)) - return DynValueToObject(value); - - StringConversions.StringSubtype stringSubType = StringConversions.GetStringSubtype(desiredType); - string str = null; - - Type nt = Nullable.GetUnderlyingType(desiredType); - Type nullableType = null; - - if (nt != null) - { - nullableType = desiredType; - desiredType = nt; - } - - switch (value.Type) - { - case DataType.Void: - if (isOptional) - return defaultValue; - else if ((!Framework.Do.IsValueType(desiredType)) || (nullableType != null)) - return null; - break; - case DataType.Nil: - if (Framework.Do.IsValueType(desiredType)) - { - if (nullableType != null) - return null; - - if (isOptional) - return defaultValue; - } - else - { - return null; - } - break; - case DataType.Boolean: - if (desiredType == typeof(bool)) - return value.Boolean; - if (stringSubType != StringConversions.StringSubtype.None) - str = value.Boolean.ToString(); - break; - case DataType.Number: - if (Framework.Do.IsEnum(desiredType)) - { // number to enum conv - Type underType = Enum.GetUnderlyingType(desiredType); - return NumericConversions.DoubleToType(underType, value.Number); - } - if (NumericConversions.NumericTypes.Contains(desiredType)) - return NumericConversions.DoubleToType(desiredType, value.Number); - if (stringSubType != StringConversions.StringSubtype.None) - str = value.Number.ToString(); - break; - case DataType.String: - if (stringSubType != StringConversions.StringSubtype.None) - str = value.String; - break; - case DataType.Function: - if (desiredType == typeof(Closure)) return value.Function; - else if (desiredType == typeof(ScriptFunctionDelegate)) return value.Function.GetDelegate(); - break; - case DataType.ClrFunction: - if (desiredType == typeof(CallbackFunction)) return value.Callback; - else if (desiredType == typeof(Func)) return value.Callback.ClrCallback; - break; - case DataType.UserData: - if (value.UserData.Object != null) - { - var udObj = value.UserData.Object; - var udDesc = value.UserData.Descriptor; - - if (udDesc.IsTypeCompatible(desiredType, udObj)) - return udObj; - - if (stringSubType != StringConversions.StringSubtype.None) - str = udDesc.AsString(udObj); - } - break; - case DataType.Table: - if (desiredType == typeof(Table) || Framework.Do.IsAssignableFrom(desiredType, typeof(Table))) - return value.Table; - else - { - object o = TableConversions.ConvertTableToType(value.Table, desiredType); - if (o != null) - return o; - } - break; - case DataType.Tuple: - break; - } - - if (stringSubType != StringConversions.StringSubtype.None && str != null) - return StringConversions.ConvertString(stringSubType, str, desiredType, value.Type); - - throw ScriptRuntimeException.ConvertObjectFailed(value.Type, desiredType); - } - - /// - /// Gets a relative weight of how much the conversion is matching the given types. - /// Implementation must follow that of DynValueToObjectOfType.. it's not very DRY in that sense. - /// However here we are in perf-sensitive path.. TODO : double-check the gain and see if a DRY impl is better. - /// - internal static int DynValueToObjectOfTypeWeight(DynValue value, Type desiredType, bool isOptional) - { - if (desiredType.IsByRef) - desiredType = desiredType.GetElementType(); - - var customConverter = Script.GlobalOptions.CustomConverters.GetScriptToClrCustomConversion(value.Type, desiredType); - if (customConverter != null) - return WEIGHT_CUSTOM_CONVERTER_MATCH; - - if (desiredType == typeof(DynValue)) - return WEIGHT_EXACT_MATCH; - - if (desiredType == typeof(object)) - return WEIGHT_EXACT_MATCH; - - StringConversions.StringSubtype stringSubType = StringConversions.GetStringSubtype(desiredType); - - Type nt = Nullable.GetUnderlyingType(desiredType); - Type nullableType = null; - - if (nt != null) - { - nullableType = desiredType; - desiredType = nt; - } - - switch (value.Type) - { - case DataType.Void: - if (isOptional) - return WEIGHT_VOID_WITH_DEFAULT; - else if ((!Framework.Do.IsValueType(desiredType)) || (nullableType != null)) - return WEIGHT_VOID_WITHOUT_DEFAULT; - break; - case DataType.Nil: - if (Framework.Do.IsValueType(desiredType)) - { - if (nullableType != null) - return WEIGHT_NIL_TO_NULLABLE; - - if (isOptional) - return WEIGHT_NIL_WITH_DEFAULT; - } - else - { - return WEIGHT_NIL_TO_REFTYPE; - } - break; - case DataType.Boolean: - if (desiredType == typeof(bool)) - return WEIGHT_EXACT_MATCH; - if (stringSubType != StringConversions.StringSubtype.None) - return WEIGHT_BOOL_TO_STRING; - break; - case DataType.Number: - if (Framework.Do.IsEnum(desiredType)) - { // number to enum conv - return WEIGHT_NUMBER_TO_ENUM; - } - if (NumericConversions.NumericTypes.Contains(desiredType)) - return GetNumericTypeWeight(desiredType); - if (stringSubType != StringConversions.StringSubtype.None) - return WEIGHT_NUMBER_TO_STRING; - break; - case DataType.String: - if (stringSubType == StringConversions.StringSubtype.String) - return WEIGHT_EXACT_MATCH; - else if (stringSubType == StringConversions.StringSubtype.StringBuilder) - return WEIGHT_STRING_TO_STRINGBUILDER; - else if (stringSubType == StringConversions.StringSubtype.Char) - return WEIGHT_STRING_TO_CHAR; - break; - case DataType.Function: - if (desiredType == typeof(Closure)) return WEIGHT_EXACT_MATCH; - else if (desiredType == typeof(ScriptFunctionDelegate)) return WEIGHT_EXACT_MATCH; - break; - case DataType.ClrFunction: - if (desiredType == typeof(CallbackFunction)) return WEIGHT_EXACT_MATCH; - else if (desiredType == typeof(Func)) return WEIGHT_EXACT_MATCH; - break; - case DataType.UserData: - if (value.UserData.Object != null) - { - var udObj = value.UserData.Object; - var udDesc = value.UserData.Descriptor; - - if (udDesc.IsTypeCompatible(desiredType, udObj)) - return WEIGHT_EXACT_MATCH; - - if (stringSubType != StringConversions.StringSubtype.None) - return WEIGHT_USERDATA_TO_STRING; - } - break; - case DataType.Table: - if (desiredType == typeof(Table) || Framework.Do.IsAssignableFrom(desiredType, typeof(Table))) - return WEIGHT_EXACT_MATCH; - else if (TableConversions.CanConvertTableToType(value.Table, desiredType)) - return WEIGHT_TABLE_CONVERSION; - break; - case DataType.Tuple: - break; - } - - return WEIGHT_NO_MATCH; - } - - private static int GetNumericTypeWeight(Type desiredType) - { - if (desiredType == typeof(double) || desiredType == typeof(decimal)) - return WEIGHT_EXACT_MATCH; - else - return WEIGHT_NUMBER_DOWNCAST; - } - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/StringConversions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/StringConversions.cs deleted file mode 100644 index f49708a5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/StringConversions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Text; - -namespace MoonSharp.Interpreter.Interop.Converters -{ - internal static class StringConversions - { - internal enum StringSubtype - { - None, - String, - StringBuilder, - Char - } - - internal static StringSubtype GetStringSubtype(Type desiredType) - { - if (desiredType == typeof(string)) - return StringSubtype.String; - else if (desiredType == typeof(StringBuilder)) - return StringSubtype.StringBuilder; - else if (desiredType == typeof(char)) - return StringSubtype.Char; - else - return StringSubtype.None; - } - - - internal static object ConvertString(StringSubtype stringSubType, string str, Type desiredType, DataType dataType) - { - switch (stringSubType) - { - case StringSubtype.String: - return str; - case StringSubtype.StringBuilder: - return new StringBuilder(str); - case StringSubtype.Char: - if (!string.IsNullOrEmpty(str)) - return str[0]; - break; - case StringSubtype.None: - default: - break; - } - - throw ScriptRuntimeException.ConvertObjectFailed(dataType, desiredType); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/TableConversions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/TableConversions.cs deleted file mode 100644 index 0f744f45..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/Converters/TableConversions.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop.Converters -{ - internal static class TableConversions - { - /// - /// Converts an IList to a Lua table. - /// - internal static Table ConvertIListToTable(Script script, System.Collections.IList list) - { - Table t = new Table(script); - for (int i = 0; i < list.Count; i++) - { - t[i + 1] = ClrToScriptConversions.ObjectToDynValue(script, list[i]); - } - return t; - } - - /// - /// Converts an IDictionary to a Lua table. - /// - internal static Table ConvertIDictionaryToTable(Script script, System.Collections.IDictionary dict) - { - Table t = new Table(script); - - foreach (System.Collections.DictionaryEntry kvp in dict) - { - DynValue key = ClrToScriptConversions.ObjectToDynValue(script, kvp.Key); - DynValue val = ClrToScriptConversions.ObjectToDynValue(script, kvp.Value); - t.Set(key, val); - } - - return t; - } - - /// - /// Determines whether the specified table can be converted to the specified type - /// - /// The table. - /// The type. - /// - internal static bool CanConvertTableToType(Table table, Type t) - { - if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) - return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) - return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) - return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) - return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(object[]))) - return true; - else if (Framework.Do.IsAssignableFrom(t, typeof(DynValue[]))) - return true; - - if (Framework.Do.IsGenericType(t)) - { - Type generic = t.GetGenericTypeDefinition(); - - if ((generic == typeof(List<>)) - || (generic == typeof(IList<>)) - || (generic == typeof(ICollection<>)) - || (generic == typeof(IEnumerable<>))) - { - return true; - } - else if ((generic == typeof(Dictionary<,>)) - || (generic == typeof(IDictionary<,>))) - { - return true; - } - } - - if (t.IsArray && t.GetArrayRank() == 1) - return true; - - return false; - } - - - - /// - /// Converts a table to a CLR object of a given type - /// - internal static object ConvertTableToType(Table table, Type t) - { - if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) - return TableToDictionary(table, v => v.ToObject(), v => v.ToObject()); - else if (Framework.Do.IsAssignableFrom(t, typeof(Dictionary))) - return TableToDictionary(table, v => v, v => v); - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) - return TableToList(table, v => v.ToObject()); - else if (Framework.Do.IsAssignableFrom(t, typeof(List))) - return TableToList(table, v => v); - else if (Framework.Do.IsAssignableFrom(t, typeof(object[]))) - return TableToList(table, v => v.ToObject()).ToArray(); - else if (Framework.Do.IsAssignableFrom(t, typeof(DynValue[]))) - return TableToList(table, v => v).ToArray(); - - if (Framework.Do.IsGenericType(t)) - { - Type generic = t.GetGenericTypeDefinition(); - - if ((generic == typeof(List<>)) - || (generic == typeof(IList<>)) - || (generic == typeof(ICollection<>)) - || (generic == typeof(IEnumerable<>))) - { - return ConvertTableToListOfGenericType(t, Framework.Do.GetGenericArguments(t)[0], table); - } - else if ((generic == typeof(Dictionary<,>)) - || (generic == typeof(IDictionary<,>))) - { - return ConvertTableToDictionaryOfGenericType(t, Framework.Do.GetGenericArguments(t)[0], Framework.Do.GetGenericArguments(t)[1], table); - } - } - - if (t.IsArray && t.GetArrayRank() == 1) - return ConvertTableToArrayOfGenericType(t, t.GetElementType(), table); - - return null; - } - - - /// - /// Converts a table to a - /// - internal static object ConvertTableToDictionaryOfGenericType(Type dictionaryType, Type keyType, Type valueType, Table table) - { - if (dictionaryType.GetGenericTypeDefinition() != typeof(Dictionary<,>)) - { - dictionaryType = typeof(Dictionary<,>); - dictionaryType = dictionaryType.MakeGenericType(keyType, valueType); - } - - System.Collections.IDictionary dic = (System.Collections.IDictionary)Activator.CreateInstance(dictionaryType); - - foreach (var kvp in table.Pairs) - { - object key = ScriptToClrConversions.DynValueToObjectOfType(kvp.Key, keyType, null, false); - object val = ScriptToClrConversions.DynValueToObjectOfType(kvp.Value, valueType, null, false); - - dic.Add(key, val); - } - - return dic; - } - - /// - /// Converts a table to a T[] - /// - internal static object ConvertTableToArrayOfGenericType(Type arrayType, Type itemType, Table table) - { - List lst = new List(); - - for (int i = 1, l = table.Length; i <= l; i++) - { - DynValue v = table.Get(i); - object o = ScriptToClrConversions.DynValueToObjectOfType(v, itemType, null, false); - lst.Add(o); - } - - System.Collections.IList array = (System.Collections.IList)Activator.CreateInstance(arrayType, new object[] { lst.Count }); - - for (int i = 0; i < lst.Count; i++) - array[i] = lst[i]; - - return array; - } - - - /// - /// Converts a table to a - /// - internal static object ConvertTableToListOfGenericType(Type listType, Type itemType, Table table) - { - if (listType.GetGenericTypeDefinition() != typeof(List<>)) - { - listType = typeof(List<>); - listType = listType.MakeGenericType(itemType); - } - - System.Collections.IList lst = (System.Collections.IList)Activator.CreateInstance(listType); - - for (int i = 1, l = table.Length; i <= l; i++) - { - DynValue v = table.Get(i); - object o = ScriptToClrConversions.DynValueToObjectOfType(v, itemType, null, false); - lst.Add(o); - } - - return lst; - } - - /// - /// Converts a table to a , known in advance - /// - internal static List TableToList(Table table, Func converter) - { - List lst = new List(); - - for (int i = 1, l = table.Length; i <= l; i++) - { - DynValue v = table.Get(i); - T o = converter(v); - lst.Add(o); - } - - return lst; - } - - /// - /// Converts a table to a Dictionary, known in advance - /// - internal static Dictionary TableToDictionary(Table table, Func keyconverter, Func valconverter) - { - Dictionary dict = new Dictionary(); - - foreach (var kvp in table.Pairs) - { - TK key = keyconverter(kvp.Key); - TV val = valconverter(kvp.Value); - - dict.Add(key, val); - } - - return dict; - } - - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/CustomConvertersCollection.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/CustomConvertersCollection.cs deleted file mode 100644 index 70866ceb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/CustomConvertersCollection.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// A collection of custom converters between MoonSharp types and CLR types. - /// If a converter function is not specified or returns null, the standard conversion path applies. - /// - public class CustomConvertersCollection - { - private Dictionary>[] m_Script2Clr = new Dictionary>[(int)LuaTypeExtensions.MaxConvertibleTypes + 1]; - private Dictionary> m_Clr2Script = new Dictionary>(); - - - - internal CustomConvertersCollection() - { - for (int i = 0; i < m_Script2Clr.Length; i++) - m_Script2Clr[i] = new Dictionary>(); - } - - // This needs to be evaluated further (doesn't work well with inheritance) - // - // private Dictionary>> m_Script2ClrUserData = new Dictionary>>(); - // - //public void SetScriptToClrUserDataSpecificCustomConversion(Type destType, Type userDataType, Func converter = null) - //{ - // var destTypeMap = m_Script2ClrUserData.GetOrCreate(destType, () => new Dictionary>()); - // destTypeMap[userDataType] = converter; - - // SetScriptToClrCustomConversion(DataType.UserData, destType, v => DispatchUserDataCustomConverter(destTypeMap, v)); - //} - - //private object DispatchUserDataCustomConverter(Dictionary> destTypeMap, DynValue v) - //{ - // if (v.Type != DataType.UserData) - // return null; - - // if (v.UserData.Object == null) - // return null; - - // Func converter; - - // for (Type userDataType = v.UserData.Object.GetType(); - // userDataType != typeof(object); - // userDataType = userDataType.BaseType) - // { - // if (destTypeMap.TryGetValue(userDataType, out converter)) - // { - // return converter(v.UserData.Object); - // } - // } - - // return null; - //} - - //public Func GetScriptToClrUserDataSpecificCustomConversion(Type destType, Type userDataType) - //{ - // Dictionary> destTypeMap; - - // if (m_Script2ClrUserData.TryGetValue(destType, out destTypeMap)) - // { - // Func converter; - - // if (destTypeMap.TryGetValue(userDataType, out converter)) - // { - // return converter; - // } - // } - - // return null; - //} - - - - /// - /// Sets a custom converter from a script data type to a CLR data type. Set null to remove a previous custom converter. - /// - /// The script data type - /// The CLR data type. - /// The converter, or null. - public void SetScriptToClrCustomConversion(DataType scriptDataType, Type clrDataType, Func converter = null) - { - if ((int)scriptDataType > m_Script2Clr.Length) - throw new ArgumentException("scriptDataType"); - - Dictionary> map = m_Script2Clr[(int)scriptDataType]; - - if (converter == null) - { - if (map.ContainsKey(clrDataType)) - map.Remove(clrDataType); - } - else - { - map[clrDataType] = converter; - } - } - - /// - /// Gets a custom converter from a script data type to a CLR data type, or null - /// - /// The script data type - /// The CLR data type. - /// The converter function, or null if not found - public Func GetScriptToClrCustomConversion(DataType scriptDataType, Type clrDataType) - { - if ((int)scriptDataType > m_Script2Clr.Length) - return null; - - Dictionary> map = m_Script2Clr[(int)scriptDataType]; - return map.GetOrDefault(clrDataType); - } - - /// - /// Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - /// - /// The CLR data type. - /// The converter, or null. - public void SetClrToScriptCustomConversion(Type clrDataType, Func converter = null) - { - if (converter == null) - { - if (m_Clr2Script.ContainsKey(clrDataType)) - m_Clr2Script.Remove(clrDataType); - } - else - { - m_Clr2Script[clrDataType] = converter; - } - } - - /// - /// Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - /// - /// The CLR data type. - /// The converter, or null. - public void SetClrToScriptCustomConversion(Func converter = null) - { - SetClrToScriptCustomConversion(typeof(T), (s, o) => converter(s, (T)o)); - } - - - /// - /// Gets a custom converter from a CLR data type, or null - /// - /// Type of the color data. - /// The converter function, or null if not found - public Func GetClrToScriptCustomConversion(Type clrDataType) - { - return m_Clr2Script.GetOrDefault(clrDataType); - } - - /// Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - /// - /// The CLR data type. - /// The converter, or null. - [Obsolete("This method is deprecated. Use the overloads accepting functions with a Script argument.")] - public void SetClrToScriptCustomConversion(Type clrDataType, Func converter = null) - { - SetClrToScriptCustomConversion(clrDataType, (s, o) => converter(o)); - } - - /// - /// Sets a custom converter from a CLR data type. Set null to remove a previous custom converter. - /// - /// The CLR data type. - /// The converter, or null. - [Obsolete("This method is deprecated. Use the overloads accepting functions with a Script argument.")] - public void SetClrToScriptCustomConversion(Func converter = null) - { - SetClrToScriptCustomConversion(typeof(T), o => converter((T)o)); - } - - - /// - /// Removes all converters. - /// - public void Clear() - { - m_Clr2Script.Clear(); - - for (int i = 0; i < m_Script2Clr.Length; i++) - m_Script2Clr[i].Clear(); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/DescriptorHelpers.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/DescriptorHelpers.cs deleted file mode 100755 index 9bf7c402..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/DescriptorHelpers.cs +++ /dev/null @@ -1,298 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Helper extension methods used to simplify some parts of userdata descriptor implementations - /// - public static class DescriptorHelpers - { - /// - /// Determines whether a - /// or a is changing visibility of a member - /// to scripts. - /// - /// The member to check. - /// - /// true if visibility is forced visible, - /// false if visibility is forced hidden or the specified MemberInfo is null, - /// if no attribute was found - /// - /// If both MoonSharpHiddenAttribute and MoonSharpVisibleAttribute are specified and they convey different messages. - public static bool? GetVisibilityFromAttributes(this MemberInfo mi) - { - if (mi == null) - return false; - - MoonSharpVisibleAttribute va = mi.GetCustomAttributes(true).OfType().SingleOrDefault(); - MoonSharpHiddenAttribute ha = mi.GetCustomAttributes(true).OfType().SingleOrDefault(); - - if (va != null && ha != null && va.Visible) - throw new InvalidOperationException(string.Format("A member ('{0}') can't have discording MoonSharpHiddenAttribute and MoonSharpVisibleAttribute.", mi.Name)); - else if (ha != null) - return false; - else if (va != null) - return va.Visible; - else - return null; - } - - public static bool IsDelegateType(this Type t) - { - return Framework.Do.IsAssignableFrom(typeof(Delegate), t); - } - - /// - /// Gets the visibility of the type as a string - /// - public static string GetClrVisibility(this Type type) - { -#if NETFX_CORE - var t = type.GetTypeInfo(); -#else - Type t = type; -#endif - if (t.IsPublic || t.IsNestedPublic) - return "public"; - if ((t.IsNotPublic && (!t.IsNested)) || (t.IsNestedAssembly)) - return "internal"; - if (t.IsNestedFamORAssem) - return "protected-internal"; - if (t.IsNestedFamANDAssem || t.IsNestedFamily) - return "protected"; - if (t.IsNestedPrivate) - return "private"; - return "unknown"; - } - - /// - /// Gets a string representing visibility of the given member type - /// - public static string GetClrVisibility(this FieldInfo info) - { - if (info.IsPublic) - return "public"; - if (info.IsAssembly) - return "internal"; - if (info.IsFamilyOrAssembly) - return "protected-internal"; - if (info.IsFamilyAndAssembly || info.IsFamily) - return "protected"; - if (info.IsPrivate) - return "private"; - - return "unknown"; - } - - /// - /// Gets a string representing visibility of the given member type - /// - public static string GetClrVisibility(this PropertyInfo info) - { - MethodInfo gm = Framework.Do.GetGetMethod(info); - MethodInfo sm = Framework.Do.GetSetMethod(info); - - string gv = (gm != null) ? GetClrVisibility(gm) : "private"; - string sv = (sm != null) ? GetClrVisibility(sm) : "private"; - - if (gv == "public" || sv == "public") - return "public"; - else if (gv == "internal" || sv == "internal") - return "internal"; - else - return gv; - } - - /// - /// Gets a string representing visibility of the given member type - /// - public static string GetClrVisibility(this MethodBase info) - { - if (info.IsPublic) - return "public"; - if (info.IsAssembly) - return "internal"; - if (info.IsFamilyOrAssembly) - return "protected-internal"; - if (info.IsFamilyAndAssembly || info.IsFamily) - return "protected"; - if (info.IsPrivate) - return "private"; - - return "unknown"; - } - - - - - /// - /// Determines whether the specified PropertyInfo is visible publicly (either the getter or the setter is public). - /// - /// The PropertyInfo. - /// - public static bool IsPropertyInfoPublic(this PropertyInfo pi) - { - MethodInfo getter = Framework.Do.GetGetMethod(pi); - MethodInfo setter = Framework.Do.GetSetMethod(pi); - - return (getter != null && getter.IsPublic) || (setter != null && setter.IsPublic); - } - - /// - /// Gets the list of metamethod names from attributes - in practice the list of metamethods declared through - /// . - /// - /// The mi. - /// - public static List GetMetaNamesFromAttributes(this MethodInfo mi) - { - return mi.GetCustomAttributes(typeof(MoonSharpUserDataMetamethodAttribute), true) - .OfType() - .Select(a => a.Name) - .ToList(); - } - - /// - /// Gets the Types implemented in the assembly, catching the ReflectionTypeLoadException just in case.. - /// - /// The assebly - /// - public static Type[] SafeGetTypes(this Assembly asm) - { - try - { - return Framework.Do.GetAssemblyTypes(asm); - } - catch (ReflectionTypeLoadException) - { - return new Type[0]; - } - } - - - - - /// - /// Gets the name of a conversion method to be exposed to Lua scripts - /// - /// The type. - /// - public static string GetConversionMethodName(this Type type) - { - StringBuilder sb = new StringBuilder(type.Name); - - for (int i = 0; i < sb.Length; i++) - if (!char.IsLetterOrDigit(sb[i])) sb[i] = '_'; - - return "__to" + sb.ToString(); - } - - - /// - /// Gets all implemented types by a given type - /// - /// The t. - /// - public static IEnumerable GetAllImplementedTypes(this Type t) - { - for (Type ot = t; ot != null; ot = Framework.Do.GetBaseType(ot)) - yield return ot; - - foreach (Type it in Framework.Do.GetInterfaces(t)) - yield return it; - } - - - /// - /// Determines whether the string is a valid simple identifier (starts with letter or underscore - /// and contains only letters, digits and underscores). - /// - public static bool IsValidSimpleIdentifier(string str) - { - if (string.IsNullOrEmpty(str)) - return false; - - if (str[0] != '_' && !char.IsLetter(str[0])) - return false; - - for (int i = 1; i < str.Length; i++) - if (str[i] != '_' && !char.IsLetterOrDigit(str[i])) - return false; - - return true; - } - - /// - /// Converts the string to a valid simple identifier (starts with letter or underscore - /// and contains only letters, digits and underscores). - /// - public static string ToValidSimpleIdentifier(string str) - { - if (string.IsNullOrEmpty(str)) - return "_"; - - if (str[0] != '_' && !char.IsLetter(str[0])) - str = "_" + str; - - StringBuilder sb = new StringBuilder(str); - - for (int i = 0; i < sb.Length; i++) - if (sb[i] != '_' && !char.IsLetterOrDigit(sb[i])) - sb[i] = '_'; - - return sb.ToString(); - } - - /// - /// Converts the specified name from underscore_case to camelCase. - /// - /// The name. - /// - public static string Camelify(string name) - { - StringBuilder sb = new StringBuilder(name.Length); - - bool lastWasUnderscore = false; - for (int i = 0; i < name.Length; i++) - { - if (name[i] == '_' && i != 0) - { - lastWasUnderscore = true; - } - else - { - if (lastWasUnderscore) - sb.Append(char.ToUpperInvariant(name[i])); - else - sb.Append(name[i]); - - lastWasUnderscore = false; - } - } - - return sb.ToString(); - } - - /// - /// Converts the specified name to one with an uppercase first letter (something to Something). - /// - /// The name. - /// - public static string UpperFirstLetter(string name) - { - if (!string.IsNullOrEmpty(name)) - return char.ToUpperInvariant(name[0]) + name.Substring(1); - - return name; - } - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IGeneratorUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IGeneratorUserDataDescriptor.cs deleted file mode 100644 index 637766a4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IGeneratorUserDataDescriptor.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// An interface for type descriptors having the ability to generate other descriptors on the fly. - /// - public interface IGeneratorUserDataDescriptor : IUserDataDescriptor - { - /// - /// - /// Generates a new descriptor for the specified type. - /// - /// The purpose is to allow a mechanism by which a type descriptor can replace itself with another - /// descriptor for a specific type. For example, descriptors can be created on the fly to support - /// generic types through this mechanism. - /// - /// The return value should be: - /// null - if this descriptor is simply skipped for the specified type - /// this - acts as if the descriptor was a vanilla descriptor - /// a new descriptor - if a new descriptor should be used in place of this one - /// - /// It's recommended that instances of descriptors are cached for future references. One possible way, - /// to do the caching is to have the generator register the descriptor through . - /// In that case, it should query whether the type is exactly registered, through - /// - /// NOTE-1 : the search for descriptors does NOT stop with the descriptor returned by this type, but - /// other descriptors (e.g. for interfaces) might still be added. - /// - /// NOTE-2 : the descriptor generation mechanism is not triggered on an exact match of types. - /// - /// NOTE-3 : the method is called in the context of a lock over the descriptors registry so no unpredictable changes to the - /// registry can come from other threads during the execution of this method. However this method should not take other - /// locks, to avoid deadlocks. - /// - /// - /// The type. - /// Null, this object instance or a new descriptor. - IUserDataDescriptor Generate(Type type); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataDescriptor.cs deleted file mode 100644 index b93c8092..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataDescriptor.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Interface used by MoonSharp to access objects of a given type from scripts. - /// - public interface IUserDataDescriptor - { - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - string Name { get; } - /// - /// Gets the type this descriptor refers to - /// - Type Type { get; } - /// - /// Performs an "index" "get" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing); - /// - /// Performs an "index" "set" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing); - /// - /// Converts this userdata to string - /// - /// The object. - /// - string AsString(object obj); - /// - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// - /// These standard metamethods can be supported (the return value should be a function accepting the - /// classic parameters of the corresponding metamethod): - /// __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - /// __pairs, __ipairs, __iterator, __call - /// - /// These standard metamethods are supported through other calls for efficiency: - /// __index, __newindex, __tostring - /// - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The name of the metamember. - /// - DynValue MetaIndex(Script script, object obj, string metaname); - /// - /// Determines whether the specified object is compatible with the specified type. - /// Unless a very specific behaviour is needed, the correct implementation is a - /// simple " return type.IsInstanceOfType(obj); " - /// - /// The type. - /// The object. - /// - bool IsTypeCompatible(Type type, object obj); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataMemberDescriptor.cs deleted file mode 100644 index 23f83de1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataMemberDescriptor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Interface used by standard descriptors to access members of a given type from scripts. - /// - public interface IUserDataMemberDescriptor - { - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - string Name { get; } - /// - /// Gets the type this descriptor refers to - /// - Type Type { get; } - /// - /// Gets the value of the member - /// - /// The script. - /// The object. - /// - DynValue GetValue(Script script, object obj); - /// - /// Sets the value of the member - /// - /// The script. - /// The object. - /// The value. - /// - bool SetValue(Script script, object obj, DynValue value); - /// - /// Gets the type of the member. - /// - /// - /// The type of the member. - /// - UserDataMemberType MemberType { get; } - - - void Optimize(); - - - - bool IsStatic { get; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataType.cs deleted file mode 100644 index 9ae18bbe..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IUserDataType.cs +++ /dev/null @@ -1,47 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// As a convenience, every type deriving from IUserDataType is "self-described". That is, no descriptor is needed/generated - /// and the object itself is used to describe the type for interop. See also , - /// and . - /// - public interface IUserDataType - { - /// - /// Performs an "index" "get" operation. - /// - /// The script originating the request - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - DynValue Index(Script script, DynValue index, bool isDirectIndexing); - /// - /// Performs an "index" "set" operation. - /// - /// The script originating the request - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - bool SetIndex(Script script, DynValue index, DynValue value, bool isDirectIndexing); - /// - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// - /// These standard metamethods can be supported (the return value should be a function accepting the - /// classic parameters of the corresponding metamethod): - /// __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - /// __pairs, __ipairs, __iterator, __call - /// - /// These standard metamethods are supported through other calls for efficiency: - /// __index, __newindex, __tostring - /// - /// - /// The script originating the request - /// The name of the metamember. - /// - DynValue MetaIndex(Script script, string metaname); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IWireableDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IWireableDescriptor.cs deleted file mode 100644 index 7bbe8996..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/IWireableDescriptor.cs +++ /dev/null @@ -1,17 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop.BasicDescriptors -{ - /// - /// Interface for descriptors with the capability of being serialized - /// for later hardwiring. - /// - public interface IWireableDescriptor - { - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - void PrepareForWiring(Table t); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropAccessMode.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropAccessMode.cs deleted file mode 100644 index 8b5f8b07..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropAccessMode.cs +++ /dev/null @@ -1,51 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Enumerations of the possible strategies to marshal CLR objects to MoonSharp userdata and functions - /// when using automatic descriptors. - /// Note that these are "hints" and MoonSharp is free to ignore the access mode specified (if different from - /// HideMembers) and downgrade the access mode to "Reflection". - /// This particularly happens when running on AOT platforms like iOS. - /// See also : and . - /// - public enum InteropAccessMode - { - /// - /// Optimization is not performed and reflection is used everytime to access members. - /// This is the slowest approach but saves a lot of memory if members are seldomly used. - /// - Reflection, - /// - /// Optimization is done on the fly the first time a member is accessed. - /// This saves memory for all members that are never accessed, at the cost of an increased script execution time. - /// - LazyOptimized, - /// - /// Optimization is done at registration time. - /// - Preoptimized, - /// - /// Optimization is done in a background thread which starts at registration time. - /// If a member is accessed before optimization is completed, reflection is used. - /// - BackgroundOptimized, - /// - /// Use the hardwired descriptor(s) - /// - Hardwired, - /// - /// No optimization is done, and members are not accessible at all. - /// - HideMembers, - /// - /// No reflection is allowed, nor code generation. This is used as a safeguard when registering types which should not - /// use a standard reflection based descriptor - for example for types implementing - /// - NoReflectionAllowed, - /// - /// Use the default access mode - /// - Default - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropRegistrationPolicy.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropRegistrationPolicy.cs deleted file mode 100644 index ac21fcfb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/InteropRegistrationPolicy.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.RegistrationPolicies; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Collection of the standard policies to handle UserData type registrations. - /// Provided mostly for compile-time backward compatibility with old code. - /// See also : . - /// - public static class InteropRegistrationPolicy - { - /// - /// The default registration policy used by MoonSharp unless explicitely replaced. - /// Deregistrations are allowed, but registration of a new descriptor are not allowed - /// if a descriptor is already registered for that type. - /// - /// Types must be explicitly registered. - /// - public static IRegistrationPolicy Default { get { return new DefaultRegistrationPolicy(); }} - - /// - /// The default registration policy used by MoonSharp unless explicitely replaced. - /// Deregistrations are allowed, but registration of a new descriptor are not allowed - /// if a descriptor is already registered for that type. - /// - /// Types must be explicitly registered. - /// - [Obsolete("Please use InteropRegistrationPolicy.Default instead.")] - public static IRegistrationPolicy Explicit { get { return new DefaultRegistrationPolicy(); } } - /// - /// Types are automatically registered if not found in the registry. This is easier to use but potentially unsafe. - /// - public static IRegistrationPolicy Automatic { get { return new AutomaticRegistrationPolicy(); } } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/CharPtr.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/CharPtr.cs deleted file mode 100644 index dc1b2c62..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/CharPtr.cs +++ /dev/null @@ -1,216 +0,0 @@ -#pragma warning disable 1591 -// -// This part taken from KopiLua - https://github.com/NLua/KopiLua -// -// ========================================================================================================= -// -// Kopi Lua License -// ---------------- -// MIT License for KopiLua -// Copyright (c) 2012 LoDC -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -// associated documentation files (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// The above copyright notice and this permission notice shall be included in all copies or substantial -// portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// =============================================================================== -// Lua License -// ----------- -// Lua is licensed under the terms of the MIT license reproduced below. -// This means that Lua is free software and can be used for both academic -// and commercial purposes at absolutely no cost. -// For details and rationale, see http://www.lua.org/license.html . -// =============================================================================== -// Copyright (C) 1994-2008 Lua.org, PUC-Rio. -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - public class CharPtr - { - public char[] chars; - public int index; - - public char this[int offset] - { - get { return chars[index + offset]; } - set { chars[index + offset] = value; } - } - - public char this[uint offset] - { - get { return chars[index + offset]; } - set { chars[index + offset] = value; } - } - public char this[long offset] - { - get { return chars[index + (int)offset]; } - set { chars[index + (int)offset] = value; } - } - - public static implicit operator CharPtr(string str) { return new CharPtr(str); } - public static implicit operator CharPtr(char[] chars) { return new CharPtr(chars); } - public static implicit operator CharPtr(byte[] bytes) { return new CharPtr(bytes); } - - public CharPtr() - { - this.chars = null; - this.index = 0; - } - - public CharPtr(string str) - { - this.chars = (str + '\0').ToCharArray(); - this.index = 0; - } - - public CharPtr(CharPtr ptr) - { - this.chars = ptr.chars; - this.index = ptr.index; - } - - public CharPtr(CharPtr ptr, int index) - { - this.chars = ptr.chars; - this.index = index; - } - - public CharPtr(char[] chars) - { - this.chars = chars; - this.index = 0; - } - - public CharPtr(char[] chars, int index) - { - this.chars = chars; - this.index = index; - } - - public CharPtr(byte[] bytes) - { - this.chars = new char[bytes.Length]; - for (int i = 0; i < bytes.Length; i++) - { - this.chars[i] = (char)bytes[i]; - } - - this.index = 0; - } - - public CharPtr(IntPtr ptr) - { - this.chars = new char[0]; - this.index = 0; - } - - public static CharPtr operator +(CharPtr ptr, int offset) { return new CharPtr(ptr.chars, ptr.index + offset); } - public static CharPtr operator -(CharPtr ptr, int offset) { return new CharPtr(ptr.chars, ptr.index - offset); } - public static CharPtr operator +(CharPtr ptr, uint offset) { return new CharPtr(ptr.chars, ptr.index + (int)offset); } - public static CharPtr operator -(CharPtr ptr, uint offset) { return new CharPtr(ptr.chars, ptr.index - (int)offset); } - - public void inc() { this.index++; } - public void dec() { this.index--; } - public CharPtr next() { return new CharPtr(this.chars, this.index + 1); } - public CharPtr prev() { return new CharPtr(this.chars, this.index - 1); } - public CharPtr add(int ofs) { return new CharPtr(this.chars, this.index + ofs); } - public CharPtr sub(int ofs) { return new CharPtr(this.chars, this.index - ofs); } - - public static bool operator ==(CharPtr ptr, char ch) { return ptr[0] == ch; } - public static bool operator ==(char ch, CharPtr ptr) { return ptr[0] == ch; } - public static bool operator !=(CharPtr ptr, char ch) { return ptr[0] != ch; } - public static bool operator !=(char ch, CharPtr ptr) { return ptr[0] != ch; } - - public static CharPtr operator +(CharPtr ptr1, CharPtr ptr2) - { - string result = ""; - for (int i = 0; ptr1[i] != '\0'; i++) - result += ptr1[i]; - for (int i = 0; ptr2[i] != '\0'; i++) - result += ptr2[i]; - return new CharPtr(result); - } - public static int operator -(CharPtr ptr1, CharPtr ptr2) - { - Debug.Assert(ptr1.chars == ptr2.chars); return ptr1.index - ptr2.index; - } - public static bool operator <(CharPtr ptr1, CharPtr ptr2) - { - Debug.Assert(ptr1.chars == ptr2.chars); return ptr1.index < ptr2.index; - } - public static bool operator <=(CharPtr ptr1, CharPtr ptr2) - { - Debug.Assert(ptr1.chars == ptr2.chars); return ptr1.index <= ptr2.index; - } - public static bool operator >(CharPtr ptr1, CharPtr ptr2) - { - Debug.Assert(ptr1.chars == ptr2.chars); return ptr1.index > ptr2.index; - } - public static bool operator >=(CharPtr ptr1, CharPtr ptr2) - { - Debug.Assert(ptr1.chars == ptr2.chars); return ptr1.index >= ptr2.index; - } - public static bool operator ==(CharPtr ptr1, CharPtr ptr2) - { - object o1 = ptr1 as CharPtr; - object o2 = ptr2 as CharPtr; - if ((o1 == null) && (o2 == null)) return true; - if (o1 == null) return false; - if (o2 == null) return false; - return (ptr1.chars == ptr2.chars) && (ptr1.index == ptr2.index); - } - public static bool operator !=(CharPtr ptr1, CharPtr ptr2) { return !(ptr1 == ptr2); } - - public override bool Equals(object o) - { - return this == (o as CharPtr); - } - - public override int GetHashCode() - { - return 0; - } - public override string ToString() - { - System.Text.StringBuilder result = new System.Text.StringBuilder(); - for (int i = index; (i < chars.Length) && (chars[i] != '\0'); i++) - result.Append(chars[i]); - - return result.ToString(); - } - - public string ToString(int length) - { - System.Text.StringBuilder result = new System.Text.StringBuilder(); - for (int i = index; (i < chars.Length) && i < (length + index); i++) - result.Append(chars[i]); - return result.ToString(); - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase.cs deleted file mode 100644 index e62ff92b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase.cs +++ /dev/null @@ -1,323 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using lua_Integer = System.Int32; - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - /// - /// Classes using the classic interface should inherit from this class. - /// This class defines only static methods and is really meant to be used only - /// from C# and not other .NET languages. - /// - /// For easier operation they should also define: - /// using ptrdiff_t = System.Int32; - /// using lua_Integer = System.Int32; - /// using LUA_INTFRM_T = System.Int64; - /// using UNSIGNED_LUA_INTFRM_T = System.UInt64; - /// - public partial class LuaBase - { - protected const int LUA_TNONE = -1; - protected const int LUA_TNIL = 0; - protected const int LUA_TBOOLEAN = 1; - protected const int LUA_TLIGHTUSERDATA = 2; - protected const int LUA_TNUMBER = 3; - protected const int LUA_TSTRING = 4; - protected const int LUA_TTABLE = 5; - protected const int LUA_TFUNCTION = 6; - protected const int LUA_TUSERDATA = 7; - protected const int LUA_TTHREAD = 8; - - protected const int LUA_MULTRET = -1; - - protected const string LUA_INTFRMLEN = "l"; - - protected static DynValue GetArgument(LuaState L, lua_Integer pos) - { - return L.At(pos); - } - - protected static DynValue ArgAsType(LuaState L, lua_Integer pos, DataType type, bool allowNil = false) - { - return GetArgument(L, pos).CheckType(L.FunctionName, type, pos - 1, allowNil ? TypeValidationFlags.AllowNil | TypeValidationFlags.AutoConvert : TypeValidationFlags.AutoConvert); - } - - protected static lua_Integer LuaType(LuaState L, lua_Integer p) - { - switch (GetArgument(L, p).Type) - { - case DataType.Void: - return LUA_TNONE; - case DataType.Nil: - return LUA_TNIL; - case DataType.Boolean: - return LUA_TNIL; - case DataType.Number: - return LUA_TNUMBER; - case DataType.String: - return LUA_TSTRING; - case DataType.Function: - return LUA_TFUNCTION; - case DataType.Table: - return LUA_TTABLE; - case DataType.UserData: - return LUA_TUSERDATA; - case DataType.Thread: - return LUA_TTHREAD; - case DataType.ClrFunction: - return LUA_TFUNCTION; - case DataType.TailCallRequest: - case DataType.YieldRequest: - case DataType.Tuple: - default: - throw new ScriptRuntimeException("Can't call LuaType on any type"); - } - } - - protected static string LuaLCheckLString(LuaState L, lua_Integer argNum, out uint l) - { - string str = ArgAsType(L, argNum, DataType.String, false).String; - l = (uint)str.Length; - return str; - } - - protected static void LuaPushInteger(LuaState L, lua_Integer val) - { - L.Push(DynValue.NewNumber(val)); - } - - protected static lua_Integer LuaToBoolean(LuaState L, lua_Integer p) - { - return GetArgument(L, p).CastToBool() ? 1 : 0; - } - - protected static string LuaToLString(LuaState luaState, lua_Integer p, out uint l) - { - return LuaLCheckLString(luaState, p, out l); - } - - protected static string LuaToString(LuaState luaState, lua_Integer p) - { - uint l; - return LuaLCheckLString(luaState, p, out l); - } - - protected static void LuaLAddValue(LuaLBuffer b) - { - b.StringBuilder.Append(b.LuaState.Pop().ToPrintString()); - } - - protected static void LuaLAddLString(LuaLBuffer b, CharPtr s, uint p) - { - b.StringBuilder.Append(s.ToString((int)p)); - } - - protected static void LuaLAddString(LuaLBuffer b, string s) - { - b.StringBuilder.Append(s.ToString()); - } - - - protected static lua_Integer LuaLOptInteger(LuaState L, lua_Integer pos, lua_Integer def) - { - DynValue v = ArgAsType(L, pos, DataType.Number, true); - - if (v.IsNil()) - return def; - else - return (int)v.Number; - } - - protected static lua_Integer LuaLCheckInteger(LuaState L, lua_Integer pos) - { - DynValue v = ArgAsType(L, pos, DataType.Number, false); - return (int)v.Number; - } - - protected static void LuaLArgCheck(LuaState L, bool condition, lua_Integer argNum, string message) - { - if (!condition) - LuaLArgError(L, argNum, message); - } - - protected static lua_Integer LuaLCheckInt(LuaState L, lua_Integer argNum) - { - return LuaLCheckInteger(L, argNum); - } - - protected static lua_Integer LuaGetTop(LuaState L) - { - return L.Count; - } - - protected static lua_Integer LuaLError(LuaState luaState, string message, params object[] args) - { - throw new ScriptRuntimeException(message, args); - } - - protected static void LuaLAddChar(LuaLBuffer b, char p) - { - b.StringBuilder.Append(p); - } - - protected static void LuaLBuffInit(LuaState L, LuaLBuffer b) - { - } - - protected static void LuaPushLiteral(LuaState L, string literalString) - { - L.Push(DynValue.NewString(literalString)); - } - - protected static void LuaLPushResult(LuaLBuffer b) - { - LuaPushLiteral(b.LuaState, b.StringBuilder.ToString()); - } - - protected static void LuaPushLString(LuaState L, CharPtr s, uint len) - { - string ss = s.ToString((int)len); - L.Push(DynValue.NewString(ss)); - } - - protected static void LuaLCheckStack(LuaState L, lua_Integer n, string message) - { - // nop ? - } - - protected static string LUA_QL(string p) - { - return "'" + p + "'"; - } - - - protected static void LuaPushNil(LuaState L) - { - L.Push(DynValue.Nil); - } - - protected static void LuaAssert(bool p) - { - // ??! - // A lot of KopiLua methods fall here in valid state! - - //if (!p) - // throw new InternalErrorException("LuaAssert failed!"); - } - - protected static string LuaLTypeName(LuaState L, lua_Integer p) - { - return L.At(p).Type.ToErrorTypeString(); - } - - protected static lua_Integer LuaIsString(LuaState L, lua_Integer p) - { - var v = L.At(p); - return (v.Type == DataType.String || v.Type == DataType.Number) ? 1 : 0; - } - - protected static void LuaPop(LuaState L, lua_Integer p) - { - for (int i = 0; i < p; i++) - L.Pop(); - } - - protected static void LuaGetTable(LuaState L, lua_Integer p) - { - // DEBT: this should call metamethods, now it performs raw access - DynValue key = L.Pop(); - DynValue table = L.At(p); - - if (table.Type != DataType.Table) - throw new NotImplementedException(); - - var v = table.Table.Get(key); - L.Push(v); - } - - protected static int LuaLOptInt(LuaState L, lua_Integer pos, lua_Integer def) - { - return LuaLOptInteger(L, pos, def); - } - - protected static CharPtr LuaLCheckString(LuaState L, lua_Integer p) - { - uint dummy; - return LuaLCheckLString(L, p, out dummy); - } - - protected static string LuaLCheckStringStr(LuaState L, lua_Integer p) - { - uint dummy; - return LuaLCheckLString(L, p, out dummy); - } - - protected static void LuaLArgError(LuaState L, lua_Integer arg, string p) - { - throw ScriptRuntimeException.BadArgument(arg - 1, L.FunctionName, p); - } - - protected static double LuaLCheckNumber(LuaState L, lua_Integer pos) - { - DynValue v = ArgAsType(L, pos, DataType.Number, false); - return v.Number; - } - - protected static void LuaPushValue(LuaState L, lua_Integer arg) - { - DynValue v = L.At(arg); - L.Push(v); - } - - - /// - /// Calls a function. - /// To call a function you must use the following protocol: first, the function to be called is pushed onto the stack; then, - /// the arguments to the function are pushed in direct order; that is, the first argument is pushed first. Finally you call - /// lua_call; nargs is the number of arguments that you pushed onto the stack. All arguments and the function value are - /// popped from the stack when the function is called. The function results are pushed onto the stack when the function - /// returns. The number of results is adjusted to nresults, unless nresults is LUA_MULTRET. In this case, all results from - /// the function are pushed. Lua takes care that the returned values fit into the stack space. The function results are - /// pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is on - /// the top of the stack. - /// - /// The LuaState - /// The number of arguments. - /// The number of expected results. - /// - protected static void LuaCall(LuaState L, lua_Integer nargs, lua_Integer nresults = LUA_MULTRET) - { - DynValue[] args = L.GetTopArray(nargs); - - L.Discard(nargs); - - DynValue func = L.Pop(); - - DynValue ret = L.ExecutionContext.Call(func, args); - - if (nresults != 0) - { - if (nresults == -1) - { - nresults = (ret.Type == DataType.Tuple) ? ret.Tuple.Length : 1; - } - - DynValue[] vals = (ret.Type == DataType.Tuple) ? ret.Tuple : new DynValue[1] { ret }; - - int copied = 0; - - for (int i = 0; i < vals.Length && copied < nresults; i++, copied++) - { - L.Push(vals[i]); - } - - while (copied < nresults) - { - L.Push(DynValue.Nil); - } - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase_CLib.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase_CLib.cs deleted file mode 100644 index b5ebfc2f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaBase_CLib.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System; -using lua_Integer = System.Int32; - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - public partial class LuaBase - { - protected static lua_Integer memcmp(CharPtr ptr1, CharPtr ptr2, uint size) - { - return memcmp(ptr1, ptr2, (int)size); - } - - protected static int memcmp(CharPtr ptr1, CharPtr ptr2, int size) - { - for (int i = 0; i < size; i++) - if (ptr1[i] != ptr2[i]) - { - if (ptr1[i] < ptr2[i]) - return -1; - else - return 1; - } - return 0; - } - - protected static CharPtr memchr(CharPtr ptr, char c, uint count) - { - for (uint i = 0; i < count; i++) - if (ptr[i] == c) - return new CharPtr(ptr.chars, (int)(ptr.index + i)); - return null; - } - - protected static CharPtr strpbrk(CharPtr str, CharPtr charset) - { - for (int i = 0; str[i] != '\0'; i++) - for (int j = 0; charset[j] != '\0'; j++) - if (str[i] == charset[j]) - return new CharPtr(str.chars, str.index + i); - return null; - } - - protected static bool isalpha(char c) { return Char.IsLetter(c); } - protected static bool iscntrl(char c) { return Char.IsControl(c); } - protected static bool isdigit(char c) { return Char.IsDigit(c); } - protected static bool islower(char c) { return Char.IsLower(c); } - protected static bool ispunct(char c) { return Char.IsPunctuation(c); } - protected static bool isspace(char c) { return (c == ' ') || (c >= (char)0x09 && c <= (char)0x0D); } - protected static bool isupper(char c) { return Char.IsUpper(c); } - protected static bool isalnum(char c) { return Char.IsLetterOrDigit(c); } - protected static bool isxdigit(char c) { return "0123456789ABCDEFabcdef".IndexOf(c) >= 0; } - protected static bool isgraph(char c) { return !Char.IsControl(c) && !Char.IsWhiteSpace(c); } - - protected static bool isalpha(int c) { return Char.IsLetter((char)c); } - protected static bool iscntrl(int c) { return Char.IsControl((char)c); } - protected static bool isdigit(int c) { return Char.IsDigit((char)c); } - protected static bool islower(int c) { return Char.IsLower((char)c); } - protected static bool ispunct(int c) { return ((char)c != ' ') && !isalnum((char)c); } // *not* the same as Char.IsPunctuation - protected static bool isspace(int c) { return ((char)c == ' ') || ((char)c >= (char)0x09 && (char)c <= (char)0x0D); } - protected static bool isupper(int c) { return Char.IsUpper((char)c); } - protected static bool isalnum(int c) { return Char.IsLetterOrDigit((char)c); } - protected static bool isgraph(int c) { return !Char.IsControl((char)c) && !Char.IsWhiteSpace((char)c); } - - protected static char tolower(char c) { return Char.ToLower(c); } - protected static char toupper(char c) { return Char.ToUpper(c); } - protected static char tolower(int c) { return Char.ToLower((char)c); } - protected static char toupper(int c) { return Char.ToUpper((char)c); } - - - // find c in str - protected static CharPtr strchr(CharPtr str, char c) - { - for (int index = str.index; str.chars[index] != 0; index++) - if (str.chars[index] == c) - return new CharPtr(str.chars, index); - return null; - } - - protected static CharPtr strcpy(CharPtr dst, CharPtr src) - { - int i; - for (i = 0; src[i] != '\0'; i++) - dst[i] = src[i]; - dst[i] = '\0'; - return dst; - } - - protected static CharPtr strncpy(CharPtr dst, CharPtr src, int length) - { - int index = 0; - while ((src[index] != '\0') && (index < length)) - { - dst[index] = src[index]; - index++; - } - while (index < length) - dst[index++] = '\0'; - return dst; - } - - protected static int strlen(CharPtr str) - { - int index = 0; - while (str[index] != '\0') - index++; - return index; - } - - public static void sprintf(CharPtr buffer, CharPtr str, params object[] argv) - { - string temp = Tools.sprintf(str.ToString(), argv); - strcpy(buffer, temp); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaLBuffer.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaLBuffer.cs deleted file mode 100644 index ed3ba873..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaLBuffer.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System.Text; - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - public class LuaLBuffer - { - public StringBuilder StringBuilder { get; private set; } - public LuaState LuaState { get; private set; } - - public LuaLBuffer(LuaState l) - { - StringBuilder = new StringBuilder(); - LuaState = l; - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaState.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaState.cs deleted file mode 100644 index 94fbbbcb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/LuaState.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Disable warnings about XML documentation -#pragma warning disable 1591 - -using System.Collections.Generic; - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - /// - /// - /// - public class LuaState - { - private List m_Stack; - - public ScriptExecutionContext ExecutionContext { get; private set; } - public string FunctionName { get; private set; } - - internal LuaState(ScriptExecutionContext executionContext, CallbackArguments args, string functionName) - { - ExecutionContext = executionContext; - m_Stack = new List(16); - - for (int i = 0; i < args.Count; i++) - m_Stack.Add(args[i]); - - FunctionName = functionName; - } - - public DynValue Top(int pos = 0) - { - return m_Stack[m_Stack.Count - 1 - pos]; - } - - public DynValue At(int pos) - { - if (pos < 0) - pos = m_Stack.Count + pos + 1; - - if (pos > m_Stack.Count) - return DynValue.Void; - - return m_Stack[pos - 1]; - } - - public int Count - { - get { return m_Stack.Count; } - } - - public void Push(DynValue v) - { - m_Stack.Add(v); - } - - public DynValue Pop() - { - var v = Top(); - m_Stack.RemoveAt(m_Stack.Count - 1); - return v; - } - - public DynValue[] GetTopArray(int num) - { - DynValue[] rets = new DynValue[num]; - - for (int i = 0; i < num; i++) - rets[num - i - 1] = Top(i); - - return rets; - } - - - public DynValue GetReturnValue(int retvals) - { - if (retvals == 0) - return DynValue.Nil; - else if (retvals == 1) - return Top(); - else - { - DynValue[] rets = GetTopArray(retvals); - return DynValue.NewTupleNested(rets); - } - } - - - - public void Discard(int nargs) - { - for(int i = 0; i < nargs; i++) - m_Stack.RemoveAt(m_Stack.Count - 1); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/Tools.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/Tools.cs deleted file mode 100755 index 4a9b36fd..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/LuaStateInterop/Tools.cs +++ /dev/null @@ -1,732 +0,0 @@ -// -// This part taken from KopiLua - https://github.com/NLua/KopiLua -// -// ========================================================================================================= -// -// Kopi Lua License -// ---------------- -// MIT License for KopiLua -// Copyright (c) 2012 LoDC -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -// associated documentation files (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// The above copyright notice and this permission notice shall be included in all copies or substantial -// portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// =============================================================================== -// Lua License -// ----------- -// Lua is licensed under the terms of the MIT license reproduced below. -// This means that Lua is free software and can be used for both academic -// and commercial purposes at absolutely no cost. -// For details and rationale, see http://www.lua.org/license.html . -// =============================================================================== -// Copyright (C) 1994-2008 Lua.org, PUC-Rio. -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#region Usings -using System; -using System.Globalization; -using System.IO; -using System.Text; -using System.Text.RegularExpressions; - - -#endregion - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - internal static class Tools - { - #region Public Methods - #region IsNumericType - /// - /// Determines whether the specified value is of numeric type. - /// - /// The object to check. - /// - /// true if o is a numeric type; otherwise, false. - /// - public static bool IsNumericType(object o) - { - return (o is byte || - o is sbyte || - o is short || - o is ushort || - o is int || - o is uint || - o is long || - o is ulong || - o is float || - o is double || - o is decimal); - } - #endregion - #region IsPositive - /// - /// Determines whether the specified value is positive. - /// - /// The value. - /// if set to true treats 0 as positive. - /// - /// true if the specified value is positive; otherwise, false. - /// - public static bool IsPositive(object Value, bool ZeroIsPositive) - { - Type t = Value.GetType(); - - if (t == typeof(sbyte)) - return (ZeroIsPositive ? (sbyte)Value >= 0 : (sbyte)Value > 0); - if (t == typeof(short)) - return (ZeroIsPositive ? (short)Value >= 0 : (short)Value > 0); - if (t == typeof(int)) - return (ZeroIsPositive ? (int)Value >= 0 : (int)Value > 0); - if (t == typeof(long)) - return (ZeroIsPositive ? (long)Value >= 0 : (long)Value > 0); - if (t == typeof(byte)) - return (ZeroIsPositive ? true : (byte)Value > 0); - if (t == typeof(ushort)) - return (ZeroIsPositive ? true : (ushort)Value > 0); - if (t == typeof(uint)) - return (ZeroIsPositive ? true : (uint)Value > 0); - if (t == typeof(ulong)) - return (ZeroIsPositive ? true : (ulong)Value > 0); - if (t == typeof(float)) - return (ZeroIsPositive ? (float)Value >= 0 : (float)Value > 0); - if (t == typeof(double)) - return (ZeroIsPositive ? (double)Value >= 0 : (double)Value > 0); - if (t == typeof(decimal)) - return (ZeroIsPositive ? (decimal)Value >= 0 : (decimal)Value > 0); - if (t == typeof(char)) - return (ZeroIsPositive ? true : (char)Value != '\0'); - - return ZeroIsPositive; - } - #endregion - #region ToUnsigned - /// - /// Converts the specified values boxed type to its correpsonding unsigned - /// type. - /// - /// The value. - /// A boxed numeric object whos type is unsigned. - public static object ToUnsigned(object Value) - { - Type t = Value.GetType(); - - if (t == typeof(sbyte)) - return (byte)((sbyte)Value); - if (t == typeof(short)) - return (ushort)((short)Value); - if (t == typeof(int)) - return (uint)((int)Value); - if (t == typeof(long)) - return (ulong)((long)Value); - if (t == typeof(byte)) - return Value; - if (t == typeof(ushort)) - return Value; - if (t == typeof(uint)) - return Value; - if (t == typeof(ulong)) - return Value; - if (t == typeof(float)) - return (uint)((float)Value); - if (t == typeof(double)) - return (ulong)((double)Value); - if (t == typeof(decimal)) - return (ulong)((decimal)Value); - - return null; - } - #endregion - #region ToInteger - /// - /// Converts the specified values boxed type to its correpsonding integer - /// type. - /// - /// The value. - /// if set to true [round]. - /// - /// A boxed numeric object whos type is an integer type. - /// - public static object ToInteger(object Value, bool Round) - { - Type t = Value.GetType(); - - if (t == typeof(sbyte)) - return Value; - if (t == typeof(short)) - return Value; - if (t == typeof(int)) - return Value; - if (t == typeof(long)) - return Value; - if (t == typeof(byte)) - return Value; - if (t == typeof(ushort)) - return Value; - if (t == typeof(uint)) - return Value; - if (t == typeof(ulong)) - return Value; - if (t == typeof(float)) - return (Round ? (int)Math.Round((float)Value) : (int)((float)Value)); - if (t == typeof(double)) - return (Round ? (long)Math.Round((double)Value) : (long)((double)Value)); - if (t == typeof(decimal)) - return (Round ? Math.Round((decimal)Value) : (decimal)Value); - - return null; - } - #endregion - #region UnboxToLong - public static long UnboxToLong(object Value, bool Round) - { - Type t = Value.GetType(); - - if (t == typeof(sbyte)) - return (long)((sbyte)Value); - if (t == typeof(short)) - return (long)((short)Value); - if (t == typeof(int)) - return (long)((int)Value); - if (t == typeof(long)) - return (long)Value; - if (t == typeof(byte)) - return (long)((byte)Value); - if (t == typeof(ushort)) - return (long)((ushort)Value); - if (t == typeof(uint)) - return (long)((uint)Value); - if (t == typeof(ulong)) - return (long)((ulong)Value); - if (t == typeof(float)) - return (Round ? (long)Math.Round((float)Value) : (long)((float)Value)); - if (t == typeof(double)) - return (Round ? (long)Math.Round((double)Value) : (long)((double)Value)); - if (t == typeof(decimal)) - return (Round ? (long)Math.Round((decimal)Value) : (long)((decimal)Value)); - - return 0; - } - #endregion - #region ReplaceMetaChars - /// - /// Replaces the string representations of meta chars with their corresponding - /// character values. - /// - /// The input. - /// A string with all string meta chars are replaced - public static string ReplaceMetaChars(string input) - { - return Regex.Replace(input, @"(\\)(\d{3}|[^\d])?", new MatchEvaluator(ReplaceMetaCharsMatch)); - } - private static string ReplaceMetaCharsMatch(Match m) - { - // convert octal quotes (like \040) - if (m.Groups[2].Length == 3) - return Convert.ToChar(Convert.ToByte(m.Groups[2].Value, 8)).ToString(); - else - { - // convert all other special meta characters - //TODO: \xhhh hex and possible dec !! - switch (m.Groups[2].Value) - { - case "0": // null - return "\0"; - case "a": // alert (beep) - return "\a"; - case "b": // BS - return "\b"; - case "f": // FF - return "\f"; - case "v": // vertical tab - return "\v"; - case "r": // CR - return "\r"; - case "n": // LF - return "\n"; - case "t": // Tab - return "\t"; - default: - // if neither an octal quote nor a special meta character - // so just remove the backslash - return m.Groups[2].Value; - } - } - } - #endregion - #region fprintf - public static void fprintf(TextWriter Destination, string Format, params object[] Parameters) - { - Destination.Write(Tools.sprintf(Format, Parameters)); - } - - - #endregion - #region sprintf - internal static Regex r = new Regex(@"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])"); - public static string sprintf(string Format, params object[] Parameters) - { - #region Variables - StringBuilder f = new StringBuilder(); - //Regex r = new Regex( @"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])" ); - //"%[parameter][flags][width][.precision][length]type" - Match m = null; - string w = String.Empty; - int defaultParamIx = 0; - int paramIx; - object o = null; - - bool flagLeft2Right = false; - bool flagAlternate = false; - bool flagPositiveSign = false; - bool flagPositiveSpace = false; - bool flagZeroPadding = false; - bool flagGroupThousands = false; - - int fieldLength = 0; - int fieldPrecision = 0; - char shortLongIndicator = '\0'; - char formatSpecifier = '\0'; - char paddingCharacter = ' '; - #endregion - - // find all format parameters in format string - f.Append(Format); - m = r.Match(f.ToString()); - while (m.Success) - { - #region parameter index - paramIx = defaultParamIx; - if (m.Groups[1] != null && m.Groups[1].Value.Length > 0) - { - string val = m.Groups[1].Value.Substring(0, m.Groups[1].Value.Length - 1); - paramIx = Convert.ToInt32(val) - 1; - }; - #endregion - - #region format flags - // extract format flags - flagAlternate = false; - flagLeft2Right = false; - flagPositiveSign = false; - flagPositiveSpace = false; - flagZeroPadding = false; - flagGroupThousands = false; - if (m.Groups[2] != null && m.Groups[2].Value.Length > 0) - { - string flags = m.Groups[2].Value; - - flagAlternate = (flags.IndexOf('#') >= 0); - flagLeft2Right = (flags.IndexOf('-') >= 0); - flagPositiveSign = (flags.IndexOf('+') >= 0); - flagPositiveSpace = (flags.IndexOf(' ') >= 0); - flagGroupThousands = (flags.IndexOf('\'') >= 0); - - // positive + indicator overrides a - // positive space character - if (flagPositiveSign && flagPositiveSpace) - flagPositiveSpace = false; - } - #endregion - - #region field length - // extract field length and - // pading character - paddingCharacter = ' '; - fieldLength = int.MinValue; - if (m.Groups[3] != null && m.Groups[3].Value.Length > 0) - { - fieldLength = Convert.ToInt32(m.Groups[3].Value); - flagZeroPadding = (m.Groups[3].Value[0] == '0'); - } - #endregion - - if (flagZeroPadding) - paddingCharacter = '0'; - - // left2right allignment overrides zero padding - if (flagLeft2Right && flagZeroPadding) - { - flagZeroPadding = false; - paddingCharacter = ' '; - } - - #region field precision - // extract field precision - fieldPrecision = int.MinValue; - if (m.Groups[4] != null && m.Groups[4].Value.Length > 0) - fieldPrecision = Convert.ToInt32(m.Groups[4].Value); - #endregion - - #region short / long indicator - // extract short / long indicator - shortLongIndicator = Char.MinValue; - if (m.Groups[5] != null && m.Groups[5].Value.Length > 0) - shortLongIndicator = m.Groups[5].Value[0]; - #endregion - - #region format specifier - // extract format - formatSpecifier = Char.MinValue; - if (m.Groups[6] != null && m.Groups[6].Value.Length > 0) - formatSpecifier = m.Groups[6].Value[0]; - #endregion - - // default precision is 6 digits if none is specified except - if (fieldPrecision == int.MinValue && - formatSpecifier != 's' && - formatSpecifier != 'c' && - Char.ToUpper(formatSpecifier) != 'X' && - formatSpecifier != 'o') - fieldPrecision = 6; - - #region get next value parameter - // get next value parameter and convert value parameter depending on short / long indicator - if (Parameters == null || paramIx >= Parameters.Length) - o = null; - else - { - o = Parameters[paramIx]; - - if (shortLongIndicator == 'h') - { - if (o is int) - o = (short)((int)o); - else if (o is long) - o = (short)((long)o); - else if (o is uint) - o = (ushort)((uint)o); - else if (o is ulong) - o = (ushort)((ulong)o); - } - else if (shortLongIndicator == 'l') - { - if (o is short) - o = (long)((short)o); - else if (o is int) - o = (long)((int)o); - else if (o is ushort) - o = (ulong)((ushort)o); - else if (o is uint) - o = (ulong)((uint)o); - } - } - #endregion - - // convert value parameters to a string depending on the formatSpecifier - w = String.Empty; - switch (formatSpecifier) - { - #region % - character - case '%': // % character - w = "%"; - break; - #endregion - #region d - integer - case 'd': // integer - w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region i - integer - case 'i': // integer - goto case 'd'; - #endregion - #region o - octal integer - case 'o': // octal integer - no leading zero - w = FormatOct("o", flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region x - hex integer - case 'x': // hex integer - no leading zero - w = FormatHex("x", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region X - hex integer - case 'X': // same as x but with capital hex characters - w = FormatHex("X", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region u - unsigned integer - case 'u': // unsigned integer - w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - false, false, - paddingCharacter, ToUnsigned(o)); - defaultParamIx++; - break; - #endregion - #region c - character - case 'c': // character - if (IsNumericType(o)) - w = Convert.ToChar(o).ToString(); - else if (o is char) - w = ((char)o).ToString(); - else if (o is string && ((string)o).Length > 0) - w = ((string)o)[0].ToString(); - defaultParamIx++; - break; - #endregion - #region s - string - case 's': // string - //string t = "{0" + ( fieldLength != int.MinValue ? "," + ( flagLeft2Right ? "-" : String.Empty ) + fieldLength.ToString() : String.Empty ) + ":s}"; - w = o.ToString(); - if (fieldPrecision >= 0) - w = w.Substring(0, fieldPrecision); - - if (fieldLength != int.MinValue) - if (flagLeft2Right) - w = w.PadRight(fieldLength, paddingCharacter); - else - w = w.PadLeft(fieldLength, paddingCharacter); - defaultParamIx++; - break; - #endregion - #region f - double number - case 'f': // double - w = FormatNumber((flagGroupThousands ? "n" : "f"), flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region e - exponent number - case 'e': // double / exponent - w = FormatNumber("e", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region E - exponent number - case 'E': // double / exponent - w = FormatNumber("E", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region g - general number - case 'g': // double / exponent - w = FormatNumber("g", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region G - general number - case 'G': // double / exponent - w = FormatNumber("G", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; - #endregion - #region p - pointer - case 'p': // pointer - if (o is IntPtr) -#if PCL || ENABLE_DOTNET - w = ( (IntPtr)o ).ToString(); -#else - w = "0x" + ((IntPtr)o).ToString("x"); -#endif - defaultParamIx++; - break; - #endregion - #region n - number of processed chars so far - case 'n': // number of characters so far - w = FormatNumber("d", flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, m.Index); - break; - #endregion - default: - w = String.Empty; - defaultParamIx++; - break; - } - - // replace format parameter with parameter value - // and start searching for the next format parameter - // AFTER the position of the current inserted value - // to prohibit recursive matches if the value also - // includes a format specifier - f.Remove(m.Index, m.Length); - f.Insert(m.Index, w); - m = r.Match(f.ToString(), m.Index + w.Length); - } - - return f.ToString(); - } - #endregion - #endregion - - #region Private Methods - #region FormatOCT - private static string FormatOct(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - - if (IsNumericType(Value)) - { - w = Convert.ToString(UnboxToLong(Value, true), 8); - - if (Left2Right || Padding == ' ') - { - if (Alternate && w != "0") - w = "0" + w; - w = String.Format(lengthFormat, w); - } - else - { - if (FieldLength != int.MinValue) - w = w.PadLeft(FieldLength - (Alternate && w != "0" ? 1 : 0), Padding); - if (Alternate && w != "0") - w = "0" + w; - } - } - - return w; - } - #endregion - #region FormatHEX - private static string FormatHex(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? - FieldPrecision.ToString() : - String.Empty) + "}"; - - if (IsNumericType(Value)) - { - w = String.Format(numberFormat, Value); - - if (Left2Right || Padding == ' ') - { - if (Alternate) - w = (NativeFormat == "x" ? "0x" : "0X") + w; - w = String.Format(lengthFormat, w); - } - else - { - if (FieldLength != int.MinValue) - w = w.PadLeft(FieldLength - (Alternate ? 2 : 0), Padding); - if (Alternate) - w = (NativeFormat == "x" ? "0x" : "0X") + w; - } - } - - return w; - } - #endregion - #region FormatNumber - private static string FormatNumber(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - bool PositiveSign, bool PositiveSpace, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? - FieldPrecision.ToString() : - "0") + "}"; - - if (IsNumericType(Value)) - { - w = String.Format(CultureInfo.InvariantCulture, numberFormat, Value); - - if (Left2Right || Padding == ' ') - { - if (IsPositive(Value, true)) - w = (PositiveSign ? - "+" : (PositiveSpace ? " " : String.Empty)) + w; - w = String.Format(lengthFormat, w); - } - else - { - if (w.StartsWith("-")) - w = w.Substring(1); - if (FieldLength != int.MinValue) - if (PositiveSign) // xan - change here - w = w.PadLeft(FieldLength - 1, Padding); - else - w = w.PadLeft(FieldLength, Padding); - if (IsPositive(Value, true)) - w = (PositiveSign ? - "+" : "") + w; // xan - change here - else - w = "-" + w; - } - } - - return w; - } - #endregion - #endregion - } -} - - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/AnonWrapper.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/AnonWrapper.cs deleted file mode 100644 index ddee193b..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/AnonWrapper.cs +++ /dev/null @@ -1,40 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Internal type used by for registration - /// - public class AnonWrapper - { - } - - /// - /// Wrapper which allows for easier management of userdata without registering a new userdata type - useful - /// if a type which is not exposed to scripts but can be managed as a "black box" by scripts is desired. - /// - /// The type to wrap - public class AnonWrapper : AnonWrapper - { - /// - /// Initializes a new instance of the class. - /// - public AnonWrapper() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The o. - public AnonWrapper(T o) - { - Value = o; - } - - /// - /// Gets or sets the value this instance wraps. - /// - public T Value { get; set; } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/EnumerableWrapper.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/EnumerableWrapper.cs deleted file mode 100644 index 6accf2ad..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PredefinedUserData/EnumerableWrapper.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Wrappers for enumerables as return types - /// - internal class EnumerableWrapper : IUserDataType - { - IEnumerator m_Enumerator; - Script m_Script; - DynValue m_Prev = DynValue.Nil; - bool m_HasTurnOnce = false; - - private EnumerableWrapper(Script script, IEnumerator enumerator) - { - m_Script = script; - m_Enumerator = enumerator; - } - - public void Reset() - { - if (m_HasTurnOnce) - m_Enumerator.Reset(); - - m_HasTurnOnce = true; - } - - private DynValue GetNext(DynValue prev) - { - if (prev.IsNil()) - Reset(); - - while (m_Enumerator.MoveNext()) - { - DynValue v = ClrToScriptConversions.ObjectToDynValue(m_Script, m_Enumerator.Current); - - if (!v.IsNil()) - return v; - } - - return DynValue.Nil; - } - - private DynValue LuaIteratorCallback(ScriptExecutionContext executionContext, CallbackArguments args) - { - m_Prev = this.GetNext(m_Prev); - return m_Prev; - } - - internal static DynValue ConvertIterator(Script script, IEnumerator enumerator) - { - EnumerableWrapper ei = new EnumerableWrapper(script, enumerator); - return DynValue.NewTuple(UserData.Create(ei), DynValue.Nil, DynValue.Nil); - } - - internal static DynValue ConvertTable(Table table) - { - return ConvertIterator(table.OwnerScript, table.Values.GetEnumerator()); - } - - - public DynValue Index(Script script, DynValue index, bool isDirectIndexing) - { - if (index.Type == DataType.String) - { - string idx = index.String; - - if (idx == "Current" || idx == "current") - { - return DynValue.FromObject(script, m_Enumerator.Current); - } - else if (idx == "MoveNext" || idx == "moveNext" || idx == "move_next") - { - return DynValue.NewCallback((ctx, args) => DynValue.NewBoolean(m_Enumerator.MoveNext())); - } - else if (idx == "Reset" || idx == "reset") - { - return DynValue.NewCallback((ctx, args) => { Reset(); return DynValue.Nil; }); - } - } - return null; - } - - public bool SetIndex(Script script, DynValue index, DynValue value, bool isDirectIndexing) - { - return false; - } - - public DynValue MetaIndex(Script script, string metaname) - { - if (metaname == "__call") - return DynValue.NewCallback(LuaIteratorCallback); - else - return null; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PropertyTableAssigner.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PropertyTableAssigner.cs deleted file mode 100644 index bf87b3d6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/PropertyTableAssigner.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Utility class which may be used to set properties on an object of type T, from values contained in a Lua table. - /// Properties must be decorated with the . - /// This is a generic version of . - /// - /// The type of the object. - public class PropertyTableAssigner : IPropertyTableAssigner - { - PropertyTableAssigner m_InternalAssigner; - - /// - /// Initializes a new instance of the class. - /// - /// The expected missing properties, that is expected fields in the table with no corresponding property in the object. - public PropertyTableAssigner(params string[] expectedMissingProperties) - { - m_InternalAssigner = new PropertyTableAssigner(typeof(T), expectedMissingProperties); - } - - /// - /// Adds an expected missing property, that is an expected field in the table with no corresponding property in the object. - /// - /// The name. - public void AddExpectedMissingProperty(string name) - { - m_InternalAssigner.AddExpectedMissingProperty(name); - } - - /// - /// Assigns properties from tables to an object. - /// - /// The object. - /// The table. - /// Object is null - /// A field does not correspond to any property and that property is not one of the expected missing ones. - public void AssignObject(T obj, Table data) - { - m_InternalAssigner.AssignObject(obj, data); - } - - /// - /// Gets the type-unsafe assigner corresponding to this object. - /// - /// - public PropertyTableAssigner GetTypeUnsafeAssigner() - { - return m_InternalAssigner; - } - - /// - /// Sets the subassigner for the given type. Pass null to remove usage of subassigner for the given type. - /// - /// Type of the property for which the subassigner will be used. - /// The property assigner. - public void SetSubassignerForType(Type propertyType, IPropertyTableAssigner assigner) - { - m_InternalAssigner.SetSubassignerForType(propertyType, assigner); - } - - /// - /// Sets the subassigner for the given type - /// - /// Type of the property for which the subassigner will be used. - /// The property assigner. - public void SetSubassigner(PropertyTableAssigner assigner) - { - m_InternalAssigner.SetSubassignerForType(typeof(SubassignerType), assigner); - } - - - /// - /// Assigns the properties of the specified object without checking the type. - /// - /// The object. - /// The data. - void IPropertyTableAssigner.AssignObjectUnchecked(object o, Table data) - { - AssignObject((T)o, data); - } - } - - - /// - /// Utility class which may be used to set properties on an object from values contained in a Lua table. - /// Properties must be decorated with the . - /// See for a generic compile time type-safe version. - /// - public class PropertyTableAssigner : IPropertyTableAssigner - { - Type m_Type; - Dictionary m_PropertyMap = new Dictionary(); - Dictionary m_SubAssigners = new Dictionary(); - - /// - /// Initializes a new instance of the class. - /// - /// The type of the object. - /// The expected missing properties, that is expected fields in the table with no corresponding property in the object. - /// - /// Type cannot be a value type. - /// - public PropertyTableAssigner(Type type, params string[] expectedMissingProperties) - { - m_Type = type; - - if (Framework.Do.IsValueType(m_Type)) - throw new ArgumentException("Type cannot be a value type."); - - foreach(string property in expectedMissingProperties) - { - m_PropertyMap.Add(property, null); - } - - foreach (PropertyInfo pi in Framework.Do.GetProperties(m_Type)) - { - foreach (MoonSharpPropertyAttribute attr in pi.GetCustomAttributes(true).OfType()) - { - string name = attr.Name ?? pi.Name; - - if (m_PropertyMap.ContainsKey(name)) - { - throw new ArgumentException(string.Format("Type {0} has two definitions for MoonSharp property {1}", m_Type.FullName, name)); - } - else - { - m_PropertyMap.Add(name, pi); - } - } - } - - } - - /// - /// Adds an expected missing property, that is an expected field in the table with no corresponding property in the object. - /// - /// The name. - public void AddExpectedMissingProperty(string name) - { - m_PropertyMap.Add(name, null); - } - - - private bool TryAssignProperty(object obj, string name, DynValue value) - { - if (m_PropertyMap.ContainsKey(name)) - { - PropertyInfo pi = m_PropertyMap[name]; - - if (pi != null) - { - object o; - - if (value.Type == DataType.Table && m_SubAssigners.ContainsKey(pi.PropertyType)) - { - var subassigner = m_SubAssigners[pi.PropertyType]; - o = Activator.CreateInstance(pi.PropertyType); - subassigner.AssignObjectUnchecked(o, value.Table); - } - else - { - o = Interop.Converters.ScriptToClrConversions.DynValueToObjectOfType(value, - pi.PropertyType, null, false); - } - - Framework.Do.GetSetMethod(pi).Invoke(obj, new object[] { o }); - } - - return true; - } - - return false; - } - - private void AssignProperty(object obj, string name, DynValue value) - { - if (TryAssignProperty(obj, name, value)) return; - if ((Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.UpperFirstLetter) == FuzzySymbolMatchingBehavior.UpperFirstLetter && TryAssignProperty(obj, DescriptorHelpers.UpperFirstLetter(name), value)) return; - if ((Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.Camelify) == FuzzySymbolMatchingBehavior.Camelify && TryAssignProperty(obj, DescriptorHelpers.Camelify(name), value)) return; - if ((Script.GlobalOptions.FuzzySymbolMatching & FuzzySymbolMatchingBehavior.PascalCase) == FuzzySymbolMatchingBehavior.PascalCase && TryAssignProperty(obj, DescriptorHelpers.UpperFirstLetter(DescriptorHelpers.Camelify(name)), value)) return; - - throw new ScriptRuntimeException("Invalid property {0}", name); - } - - /// - /// Assigns properties from tables to an object. - /// - /// The object. - /// The table. - /// Object is null - /// The object is of an incompatible type. - /// A field does not correspond to any property and that property is not one of the expected missing ones. - public void AssignObject(object obj, Table data) - { - if (obj == null) - throw new ArgumentNullException("Object is null"); - - if (!Framework.Do.IsInstanceOfType(m_Type, obj)) - throw new ArgumentException(string.Format("Invalid type of object : got '{0}', expected {1}", obj.GetType().FullName, m_Type.FullName)); - - foreach (var pair in data.Pairs) - { - if (pair.Key.Type != DataType.String) - { - throw new ScriptRuntimeException("Invalid property of type {0}", pair.Key.Type.ToErrorTypeString()); - } - - AssignProperty(obj, pair.Key.String, pair.Value); - } - } - - /// - /// Sets the subassigner for the given type. Pass null to remove usage of subassigner for the given type. - /// - /// Type of the property for which the subassigner will be used. - /// The property assigner. - public void SetSubassignerForType(Type propertyType, IPropertyTableAssigner assigner) - { - if ( Framework.Do.IsAbstract(propertyType) - || Framework.Do.IsGenericType(propertyType) - || Framework.Do.IsInterface(propertyType) - || Framework.Do.IsValueType(propertyType)) - { - throw new ArgumentException("propertyType must be a concrete, reference type"); - } - - m_SubAssigners[propertyType] = assigner; - } - - /// - /// Assigns the properties of the specified object without checking the type. - /// - /// The object. - /// The data. - void IPropertyTableAssigner.AssignObjectUnchecked(object obj, Table data) - { - this.AssignObject(obj, data); - } - } - - /// - /// Common interface for property assigners - basically used for sub-assigners - /// - public interface IPropertyTableAssigner - { - /// - /// Assigns the properties of the specified object without checking the type. - /// - /// The object. - /// The data. - void AssignObjectUnchecked(object o, Table data); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/DelegateProxyFactory.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/DelegateProxyFactory.cs deleted file mode 100644 index fb8614b9..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/DelegateProxyFactory.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Implementation of IProxyFactory taking two delegates for simple instancing of proxies. - /// - /// The type of the proxy. - /// The type of the target. - public class DelegateProxyFactory : IProxyFactory - where TProxy : class - where TTarget : class - { - Func wrapDelegate; - - /// - /// Initializes a new instance of the class. - /// - /// The proxy. - /// The deproxy. - public DelegateProxyFactory(Func wrapDelegate) - { - this.wrapDelegate = wrapDelegate; - } - - /// - /// Takes an instance of a target object and returns a proxy object wrapping it - /// - public TProxy CreateProxyObject(TTarget target) - { - return wrapDelegate(target); - } - - /// - /// Takes an instance of a target object and returns a proxy object wrapping it - /// - /// - /// - public object CreateProxyObject(object o) - { - return CreateProxyObject((TTarget)o); - } - - /// - /// Gets the proxied type - /// - /// - public Type TargetType - { - get { return typeof(TTarget); } - } - - /// - /// Gets the proxy type - /// - public Type ProxyType - { - get { return typeof(TProxy); } - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/IProxyFactory.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/IProxyFactory.cs deleted file mode 100644 index 822353a0..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ProxyObjects/IProxyFactory.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Interface for proxy objects (type unsafe version) - /// - public interface IProxyFactory - { - /// - /// Takes an instance of a target object and returns a proxy object wrapping it - /// - object CreateProxyObject(object o); - /// - /// Gets the proxied type - /// - Type TargetType { get; } - /// - /// Gets the proxy type - /// - Type ProxyType { get; } - } - - /// - /// Interface for proxy objects (type safe version) - /// - /// The type of the proxy. - /// The type of the target. - public interface IProxyFactory : IProxyFactory - where TProxy : class - where TTarget : class - { - /// - /// Takes an instance of a target object and returns a proxy object wrapping it - /// - TProxy CreateProxyObject(TTarget target); - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ReflectionSpecialNames.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ReflectionSpecialNames.cs deleted file mode 100644 index 0501f2d3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/ReflectionSpecialNames.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System.Linq; - -namespace MoonSharp.Interpreter.Interop -{ - - /// - /// Helps identifying a reflection special name - /// - public enum ReflectionSpecialNameType - { - IndexGetter, - IndexSetter, - ImplicitCast, - ExplicitCast, - - OperatorTrue, - OperatorFalse, - - PropertyGetter, - PropertySetter, - AddEvent, - RemoveEvent, - - OperatorAdd, - OperatorAnd, - OperatorOr, - OperatorDec, - OperatorDiv, - OperatorEq, - OperatorXor, - OperatorGt, - OperatorGte, - OperatorInc, - OperatorNeq, - OperatorLt, - OperatorLte, - OperatorNot, - OperatorMod, - OperatorMul, - OperatorCompl, - OperatorSub, - OperatorNeg, - OperatorUnaryPlus, - } - - /// - /// Class helping identifying special names found with reflection - /// - public struct ReflectionSpecialName - { - public ReflectionSpecialNameType Type { get; private set; } - public string Argument { get; private set; } - - public ReflectionSpecialName(ReflectionSpecialNameType type, string argument = null) - : this() - { - Type = type; - Argument = argument; - } - - public ReflectionSpecialName(string name) - : this() - { - if (name.Contains(".")) - { - string[] split = name.Split('.'); - name = split[split.Length - 1]; - } - - switch (name) - { - case "op_Explicit": - Type = ReflectionSpecialNameType.ExplicitCast; - return; - case "op_Implicit": - Type = ReflectionSpecialNameType.ImplicitCast; - return; - case "set_Item": - Type = ReflectionSpecialNameType.IndexSetter; - return; - case "get_Item": - Type = ReflectionSpecialNameType.IndexGetter; - return; - case "op_Addition": - Type = ReflectionSpecialNameType.OperatorAdd; - Argument = "+"; - return; - case "op_BitwiseAnd": - Type = ReflectionSpecialNameType.OperatorAnd; - Argument = "&"; - return; - case "op_BitwiseOr": - Type = ReflectionSpecialNameType.OperatorOr; - Argument = "|"; - return; - case "op_Decrement": - Type = ReflectionSpecialNameType.OperatorDec; - Argument = "--"; - return; - case "op_Division": - Type = ReflectionSpecialNameType.OperatorDiv; - Argument = "/"; - return; - case "op_Equality": - Type = ReflectionSpecialNameType.OperatorEq; - Argument = "=="; - return; - case "op_ExclusiveOr": - Type = ReflectionSpecialNameType.OperatorXor; - Argument = "^"; - return; - case "op_False": - Type = ReflectionSpecialNameType.OperatorFalse; - return; - case "op_GreaterThan": - Type = ReflectionSpecialNameType.OperatorGt; - Argument = ">"; - return; - case "op_GreaterThanOrEqual": - Type = ReflectionSpecialNameType.OperatorGte; - Argument = ">="; - return; - case "op_Increment": - Type = ReflectionSpecialNameType.OperatorInc; - Argument = "++"; - return; - case "op_Inequality": - Type = ReflectionSpecialNameType.OperatorNeq; - Argument = "!="; - return; - case "op_LessThan": - Type = ReflectionSpecialNameType.OperatorLt; - Argument = "<"; - return; - case "op_LessThanOrEqual": - Type = ReflectionSpecialNameType.OperatorLte; - Argument = "<="; - return; - case "op_LogicalNot": - Type = ReflectionSpecialNameType.OperatorNot; - Argument = "!"; - return; - case "op_Modulus": - Type = ReflectionSpecialNameType.OperatorMod; - Argument = "%"; - return; - case "op_Multiply": - Type = ReflectionSpecialNameType.OperatorMul; - Argument = "*"; - return; - case "op_OnesComplement": - Type = ReflectionSpecialNameType.OperatorCompl; - Argument = "~"; - return; - case "op_Subtraction": - Type = ReflectionSpecialNameType.OperatorSub; - Argument = "-"; - return; - case "op_True": - Type = ReflectionSpecialNameType.OperatorTrue; - return; - case "op_UnaryNegation": - Type = ReflectionSpecialNameType.OperatorNeg; - Argument = "-"; - return; - case "op_UnaryPlus": - Type = ReflectionSpecialNameType.OperatorUnaryPlus; - Argument = "+"; - return; - } - - if (name.StartsWith("get_")) - { - Type = ReflectionSpecialNameType.PropertyGetter; - Argument = name.Substring(4); - } - else if (name.StartsWith("set_")) - { - Type = ReflectionSpecialNameType.PropertySetter; - Argument = name.Substring(4); - } - else if (name.StartsWith("add_")) - { - Type = ReflectionSpecialNameType.AddEvent; - Argument = name.Substring(4); - } - else if (name.StartsWith("remove_")) - { - Type = ReflectionSpecialNameType.RemoveEvent; - Argument = name.Substring(7); - } - } - } -} - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/AutomaticRegistrationPolicy.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/AutomaticRegistrationPolicy.cs deleted file mode 100644 index f9eb982d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/AutomaticRegistrationPolicy.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop.RegistrationPolicies -{ - /// - /// Similar to , but with automatic type registration is disabled. - /// - public class AutomaticRegistrationPolicy : DefaultRegistrationPolicy - { - /// - /// Allows type automatic registration for the specified type. - /// NOTE: automatic type registration is NOT recommended. - /// - /// The type. - /// - /// True to register the type automatically, false otherwise. - /// - public override bool AllowTypeAutoRegistration(Type type) - { - return true; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/DefaultRegistrationPolicy.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/DefaultRegistrationPolicy.cs deleted file mode 100644 index 4d7328ae..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/DefaultRegistrationPolicy.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors; - -namespace MoonSharp.Interpreter.Interop.RegistrationPolicies -{ - /// - /// The default registration policy used by MoonSharp unless explicitely replaced. - /// Deregistrations are allowed, but registration of a new descriptor are not allowed - /// if a descriptor is already registered for that type. - /// - /// Automatic type registration is disabled. - /// - public class DefaultRegistrationPolicy : IRegistrationPolicy - { - /// - /// Called to handle the registration or deregistration of a type descriptor. Must return the type descriptor to be registered, or null to remove the registration. - /// - /// The new descriptor, or null if this is a deregistration. - /// The old descriptor, or null if no descriptor was previously registered for this type. - /// - public IUserDataDescriptor HandleRegistration(IUserDataDescriptor newDescriptor, IUserDataDescriptor oldDescriptor) - { - if (newDescriptor == null) - return null; - else - return oldDescriptor ?? newDescriptor; - } - - /// - /// Allows type automatic registration for the specified type. - /// NOTE: automatic type registration is NOT recommended. - /// - /// The type. - /// - /// True to register the type automatically, false otherwise. - /// - public virtual bool AllowTypeAutoRegistration(Type type) - { - return false; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/IRegistrationPolicy.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/IRegistrationPolicy.cs deleted file mode 100644 index d4cdf8e5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/IRegistrationPolicy.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop.RegistrationPolicies -{ - /// - /// Interface for managing how to handle - /// - public interface IRegistrationPolicy - { - /// - /// Called to handle the registration or deregistration of a type descriptor. Must return the type descriptor to be registered, or null to remove the registration. - /// - /// The new descriptor, or null if this is a deregistration. - /// The old descriptor, or null if no descriptor was previously registered for this type. - /// - IUserDataDescriptor HandleRegistration(IUserDataDescriptor newDescriptor, IUserDataDescriptor oldDescriptor); - - /// - /// Allows type automatic registration for the specified type. - /// NOTE: automatic type registration is NOT recommended. - /// - /// The type. - /// True to register the type automatically, false otherwise. - bool AllowTypeAutoRegistration(Type type); - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/PermanentRegistrationPolicy.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/PermanentRegistrationPolicy.cs deleted file mode 100644 index 7d984b3d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/RegistrationPolicies/PermanentRegistrationPolicy.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Interop.RegistrationPolicies -{ - /// - /// A registration policy which makes registration permanent and not deletable. - /// Deregistrations are not allowed and registrations of a new descriptor are not allowed - /// if a descriptor is already registered for that type. - /// - public class PermanentRegistrationPolicy : IRegistrationPolicy - { - /// - /// Called to handle the registration or deregistration of a type descriptor. Must return the type descriptor to be registered, or null to remove the registration. - /// - /// The new descriptor, or null if this is a deregistration. - /// The old descriptor, or null if no descriptor was previously registered for this type. - /// - public IUserDataDescriptor HandleRegistration(IUserDataDescriptor newDescriptor, IUserDataDescriptor oldDescriptor) - { - return oldDescriptor ?? newDescriptor; - } - - - /// - /// Allows type automatic registration for the specified type. - /// NOTE: automatic type registration is NOT recommended. - /// - /// The type. - /// - /// True to register the type automatically, false otherwise. - /// - /// - public bool AllowTypeAutoRegistration(Type type) - { - return false; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs deleted file mode 100644 index c9392485..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop; - -namespace MoonSharp.Interpreter -{ - /// - /// Descriptor which acts as a non-containing adapter from IUserDataType to IUserDataDescriptor - /// - internal class AutoDescribingUserDataDescriptor : IUserDataDescriptor - { - private string m_FriendlyName; - private Type m_Type; - - /// - /// Initializes a new instance of the class. - /// - /// The type. - /// Name of the friendly. - public AutoDescribingUserDataDescriptor(Type type, string friendlyName) - { - m_FriendlyName = friendlyName; - m_Type = type; - } - - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - public string Name - { - get { return m_FriendlyName; } - } - - /// - /// Gets the type this descriptor refers to - /// - public Type Type - { - get { return m_Type; } - } - - /// - /// Performs an "index" "get" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing) - { - IUserDataType u = obj as IUserDataType; - - if (u != null) - return u.Index(script, index, isDirectIndexing); - - return null; - } - - /// - /// Performs an "index" "set" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing) - { - IUserDataType u = obj as IUserDataType; - - if (u != null) - return u.SetIndex(script, index, value, isDirectIndexing); - - return false; - } - - /// - /// Converts this userdata to string - /// - /// The object. - /// - public string AsString(object obj) - { - if (obj != null) - return obj.ToString(); - else - return null; - } - - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// These standard metamethods can be supported (the return value should be a function accepting the - /// classic parameters of the corresponding metamethod): - /// __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - /// __pairs, __ipairs, __iterator, __call - /// These standard metamethods are supported through other calls for efficiency: - /// __index, __newindex, __tostring - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The name of the metamember. - /// - public DynValue MetaIndex(Script script, object obj, string metaname) - { - IUserDataType u = obj as IUserDataType; - - if (u != null) - return u.MetaIndex(script, metaname); - - return null; - } - - - /// - /// Determines whether the specified object is compatible with the specified type. - /// Unless a very specific behaviour is needed, the correct implementation is a - /// simple " return type.IsInstanceOfType(obj); " - /// - /// The type. - /// The object. - /// - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs deleted file mode 100644 index a7e1a528..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// A user data descriptor which aggregates multiple descriptors and tries dispatching members - /// on them, in order. - /// - /// Used, for example, for objects implementing multiple interfaces but for which no descriptor is - /// specifically registered. - /// - public class CompositeUserDataDescriptor : IUserDataDescriptor - { - private List m_Descriptors; - private Type m_Type; - - /// - /// Initializes a new instance of the class. - /// - /// The descriptors. - /// The type. - public CompositeUserDataDescriptor(List descriptors, Type type) - { - m_Descriptors = descriptors; - m_Type = type; - } - - /// - /// Gets the descriptors aggregated by this object, allowing changes to the descriptor list - /// - public IList Descriptors - { - get { return m_Descriptors; } - } - - - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - public string Name - { - get { return "^" + m_Type.FullName; } - } - - /// - /// Gets the type this descriptor refers to - /// - public Type Type - { - get { return m_Type; } - } - - /// - /// Performs an "index" "get" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public DynValue Index(Script script, object obj, DynValue index, bool isNameIndex) - { - foreach (IUserDataDescriptor dd in m_Descriptors) - { - DynValue v = dd.Index(script, obj, index, isNameIndex); - - if (v != null) - return v; - } - return null; - } - - /// - /// Performs an "index" "set" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isNameIndex) - { - foreach (IUserDataDescriptor dd in m_Descriptors) - { - if (dd.SetIndex(script, obj, index, value, isNameIndex)) - return true; - } - return false; - } - - /// - /// Converts this userdata to string - /// - /// The object. - /// - public string AsString(object obj) - { - return (obj != null) ? obj.ToString() : null; - } - - - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// These standard metamethods can be supported (the return value should be a function accepting the - /// classic parameters of the corresponding metamethod): - /// __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - /// __pairs, __ipairs, __iterator, __call - /// These standard metamethods are supported through other calls for efficiency: - /// __index, __newindex, __tostring - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The name of the metamember. - /// - public DynValue MetaIndex(Script script, object obj, string metaname) - { - foreach (IUserDataDescriptor dd in m_Descriptors) - { - DynValue v = dd.MetaIndex(script, obj, metaname); - - if (v != null) - return v; - } - return null; - } - - - /// - /// Determines whether the specified object is compatible with the specified type. - /// Unless a very specific behaviour is needed, the correct implementation is a - /// simple " return type.IsInstanceOfType(obj); " - /// - /// The type. - /// The object. - /// - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/EventFacade.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/EventFacade.cs deleted file mode 100644 index 6b9d98b8..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/EventFacade.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Interop.StandardDescriptors -{ - internal class EventFacade : IUserDataType - { - Func m_AddCallback; - Func m_RemoveCallback; - object m_Object; - - public EventFacade(EventMemberDescriptor parent, object obj) - { - m_Object = obj; - m_AddCallback = parent.AddCallback; - m_RemoveCallback = parent.RemoveCallback; - } - - public EventFacade(Func addCallback, Func removeCallback, object obj) - { - m_Object = obj; - m_AddCallback = addCallback; - m_RemoveCallback = removeCallback; - } - - public DynValue Index(Script script, DynValue index, bool isDirectIndexing) - { - if (index.Type == DataType.String) - { - if (index.String == "add") - return DynValue.NewCallback((c, a) => m_AddCallback(m_Object, c, a)); - else if (index.String == "remove") - return DynValue.NewCallback((c, a) => m_RemoveCallback(m_Object, c, a)); - } - - throw new ScriptRuntimeException("Events only support add and remove methods"); - } - - public bool SetIndex(Script script, DynValue index, DynValue value, bool isDirectIndexing) - { - throw new ScriptRuntimeException("Events do not have settable fields"); - } - - public DynValue MetaIndex(Script script, string metaname) - { - return null; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/DefaultValue.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/DefaultValue.cs deleted file mode 100644 index 55fbbac2..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/DefaultValue.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors -{ - public sealed class DefaultValue - { - public static readonly DefaultValue Instance = new DefaultValue(); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMemberDescriptor.cs deleted file mode 100644 index 6ebf7363..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMemberDescriptor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors -{ - public abstract class HardwiredMemberDescriptor : IMemberDescriptor - { - public Type MemberType { get; private set; } - - protected HardwiredMemberDescriptor(Type memberType, string name, bool isStatic, MemberDescriptorAccess access) - { - IsStatic = isStatic; - Name = name; - MemberAccess = access; - MemberType = memberType; - } - - public bool IsStatic { get; private set; } - - public string Name { get; private set; } - - public MemberDescriptorAccess MemberAccess { get; private set; } - - - public DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - object result = GetValueImpl(script, obj); - return ClrToScriptConversions.ObjectToDynValue(script, result); - } - - public void SetValue(Script script, object obj, DynValue value) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - object v = ScriptToClrConversions.DynValueToObjectOfType(value, MemberType, null, false); - SetValueImpl(script, obj, v); - } - - - protected virtual object GetValueImpl(Script script, object obj) - { - throw new InvalidOperationException("GetValue on write-only hardwired descriptor " + Name); - } - - protected virtual void SetValueImpl(Script script, object obj, object value) - { - throw new InvalidOperationException("SetValue on read-only hardwired descriptor " + Name); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMethodMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMethodMemberDescriptor.cs deleted file mode 100644 index bcbf0c52..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredMethodMemberDescriptor.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors -{ - public abstract class HardwiredMethodMemberDescriptor : FunctionMemberDescriptorBase - { - public override DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args) - { - this.CheckAccess(MemberDescriptorAccess.CanExecute, obj); - - List outParams = null; - object[] pars = base.BuildArgumentList(script, obj, context, args, out outParams); - object retv = Invoke(script, obj, pars, CalcArgsCount(pars)); - - return DynValue.FromObject(script, retv); - } - - private int CalcArgsCount(object[] pars) - { - int count = pars.Length; - - for(int i = 0; i < pars.Length; i++) - if (Parameters[i].HasDefaultValue && (pars[i] is DefaultValue)) - { - count -= 1; - } - - return count; - } - - protected abstract object Invoke(Script script, object obj, object[] pars, int argscount); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredUserDataDescriptor.cs deleted file mode 100644 index 3555f9bb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/HardwiredDescriptors/HardwiredUserDataDescriptor.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors -{ - public abstract class HardwiredUserDataDescriptor : DispatchingUserDataDescriptor - { - protected HardwiredUserDataDescriptor(Type T) : - base(T, "::hardwired::" + T.Name) - { - - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ArrayMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ArrayMemberDescriptor.cs deleted file mode 100644 index 0e9f4c09..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ArrayMemberDescriptor.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Member descriptor for indexer of array types - /// - public class ArrayMemberDescriptor : ObjectCallbackMemberDescriptor, IWireableDescriptor - { - bool m_IsSetter; - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// if set to true is a setter indexer. - /// The indexer parameters. - public ArrayMemberDescriptor(string name, bool isSetter, ParameterDescriptor[] indexerParams) - : base( - name, - isSetter ? (Func)ArrayIndexerSet : (Func)ArrayIndexerGet, - indexerParams) - { - m_IsSetter = isSetter; - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// if set to true [is setter]. - public ArrayMemberDescriptor(string name, bool isSetter) - : base( - name, - isSetter ? (Func)ArrayIndexerSet : (Func)ArrayIndexerGet) - { - m_IsSetter = isSetter; - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("name", DynValue.NewString(Name)); - t.Set("setter", DynValue.NewBoolean(m_IsSetter)); - - if (this.Parameters != null) - { - var pars = DynValue.NewPrimeTable(); - - t.Set("params", pars); - - int i = 0; - - foreach (var p in Parameters) - { - DynValue pt = DynValue.NewPrimeTable(); - pars.Table.Set(++i, pt); - p.PrepareForWiring(pt.Table); - } - } - } - - private static int[] BuildArrayIndices(CallbackArguments args, int count) - { - int[] indices = new int[count]; - - for (int i = 0; i < count; i++) - indices[i] = args.AsInt(i, "userdata_array_indexer"); - - return indices; - } - - private static object ArrayIndexerSet(object arrayObj, ScriptExecutionContext ctx, CallbackArguments args) - { - Array array = (Array)arrayObj; - int[] indices = BuildArrayIndices(args, args.Count - 1); - DynValue value = args[args.Count - 1]; - - Type elemType = array.GetType().GetElementType(); - - object objValue = ScriptToClrConversions.DynValueToObjectOfType(value, elemType, null, false); - - array.SetValue(objValue, indices); - - return DynValue.Void; - } - - - private static object ArrayIndexerGet(object arrayObj, ScriptExecutionContext ctx, CallbackArguments args) - { - Array array = (Array)arrayObj; - int[] indices = BuildArrayIndices(args, args.Count); - - return array.GetValue(indices); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs deleted file mode 100644 index a12f7fd0..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/DynValueMemberDescriptor.cs +++ /dev/null @@ -1,155 +0,0 @@ -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing a simple descriptor for constant DynValues in userdata - /// - public class DynValueMemberDescriptor : IMemberDescriptor, IWireableDescriptor - { - private DynValue m_Value; - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// A string containing a table whose first member is the dynvalue to be deserialized (convoluted...). - protected DynValueMemberDescriptor(string name, string serializedTableValue) - { - Script s = new Script(); - var exp = s.CreateDynamicExpression(serializedTableValue); - DynValue val = exp.Evaluate(null); - - m_Value = val.Table.Get(1); - Name = name; - MemberAccess = MemberDescriptorAccess.CanRead; - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - protected DynValueMemberDescriptor(string name) - { - MemberAccess = MemberDescriptorAccess.CanRead; - m_Value = null; - Name = name; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The value. - public DynValueMemberDescriptor(string name, DynValue value) - { - m_Value = value; - Name = name; - - if (value.Type == DataType.ClrFunction) - MemberAccess = MemberDescriptorAccess.CanRead | MemberDescriptorAccess.CanExecute; - else - MemberAccess = MemberDescriptorAccess.CanRead; - } - - /// - /// Gets a value indicating whether the described member is static. - /// - public bool IsStatic { get { return true; } } - /// - /// Gets the name of the member - /// - public string Name { get; private set; } - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess { get; private set; } - - - /// - /// Gets the value wrapped by this descriptor - /// - public virtual DynValue Value - { - get - { - return m_Value; - } - } - - /// - /// Gets the value of this member as a to be exposed to scripts. - /// - /// The script. - /// The object owning this member, or null if static. - /// - /// The value of this member as a . - /// - public DynValue GetValue(Script script, object obj) - { - return Value; - } - - /// - /// Sets the value of this member from a . - /// - /// The script. - /// The object owning this member, or null if static. - /// The value to be set. - /// userdata '{0}' cannot be written to. - public void SetValue(Script script, object obj, DynValue value) - { - throw new ScriptRuntimeException("userdata '{0}' cannot be written to.", this.Name); - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("name", DynValue.NewString(this.Name)); - - switch (Value.Type) - { - case DataType.Nil: - case DataType.Void: - case DataType.Boolean: - case DataType.Number: - case DataType.String: - case DataType.Tuple: - t.Set("value", Value); - break; - case DataType.Table: - if (Value.Table.OwnerScript == null) - { - t.Set("value", Value); - } - else - { - t.Set("error", DynValue.NewString("Wiring of non-prime table value members not supported.")); - } - - break; - case DataType.UserData: - if (Value.UserData.Object == null) - { - t.Set("type", DynValue.NewString("userdata")); - t.Set("staticType", DynValue.NewString(Value.UserData.Descriptor.Type.FullName)); - t.Set("visibility", DynValue.NewString(Value.UserData.Descriptor.Type.GetClrVisibility())); - } - else - { - t.Set("error", DynValue.NewString("Wiring of non-static userdata value members not supported.")); - } - break; - default: - t.Set("error", DynValue.NewString(string.Format("Wiring of '{0}' value members not supported.", Value.Type.ToErrorTypeString()))); - break; - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs deleted file mode 100644 index 74af1b11..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs +++ /dev/null @@ -1,306 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of CLR functions - /// - public abstract class FunctionMemberDescriptorBase : IOverloadableMemberDescriptor - { - /// - /// Gets a value indicating whether the described method is static. - /// - public bool IsStatic { get; private set; } - /// - /// Gets the name of the described method - /// - public string Name { get; private set; } - /// - /// Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - /// - public string SortDiscriminant { get; private set; } - /// - /// Gets the type of the arguments of the underlying CLR function - /// - public ParameterDescriptor[] Parameters { get; private set; } - /// - /// Gets the type which this extension method extends, null if this is not an extension method. - /// - public Type ExtensionMethodType { get; private set; } - /// - /// Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - public Type VarArgsArrayType { get; private set; } - /// - /// Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - public Type VarArgsElementType { get; private set; } - - /// - /// Initializes this instance. - /// This *MUST* be called by the constructors extending this class to complete initialization. - /// - /// Name of the function. - /// if set to true [is static]. - /// The parameters. - /// if set to true [is extension method]. - protected void Initialize(string funcName, bool isStatic, ParameterDescriptor[] parameters, bool isExtensionMethod) - { - this.Name = funcName; - this.IsStatic = isStatic; - this.Parameters = parameters; - - if (isExtensionMethod) - this.ExtensionMethodType = Parameters[0].Type; - - if (Parameters.Length > 0 && Parameters[Parameters.Length - 1].IsVarArgs) - { - VarArgsArrayType = Parameters[Parameters.Length - 1].Type; - VarArgsElementType = Parameters[Parameters.Length - 1].Type.GetElementType(); - } - - SortDiscriminant = string.Join(":", Parameters.Select(pi => pi.Type.FullName).ToArray()); - } - - - - /// - /// Gets a callback function as a delegate - /// - /// The script for which the callback must be generated. - /// The object (null for static). - /// - public Func GetCallback(Script script, object obj = null) - { - return (c, a) => Execute(script, obj, c, a); - } - - /// - /// Gets the callback function. - /// - /// The script for which the callback must be generated. - /// The object (null for static). - /// - public CallbackFunction GetCallbackFunction(Script script, object obj = null) - { - return new CallbackFunction(GetCallback(script, obj), this.Name); - } - - /// - /// Gets the callback function as a DynValue. - /// - /// The script for which the callback must be generated. - /// The object (null for static). - /// - public DynValue GetCallbackAsDynValue(Script script, object obj = null) - { - return DynValue.NewCallback(this.GetCallbackFunction(script, obj)); - } - - /// - /// Creates a callback DynValue starting from a MethodInfo. - /// - /// The script. - /// The mi. - /// The object. - /// - public static DynValue CreateCallbackDynValue(Script script, MethodInfo mi, object obj = null) - { - var desc = new MethodMemberDescriptor(mi); - return desc.GetCallbackAsDynValue(script, obj); - } - - - /// - /// Builds the argument list. - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// Output: A list containing the indices of all "out" parameters, or null if no out parameters are specified. - /// The arguments, appropriately converted. - protected virtual object[] BuildArgumentList(Script script, object obj, ScriptExecutionContext context, CallbackArguments args, - out List outParams) - { - ParameterDescriptor[] parameters = Parameters; - - object[] pars = new object[parameters.Length]; - - int j = args.IsMethodCall ? 1 : 0; - - outParams = null; - - for (int i = 0; i < pars.Length; i++) - { - // keep track of out and ref params - if (parameters[i].Type.IsByRef) - { - if (outParams == null) outParams = new List(); - outParams.Add(i); - } - - // if an ext method, we have an obj -> fill the first param - if (ExtensionMethodType != null && obj != null && i == 0) - { - pars[i] = obj; - continue; - } - // else, fill types with a supported type - else if (parameters[i].Type == typeof(Script)) - { - pars[i] = script; - } - else if (parameters[i].Type == typeof(ScriptExecutionContext)) - { - pars[i] = context; - } - else if (parameters[i].Type == typeof(CallbackArguments)) - { - pars[i] = args.SkipMethodCall(); - } - // else, ignore out params - else if (parameters[i].IsOut) - { - pars[i] = null; - } - else if (i == parameters.Length - 1 && VarArgsArrayType != null) - { - List extraArgs = new List(); - - while (true) - { - DynValue arg = args.RawGet(j, false); - j += 1; - if (arg != null) - extraArgs.Add(arg); - else - break; - } - - // here we have to worry we already have an array.. damn. We only support this for userdata. - // remains to be analyzed what's the correct behavior here. For example, let's take a params object[].. - // given a single table parameter, should it use it as an array or as an object itself ? - if (extraArgs.Count == 1) - { - DynValue arg = extraArgs[0]; - - if (arg.Type == DataType.UserData && arg.UserData.Object != null) - { - if (Framework.Do.IsAssignableFrom(VarArgsArrayType, arg.UserData.Object.GetType())) - { - pars[i] = arg.UserData.Object; - continue; - } - } - } - - // ok let's create an array, and loop - Array vararg = Array.CreateInstance(VarArgsElementType, extraArgs.Count); - - for (int ii = 0; ii < extraArgs.Count; ii++) - { - vararg.SetValue(ScriptToClrConversions.DynValueToObjectOfType(extraArgs[ii], VarArgsElementType, - null, false), ii); - } - - pars[i] = vararg; - - } - // else, convert it - else - { - var arg = args.RawGet(j, false) ?? DynValue.Void; - pars[i] = ScriptToClrConversions.DynValueToObjectOfType(arg, parameters[i].Type, - parameters[i].DefaultValue, parameters[i].HasDefaultValue); - j += 1; - } - } - - return pars; - } - - /// - /// Builds the return value of a call - /// - /// The script. - /// The out parameters indices, or null. See . - /// The parameters passed to the function. - /// The return value from the function. Use DynValue.Void if the function returned no value. - /// A DynValue to be returned to scripts - protected static DynValue BuildReturnValue(Script script, List outParams, object[] pars, object retv) - { - if (outParams == null) - { - return ClrToScriptConversions.ObjectToDynValue(script, retv); - } - else - { - DynValue[] rets = new DynValue[outParams.Count + 1]; - - if (retv is DynValue && ((DynValue)retv).IsVoid()) - rets[0] = DynValue.Nil; - else - rets[0] = ClrToScriptConversions.ObjectToDynValue(script, retv); - - for (int i = 0; i < outParams.Count; i++) - rets[i + 1] = ClrToScriptConversions.ObjectToDynValue(script, pars[outParams[i]]); - - return DynValue.NewTuple(rets); - } - } - - /// - /// The internal callback which actually executes the method - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - public abstract DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args); - - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get { return MemberDescriptorAccess.CanRead | MemberDescriptorAccess.CanExecute; } - } - - /// - /// Gets the value of this member as a to be exposed to scripts. - /// - /// The script. - /// The object owning this member, or null if static. - /// - /// The value of this member as a . - /// - public virtual DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - return this.GetCallbackAsDynValue(script, obj); - } - - /// - /// Sets the value. - /// - /// The script. - /// The object. - /// The v. - /// - public virtual void SetValue(Script script, object obj, DynValue v) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ObjectCallbackMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ObjectCallbackMemberDescriptor.cs deleted file mode 100644 index 0fa3f834..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/MemberDescriptors/ObjectCallbackMemberDescriptor.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Member descriptor which allows to define new members which behave similarly to class instance members - /// - public class ObjectCallbackMemberDescriptor : FunctionMemberDescriptorBase - { - Func m_CallbackFunc; - - - /// - /// Initializes a new instance of the class. - /// A new member descriptor is defined, which is a function taking no parameters and returning void, doing nothing. - /// - /// Name of the function. - public ObjectCallbackMemberDescriptor(string funcName) - : this(funcName, (o, c, a) => DynValue.Void, new ParameterDescriptor[0]) - { } - - - /// - /// Initializes a new instance of the class. - /// The function described by descriptors created by this callback are defined as if they take no parameters - /// and thus don't support overload resolution well (unless they really take no parameters) but can freely be - /// used if no overload resolution is required. - /// - /// Name of the function. - /// The callback function. - public ObjectCallbackMemberDescriptor(string funcName, Func callBack) - : this(funcName, callBack, new ParameterDescriptor[0]) - { - } - - /// - /// Initializes a new instance of the class. - /// Members defined with this constructor will support overload resolution. - /// - /// Name of the function. - /// The call back. - /// The parameters. - public ObjectCallbackMemberDescriptor(string funcName, Func callBack, ParameterDescriptor[] parameters) - { - m_CallbackFunc = callBack; - Initialize(funcName, false, parameters, false); - } - - /// - /// The internal callback which actually executes the method - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - public override DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args) - { - if (m_CallbackFunc != null) - { - object retv = m_CallbackFunc(obj, context, args); - return ClrToScriptConversions.ObjectToDynValue(script, retv); - } - else - { - return DynValue.Void; - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs deleted file mode 100644 index 8485bc60..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Data descriptor used for proxy objects - /// - public sealed class ProxyUserDataDescriptor : IUserDataDescriptor - { - IUserDataDescriptor m_ProxyDescriptor; - IProxyFactory m_ProxyFactory; - - internal ProxyUserDataDescriptor(IProxyFactory proxyFactory, IUserDataDescriptor proxyDescriptor, string friendlyName = null) - { - m_ProxyFactory = proxyFactory; - Name = friendlyName ?? (proxyFactory.TargetType.Name + "::proxy"); - m_ProxyDescriptor = proxyDescriptor; - } - - /// - /// Gets the descriptor which describes the proxy object - /// - public IUserDataDescriptor InnerDescriptor - { - get { return m_ProxyDescriptor; } - } - - /// - /// Gets the name of the descriptor (usually, the name of the type described). - /// - public string Name - { - get; - private set; - } - - /// - /// Gets the type this descriptor refers to - /// - public Type Type - { - get { return m_ProxyFactory.TargetType; } - } - - /// - /// Proxies the specified object. - /// - /// The object. - /// - private object Proxy(object obj) - { - return obj != null ? m_ProxyFactory.CreateProxyObject(obj) : null; - } - - /// - /// Performs an "index" "get" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing) - { - return m_ProxyDescriptor.Index(script, Proxy(obj), index, isDirectIndexing); - } - - /// - /// Performs an "index" "set" operation. - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The index. - /// The value to be set - /// If set to true, it's indexed with a name, if false it's indexed through brackets. - /// - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing) - { - return m_ProxyDescriptor.SetIndex(script, Proxy(obj), index, value, isDirectIndexing); - } - - /// - /// Converts this userdata to string - /// - /// The object. - /// - public string AsString(object obj) - { - return m_ProxyDescriptor.AsString(Proxy(obj)); - } - - /// - /// Gets a "meta" operation on this userdata. If a descriptor does not support this functionality, - /// it should return "null" (not a nil). - /// These standard metamethods can be supported (the return value should be a function accepting the - /// classic parameters of the corresponding metamethod): - /// __add, __sub, __mul, __div, __div, __pow, __unm, __eq, __lt, __le, __lt, __len, __concat, - /// __pairs, __ipairs, __iterator, __call - /// These standard metamethods are supported through other calls for efficiency: - /// __index, __newindex, __tostring - /// - /// The script originating the request - /// The object (null if a static request is done) - /// The name of the metamember. - /// - public DynValue MetaIndex(Script script, object obj, string metaname) - { - return m_ProxyDescriptor.MetaIndex(script, Proxy(obj), metaname); - } - - /// - /// Determines whether the specified object is compatible with the specified type. - /// Unless a very specific behaviour is needed, the correct implementation is a - /// simple " return type.IsInstanceOfType(obj); " - /// - /// The type. - /// The object. - /// - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs deleted file mode 100755 index 3a19cbe5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs +++ /dev/null @@ -1,338 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.DataStructs; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.StandardDescriptors; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of CLR events. Handling is limited to a narrow range of handler signatures, which, - /// however, covers in practice most of all available events. - /// - public class EventMemberDescriptor : IMemberDescriptor - { - /// - /// The maximum number of arguments supported in an event handler delegate - /// - public const int MAX_ARGS_IN_DELEGATE = 16; - - - object m_Lock = new object(); - MultiDictionary m_Callbacks = new MultiDictionary(new ReferenceEqualityComparer()); - Dictionary m_Delegates = new Dictionary(new ReferenceEqualityComparer()); - - /// - /// Tries to create a new StandardUserDataEventDescriptor, returning null in case the method is not - /// visible to script code. - /// - /// The EventInfo. - /// The - /// A new StandardUserDataEventDescriptor or null. - public static EventMemberDescriptor TryCreateIfVisible(EventInfo ei, InteropAccessMode accessMode) - { - if (!CheckEventIsCompatible(ei, false)) - return null; - - MethodInfo addm = Framework.Do.GetAddMethod(ei); - MethodInfo remm = Framework.Do.GetRemoveMethod(ei); - - if (ei.GetVisibilityFromAttributes() ?? ((remm != null && remm.IsPublic) && (addm != null && addm.IsPublic))) - return new EventMemberDescriptor(ei, accessMode); - - return null; - } - - - /// - /// Checks if the event is compatible with a standard descriptor - /// - /// The EventInfo. - /// if set to true an exception with the proper error message is thrown if not compatible. - /// - /// - /// Thrown if throwException is true and one of this applies: - /// The event is declared in a value type - /// or - /// The event does not have both add and remove methods - /// or - /// The event handler type doesn't implement a public Invoke method - /// or - /// The event handler has a return type which is not System.Void - /// or - /// The event handler has more than MAX_ARGS_IN_DELEGATE parameters - /// or - /// The event handler has a value type parameter or a by ref parameter - /// or - /// The event handler signature is not a valid method according to - /// - public static bool CheckEventIsCompatible(EventInfo ei, bool throwException) - { - if (Framework.Do.IsValueType(ei.DeclaringType)) - { - if (throwException) throw new ArgumentException("Events are not supported on value types"); - return false; - } - - if ((Framework.Do.GetAddMethod(ei) == null) || (Framework.Do.GetRemoveMethod(ei) == null)) - { - if (throwException) throw new ArgumentException("Event must have add and remove methods"); - return false; - } - - MethodInfo invoke = Framework.Do.GetMethod(ei.EventHandlerType, "Invoke"); - - if (invoke == null) - { - if (throwException) throw new ArgumentException("Event handler type doesn't seem to be a delegate"); - return false; - } - - if (!MethodMemberDescriptor.CheckMethodIsCompatible(invoke, throwException)) - return false; - - if (invoke.ReturnType != typeof(void)) - { - if (throwException) throw new ArgumentException("Event handler cannot have a return type"); - return false; - } - - ParameterInfo[] pars = invoke.GetParameters(); - - if (pars.Length > MAX_ARGS_IN_DELEGATE) - { - if (throwException) throw new ArgumentException(string.Format("Event handler cannot have more than {0} parameters", MAX_ARGS_IN_DELEGATE)); - return false; - } - - foreach (ParameterInfo pi in pars) - { - if (Framework.Do.IsValueType(pi.ParameterType)) - { - if (throwException) throw new ArgumentException("Event handler cannot have value type parameters"); - return false; - } - else if (pi.ParameterType.IsByRef) - { - if (throwException) throw new ArgumentException("Event handler cannot have by-ref type parameters"); - return false; - } - } - - return true; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The ei. - /// The access mode. - public EventMemberDescriptor(EventInfo ei, InteropAccessMode accessMode = InteropAccessMode.Default) - { - CheckEventIsCompatible(ei, true); - EventInfo = ei; - m_Add = Framework.Do.GetAddMethod(ei); - m_Remove = Framework.Do.GetRemoveMethod(ei); - IsStatic = m_Add.IsStatic; - } - - - - /// - /// Gets the EventInfo object of the event described by this descriptor - /// - public EventInfo EventInfo { get; private set; } - /// - /// Gets a value indicating whether the event described by this descriptor is static. - /// - public bool IsStatic { get; private set; } - - private MethodInfo m_Add, m_Remove; - - /// - /// Gets a dynvalue which is a facade supporting add/remove methods which is callable from scripts - /// - /// The script. - /// The object for which the facade should be written. - /// - public DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - - if (IsStatic) - obj = this; - - return UserData.Create(new EventFacade(this, obj)); - } - - - internal DynValue AddCallback(object o, ScriptExecutionContext context, CallbackArguments args) - { - lock (m_Lock) - { - Closure closure = args.AsType(0, string.Format("userdata<{0}>.{1}.add", EventInfo.DeclaringType, EventInfo.Name), - DataType.Function, false).Function; - - if (m_Callbacks.Add(o, closure)) - RegisterCallback(o); - - return DynValue.Void; - } - } - - internal DynValue RemoveCallback(object o, ScriptExecutionContext context, CallbackArguments args) - { - lock (m_Lock) - { - Closure closure = args.AsType(0, string.Format("userdata<{0}>.{1}.remove", EventInfo.DeclaringType, EventInfo.Name), - DataType.Function, false).Function; - - if (m_Callbacks.RemoveValue(o, closure)) - UnregisterCallback(o); - - return DynValue.Void; - } - } - - private void RegisterCallback(object o) - { - m_Delegates.GetOrCreate(o, () => - { - Delegate d = CreateDelegate(o); -#if NETFX_CORE - Delegate handler = d.GetMethodInfo().CreateDelegate(EventInfo.EventHandlerType, d.Target); -#else - Delegate handler = Delegate.CreateDelegate(EventInfo.EventHandlerType, d.Target, d.Method); -#endif - m_Add.Invoke(o, new object[] { handler }); - return handler; - }); - } - - private void UnregisterCallback(object o) - { - Delegate handler = m_Delegates.GetOrDefault(o); - - if (handler == null) - throw new InternalErrorException("can't unregister null delegate"); - - m_Delegates.Remove(o); - m_Remove.Invoke(o, new object[] { handler }); - } - - - private Delegate CreateDelegate(object sender) - { - switch (Framework.Do.GetMethod(EventInfo.EventHandlerType, "Invoke").GetParameters().Length) - { - case 0: - return (EventWrapper00)(() => DispatchEvent(sender)); - case 1: - return (EventWrapper01)((o1) => DispatchEvent(sender, o1)); - case 2: - return (EventWrapper02)((o1, o2) => DispatchEvent(sender, o1, o2)); - case 3: - return (EventWrapper03)((o1, o2, o3) => DispatchEvent(sender, o1, o2, o3)); - case 4: - return (EventWrapper04)((o1, o2, o3, o4) => DispatchEvent(sender, o1, o2, o3, o4)); - case 5: - return (EventWrapper05)((o1, o2, o3, o4, o5) => DispatchEvent(sender, o1, o2, o3, o4, o5)); - case 6: - return (EventWrapper06)((o1, o2, o3, o4, o5, o6) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6)); - case 7: - return (EventWrapper07)((o1, o2, o3, o4, o5, o6, o7) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7)); - case 8: - return (EventWrapper08)((o1, o2, o3, o4, o5, o6, o7, o8) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8)); - case 9: - return (EventWrapper09)((o1, o2, o3, o4, o5, o6, o7, o8, o9) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9)); - case 10: - return (EventWrapper10)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10)); - case 11: - return (EventWrapper11)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11)); - case 12: - return (EventWrapper12)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12)); - case 13: - return (EventWrapper13)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13)); - case 14: - return (EventWrapper14)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14)); - case 15: - return (EventWrapper15)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15)); - case 16: - return (EventWrapper16)((o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16) => DispatchEvent(sender, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16)); - default: - throw new InternalErrorException("too many args in delegate type"); - } - } - - private void DispatchEvent(object sender, - object o01 = null, object o02 = null, object o03 = null, object o04 = null, - object o05 = null, object o06 = null, object o07 = null, object o08 = null, - object o09 = null, object o10 = null, object o11 = null, object o12 = null, - object o13 = null, object o14 = null, object o15 = null, object o16 = null) - { - Closure[] closures = null; - lock (m_Lock) - { - closures = m_Callbacks.Find(sender).ToArray(); - } - - foreach (Closure c in closures) - { - c.Call(o01, o02, o03, o04, o05, o06, o07, o08, o09, o10, o11, o12, o13, o14, o15, o16); - } - } - - private delegate void EventWrapper00(); - private delegate void EventWrapper01(object o1); - private delegate void EventWrapper02(object o1, object o2); - private delegate void EventWrapper03(object o1, object o2, object o3); - private delegate void EventWrapper04(object o1, object o2, object o3, object o4); - private delegate void EventWrapper05(object o1, object o2, object o3, object o4, object o5); - private delegate void EventWrapper06(object o1, object o2, object o3, object o4, object o5, object o6); - private delegate void EventWrapper07(object o1, object o2, object o3, object o4, object o5, object o6, object o7); - private delegate void EventWrapper08(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8); - private delegate void EventWrapper09(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9); - private delegate void EventWrapper10(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10); - private delegate void EventWrapper11(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11); - private delegate void EventWrapper12(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11, object o12); - private delegate void EventWrapper13(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11, object o12, object o13); - private delegate void EventWrapper14(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11, object o12, object o13, object o14); - private delegate void EventWrapper15(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11, object o12, object o13, object o14, object o15); - private delegate void EventWrapper16(object o1, object o2, object o3, object o4, object o5, object o6, object o7, object o8, object o9, object o10, object o11, object o12, object o13, object o14, object o15, object o16); - - - /// - /// Gets the name of the member - /// - public string Name - { - get { return this.EventInfo.Name; } - } - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get { return MemberDescriptorAccess.CanRead; } - } - - /// - /// Sets the value. - /// - /// The script. - /// The object. - /// The v. - public void SetValue(Script script, object obj, DynValue v) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - } - - } -} - - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs deleted file mode 100755 index 9b08de21..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System; -using System.Linq.Expressions; -using System.Reflection; -using System.Threading; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Diagnostics; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of CLR fields - /// - public class FieldMemberDescriptor : IMemberDescriptor, IOptimizableDescriptor, IWireableDescriptor - { - /// - /// Gets the FieldInfo got by reflection - /// - public FieldInfo FieldInfo { get; private set; } - /// - /// Gets the - /// - public InteropAccessMode AccessMode { get; private set; } - /// - /// Gets a value indicating whether the described property is static. - /// - public bool IsStatic { get; private set; } - /// - /// Gets the name of the property - /// - public string Name { get; private set; } - /// - /// Gets a value indicating whether this instance is a constant - /// - public bool IsConst { get; private set; } - /// - /// Gets a value indicating whether this instance is readonly - /// - public bool IsReadonly { get; private set; } - - - object m_ConstValue = null; - - Func m_OptimizedGetter = null; - - - /// - /// Tries to create a new StandardUserDataFieldDescriptor, returning null in case the field is not - /// visible to script code. - /// - /// The FieldInfo. - /// The - /// A new StandardUserDataFieldDescriptor or null. - public static FieldMemberDescriptor TryCreateIfVisible(FieldInfo fi, InteropAccessMode accessMode) - { - if (fi.GetVisibilityFromAttributes() ?? fi.IsPublic) - return new FieldMemberDescriptor(fi, accessMode); - - return null; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The FieldInfo. - /// The - public FieldMemberDescriptor(FieldInfo fi, InteropAccessMode accessMode) - { - if (Script.GlobalOptions.Platform.IsRunningOnAOT()) - accessMode = InteropAccessMode.Reflection; - - this.FieldInfo = fi; - this.AccessMode = accessMode; - this.Name = fi.Name; - this.IsStatic = this.FieldInfo.IsStatic; - - if (this.FieldInfo.IsLiteral) - { - IsConst = true; - m_ConstValue = FieldInfo.GetValue(null); - } - else - { - IsReadonly = this.FieldInfo.IsInitOnly; - } - - if (AccessMode == InteropAccessMode.Preoptimized) - { - this.OptimizeGetter(); - } - } - - - /// - /// Gets the value of the property - /// - /// The script. - /// The object. - /// - public DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - - // optimization+workaround of Unity bug.. - if (IsConst) - return ClrToScriptConversions.ObjectToDynValue(script, m_ConstValue); - - if (AccessMode == InteropAccessMode.LazyOptimized && m_OptimizedGetter == null) - OptimizeGetter(); - - object result = null; - - if (m_OptimizedGetter != null) - result = m_OptimizedGetter(obj); - else - result = FieldInfo.GetValue(obj); - - return ClrToScriptConversions.ObjectToDynValue(script, result); - } - - internal void OptimizeGetter() - { - if (this.IsConst) - return; - - using (PerformanceStatistics.StartGlobalStopwatch(PerformanceCounter.AdaptersCompilation)) - { - if (IsStatic) - { - var paramExp = Expression.Parameter(typeof(object), "dummy"); - var propAccess = Expression.Field(null, FieldInfo); - var castPropAccess = Expression.Convert(propAccess, typeof(object)); - var lambda = Expression.Lambda>(castPropAccess, paramExp); - Interlocked.Exchange(ref m_OptimizedGetter, lambda.Compile()); - } - else - { - var paramExp = Expression.Parameter(typeof(object), "obj"); - var castParamExp = Expression.Convert(paramExp, this.FieldInfo.DeclaringType); - var propAccess = Expression.Field(castParamExp, FieldInfo); - var castPropAccess = Expression.Convert(propAccess, typeof(object)); - var lambda = Expression.Lambda>(castPropAccess, paramExp); - Interlocked.Exchange(ref m_OptimizedGetter, lambda.Compile()); - } - } - } - - /// - /// Sets the value of the property - /// - /// The script. - /// The object. - /// The value to set. - public void SetValue(Script script, object obj, DynValue v) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - - if (IsReadonly || IsConst) - throw new ScriptRuntimeException("userdata field '{0}.{1}' cannot be written to.", this.FieldInfo.DeclaringType.Name, this.Name); - - object value = ScriptToClrConversions.DynValueToObjectOfType(v, this.FieldInfo.FieldType, null, false); - - try - { - if (value is double) - value = NumericConversions.DoubleToType(FieldInfo.FieldType, (double)value); - - FieldInfo.SetValue(IsStatic ? null : obj, value); - } - catch (ArgumentException) - { - // non-optimized setters fall here - throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType); - } - catch (InvalidCastException) - { - // optimized setters fall here - throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType); - } -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) - catch (FieldAccessException ex) - { - throw new ScriptRuntimeException(ex); - } -#endif - } - - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get - { - if (IsReadonly || IsConst) - return MemberDescriptorAccess.CanRead; - else - return MemberDescriptorAccess.CanRead | MemberDescriptorAccess.CanWrite; - } - } - - void IOptimizableDescriptor.Optimize() - { - if (m_OptimizedGetter == null) - this.OptimizeGetter(); - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("visibility", DynValue.NewString(this.FieldInfo.GetClrVisibility())); - - t.Set("name", DynValue.NewString(this.Name)); - t.Set("static", DynValue.NewBoolean(this.IsStatic)); - t.Set("const", DynValue.NewBoolean(this.IsConst)); - t.Set("readonly", DynValue.NewBoolean(this.IsReadonly)); - t.Set("decltype", DynValue.NewString(this.FieldInfo.DeclaringType.FullName)); - t.Set("declvtype", DynValue.NewBoolean(Framework.Do.IsValueType(this.FieldInfo.DeclaringType))); - t.Set("type", DynValue.NewString(this.FieldInfo.FieldType.FullName)); - t.Set("read", DynValue.NewBoolean(true)); - t.Set("write", DynValue.NewBoolean(!(this.IsConst || this.IsReadonly))); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs deleted file mode 100644 index f9280ba7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs +++ /dev/null @@ -1,319 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Diagnostics; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of CLR functions - /// - public class MethodMemberDescriptor : FunctionMemberDescriptorBase, IOptimizableDescriptor, IWireableDescriptor - { - /// - /// Gets the method information (can be a MethodInfo or ConstructorInfo) - /// - public MethodBase MethodInfo { get; private set; } - /// - /// Gets the access mode used for interop - /// - public InteropAccessMode AccessMode { get; private set; } - /// - /// Gets a value indicating whether the described method is a constructor - /// - public bool IsConstructor { get; private set; } - - - private Func m_OptimizedFunc = null; - private Action m_OptimizedAction = null; - private bool m_IsAction = false; - private bool m_IsArrayCtor = false; - - /// - /// Initializes a new instance of the class. - /// - /// The MethodBase (MethodInfo or ConstructorInfo) got through reflection. - /// The interop access mode. - /// Invalid accessMode - public MethodMemberDescriptor(MethodBase methodBase, InteropAccessMode accessMode = InteropAccessMode.Default) - { - CheckMethodIsCompatible(methodBase, true); - - IsConstructor = (methodBase is ConstructorInfo); - this.MethodInfo = methodBase; - - bool isStatic = methodBase.IsStatic || IsConstructor; - - if (IsConstructor) - m_IsAction = false; - else - m_IsAction = ((MethodInfo)methodBase).ReturnType == typeof(void); - - ParameterInfo[] reflectionParams = methodBase.GetParameters(); - ParameterDescriptor[] parameters; - - if (this.MethodInfo.DeclaringType.IsArray) - { - m_IsArrayCtor = true; - - int rank = this.MethodInfo.DeclaringType.GetArrayRank(); - - parameters = new ParameterDescriptor[rank]; - - for (int i = 0; i < rank; i++) - parameters[i] = new ParameterDescriptor("idx" + i.ToString(), typeof(int)); - } - else - { - parameters = reflectionParams.Select(pi => new ParameterDescriptor(pi)).ToArray(); - } - - - bool isExtensionMethod = (methodBase.IsStatic && parameters.Length > 0 && methodBase.GetCustomAttributes(typeof(ExtensionAttribute), false).Any()); - - base.Initialize(methodBase.Name, isStatic, parameters, isExtensionMethod); - - // adjust access mode - if (Script.GlobalOptions.Platform.IsRunningOnAOT()) - accessMode = InteropAccessMode.Reflection; - - if (accessMode == InteropAccessMode.Default) - accessMode = UserData.DefaultAccessMode; - - if (accessMode == InteropAccessMode.HideMembers) - throw new ArgumentException("Invalid accessMode"); - - if (parameters.Any(p => p.Type.IsByRef)) - accessMode = InteropAccessMode.Reflection; - - this.AccessMode = accessMode; - - if (AccessMode == InteropAccessMode.Preoptimized) - ((IOptimizableDescriptor)this).Optimize(); - } - - /// - /// Tries to create a new MethodMemberDescriptor, returning - /// null in case the method is not - /// visible to script code. - /// - /// The MethodBase. - /// The - /// if set to true forces visibility. - /// - /// A new MethodMemberDescriptor or null. - /// - public static MethodMemberDescriptor TryCreateIfVisible(MethodBase methodBase, InteropAccessMode accessMode, bool forceVisibility = false) - { - if (!CheckMethodIsCompatible(methodBase, false)) - return null; - - if (forceVisibility || (methodBase.GetVisibilityFromAttributes() ?? methodBase.IsPublic)) - return new MethodMemberDescriptor(methodBase, accessMode); - - return null; - } - - /// - /// Checks if the method is compatible with a standard descriptor - /// - /// The MethodBase. - /// if set to true an exception with the proper error message is thrown if not compatible. - /// - /// - /// Thrown if throwException is true and one of this applies: - /// The method contains unresolved generic parameters, or has an unresolved generic return type - /// or - /// The method contains pointer parameters, or has a pointer return type - /// - public static bool CheckMethodIsCompatible(MethodBase methodBase, bool throwException) - { - if (methodBase.ContainsGenericParameters) - { - if (throwException) throw new ArgumentException("Method cannot contain unresolved generic parameters"); - return false; - } - - if (methodBase.GetParameters().Any(p => p.ParameterType.IsPointer)) - { - if (throwException) throw new ArgumentException("Method cannot contain pointer parameters"); - return false; - } - - MethodInfo mi = methodBase as MethodInfo; - - if (mi != null) - { - if (mi.ReturnType.IsPointer) - { - if (throwException) throw new ArgumentException("Method cannot have a pointer return type"); - return false; - } - - if (Framework.Do.IsGenericTypeDefinition(mi.ReturnType)) - { - if (throwException) throw new ArgumentException("Method cannot have an unresolved generic return type"); - return false; - } - } - - return true; - } - - /// - /// The internal callback which actually executes the method - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - public override DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args) - { - this.CheckAccess(MemberDescriptorAccess.CanExecute, obj); - - if (AccessMode == InteropAccessMode.LazyOptimized && - m_OptimizedFunc == null && m_OptimizedAction == null) - ((IOptimizableDescriptor)this).Optimize(); - - List outParams = null; - object[] pars = base.BuildArgumentList(script, obj, context, args, out outParams); - object retv = null; - - if (m_OptimizedFunc != null) - { - retv = m_OptimizedFunc(obj, pars); - } - else if (m_OptimizedAction != null) - { - m_OptimizedAction(obj, pars); - retv = DynValue.Void; - } - else if (m_IsAction) - { - MethodInfo.Invoke(obj, pars); - retv = DynValue.Void; - } - else - { - if (IsConstructor) - retv = ((ConstructorInfo)MethodInfo).Invoke(pars); - else - retv = MethodInfo.Invoke(obj, pars); - } - - return BuildReturnValue(script, outParams, pars, retv); - } - - /// - /// Called by standard descriptors when background optimization or preoptimization needs to be performed. - /// - /// Out/Ref params cannot be precompiled. - void IOptimizableDescriptor.Optimize() - { - ParameterDescriptor[] parameters = Parameters; - - if (AccessMode == InteropAccessMode.Reflection) - return; - - MethodInfo methodInfo = this.MethodInfo as MethodInfo; - - if (methodInfo == null) - return; - - using (PerformanceStatistics.StartGlobalStopwatch(PerformanceCounter.AdaptersCompilation)) - { - var ep = Expression.Parameter(typeof(object[]), "pars"); - var objinst = Expression.Parameter(typeof(object), "instance"); - var inst = Expression.Convert(objinst, MethodInfo.DeclaringType); - - Expression[] args = new Expression[parameters.Length]; - - for (int i = 0; i < parameters.Length; i++) - { - if (parameters[i].OriginalType.IsByRef) - { - throw new InternalErrorException("Out/Ref params cannot be precompiled."); - } - else - { - var x = Expression.ArrayIndex(ep, Expression.Constant(i)); - args[i] = Expression.Convert(x, parameters[i].OriginalType); - } - } - - Expression fn; - - if (IsStatic) - { - fn = Expression.Call(methodInfo, args); - } - else - { - fn = Expression.Call(inst, methodInfo, args); - } - - - if (this.m_IsAction) - { - var lambda = Expression.Lambda>(fn, objinst, ep); - Interlocked.Exchange(ref m_OptimizedAction, lambda.Compile()); - } - else - { - var fnc = Expression.Convert(fn, typeof(object)); - var lambda = Expression.Lambda>(fnc, objinst, ep); - Interlocked.Exchange(ref m_OptimizedFunc, lambda.Compile()); - } - } - } - - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("name", DynValue.NewString(this.Name)); - t.Set("ctor", DynValue.NewBoolean(this.IsConstructor)); - t.Set("special", DynValue.NewBoolean(this.MethodInfo.IsSpecialName)); - t.Set("visibility", DynValue.NewString(this.MethodInfo.GetClrVisibility())); - - if (this.IsConstructor) - t.Set("ret", DynValue.NewString(((ConstructorInfo)this.MethodInfo).DeclaringType.FullName)); - else - t.Set("ret", DynValue.NewString(((MethodInfo)this.MethodInfo).ReturnType.FullName)); - - if (m_IsArrayCtor) - { - t.Set("arraytype", DynValue.NewString(this.MethodInfo.DeclaringType.GetElementType().FullName)); - } - - t.Set("decltype", DynValue.NewString(this.MethodInfo.DeclaringType.FullName)); - t.Set("static", DynValue.NewBoolean(this.IsStatic)); - t.Set("extension", DynValue.NewBoolean(this.ExtensionMethodType != null)); - - var pars = DynValue.NewPrimeTable(); - - t.Set("params", pars); - - int i = 0; - - foreach (var p in Parameters) - { - DynValue pt = DynValue.NewPrimeTable(); - pars.Table.Set(++i, pt); - p.PrepareForWiring(pt.Table); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs deleted file mode 100644 index c1ad734c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs +++ /dev/null @@ -1,520 +0,0 @@ -//#define DEBUG_OVERLOAD_RESOLVER - -using System; -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of overloaded CLR functions - /// - public class OverloadedMethodMemberDescriptor : IOptimizableDescriptor, IMemberDescriptor, IWireableDescriptor - { - /// - /// Comparer class for IOverloadableMemberDescriptor - /// - private class OverloadableMemberDescriptorComparer : IComparer - { - public int Compare(IOverloadableMemberDescriptor x, IOverloadableMemberDescriptor y) - { - return x.SortDiscriminant.CompareTo(y.SortDiscriminant); - } - } - - - const int CACHE_SIZE = 5; - - private class OverloadCacheItem - { - public bool HasObject; - public IOverloadableMemberDescriptor Method; - public List ArgsDataType; - public List ArgsUserDataType; - public int HitIndexAtLastHit; - } - - private List m_Overloads = new List(); - private List m_ExtOverloads = new List(); - private bool m_Unsorted = true; - private OverloadCacheItem[] m_Cache = new OverloadCacheItem[CACHE_SIZE]; - private int m_CacheHits = 0; - private int m_ExtensionMethodVersion = 0; - - /// - /// Gets or sets a value indicating whether this instance ignores extension methods. - /// - public bool IgnoreExtensionMethods { get; set; } - - - /// - /// Initializes a new instance of the class. - /// - public OverloadedMethodMemberDescriptor(string name, Type declaringType) - { - Name = name; - DeclaringType = declaringType; - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The declaring type. - /// The descriptor of the first overloaded method. - public OverloadedMethodMemberDescriptor(string name, Type declaringType, IOverloadableMemberDescriptor descriptor) - : this(name, declaringType) - { - m_Overloads.Add(descriptor); - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The declaring type. - /// The descriptors of the overloaded methods. - public OverloadedMethodMemberDescriptor(string name, Type declaringType, IEnumerable descriptors) - : this(name, declaringType) - { - m_Overloads.AddRange(descriptors); - } - - /// - /// Sets the extension methods snapshot. - /// - /// The version. - /// The ext methods. - internal void SetExtensionMethodsSnapshot(int version, List extMethods) - { - m_ExtOverloads = extMethods; - m_ExtensionMethodVersion = version; - } - - - - /// - /// Gets the name of the first described overload - /// - public string Name - { - get; - private set; - } - - /// - /// Gets the name of the first described overload - /// - public Type DeclaringType - { - get; - private set; - } - - /// - /// Adds an overload. - /// - /// The overload. - public void AddOverload(IOverloadableMemberDescriptor overload) - { - m_Overloads.Add(overload); - m_Unsorted = true; - } - - /// - /// Gets the number of overloaded methods contained in this collection - /// - /// - /// The overload count. - /// - public int OverloadCount - { - get { return m_Overloads.Count; } - } - - /// - /// Performs the overloaded call. - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - /// function call doesn't match any overload - private DynValue PerformOverloadedCall(Script script, object obj, ScriptExecutionContext context, CallbackArguments args) - { - bool extMethodCacheNotExpired = IgnoreExtensionMethods || (obj == null) || m_ExtensionMethodVersion == UserData.GetExtensionMethodsChangeVersion(); - - // common case, let's optimize for it - if (m_Overloads.Count == 1 && m_ExtOverloads.Count == 0 && extMethodCacheNotExpired) - return m_Overloads[0].Execute(script, obj, context, args); - - if (m_Unsorted) - { - m_Overloads.Sort(new OverloadableMemberDescriptorComparer()); - m_Unsorted = false; - } - - if (extMethodCacheNotExpired) - { - for (int i = 0; i < m_Cache.Length; i++) - { - if (m_Cache[i] != null && CheckMatch(obj != null, args, m_Cache[i])) - { -#if DEBUG_OVERLOAD_RESOLVER - System.Diagnostics.Debug.WriteLine(string.Format("[OVERLOAD] : CACHED! slot {0}, hits: {1}", i, m_CacheHits)); -#endif - return m_Cache[i].Method.Execute(script, obj, context, args); - } - } - } - - // resolve on overloads first - int maxScore = 0; - IOverloadableMemberDescriptor bestOverload = null; - - for (int i = 0; i < m_Overloads.Count; i++) - { - if (obj != null || m_Overloads[i].IsStatic) - { - int score = CalcScoreForOverload(context, args, m_Overloads[i], false); - - if (score > maxScore) - { - maxScore = score; - bestOverload = m_Overloads[i]; - } - } - } - - if (!IgnoreExtensionMethods && (obj != null)) - { - if (!extMethodCacheNotExpired) - { - m_ExtensionMethodVersion = UserData.GetExtensionMethodsChangeVersion(); - m_ExtOverloads = UserData.GetExtensionMethodsByNameAndType(this.Name, this.DeclaringType); - } - - for (int i = 0; i < m_ExtOverloads.Count; i++) - { - int score = CalcScoreForOverload(context, args, m_ExtOverloads[i], true); - - if (score > maxScore) - { - maxScore = score; - bestOverload = m_ExtOverloads[i]; - } - } - } - - - if (bestOverload != null) - { - Cache(obj != null, args, bestOverload); - return bestOverload.Execute(script, obj, context, args); - } - - throw new ScriptRuntimeException("function call doesn't match any overload"); - } - - private void Cache(bool hasObject, CallbackArguments args, IOverloadableMemberDescriptor bestOverload) - { - int lowestHits = int.MaxValue; - OverloadCacheItem found = null; - for (int i = 0; i < m_Cache.Length; i++) - { - if (m_Cache[i] == null) - { - found = new OverloadCacheItem() { ArgsDataType = new List(), ArgsUserDataType = new List() }; - m_Cache[i] = found; - break; - } - else if (m_Cache[i].HitIndexAtLastHit < lowestHits) - { - lowestHits = m_Cache[i].HitIndexAtLastHit; - found = m_Cache[i]; - } - } - - if (found == null) - { - // overflow.. - m_Cache = new OverloadCacheItem[CACHE_SIZE]; - found = new OverloadCacheItem() { ArgsDataType = new List(), ArgsUserDataType = new List() }; - m_Cache[0] = found; - m_CacheHits = 0; - } - - found.Method = bestOverload; - found.HitIndexAtLastHit = ++m_CacheHits; - found.ArgsDataType.Clear(); - found.HasObject = hasObject; - - for (int i = 0; i < args.Count; i++) - { - found.ArgsDataType.Add(args[i].Type); - - if (args[i].Type == DataType.UserData) - { - found.ArgsUserDataType.Add(args[i].UserData.Descriptor.Type); - } - else - { - found.ArgsUserDataType.Add(null); - } - } - } - - private bool CheckMatch(bool hasObject, CallbackArguments args, OverloadCacheItem overloadCacheItem) - { - if (overloadCacheItem.HasObject && !hasObject) - return false; - - if (args.Count != overloadCacheItem.ArgsDataType.Count) - return false; - - for (int i = 0; i < args.Count; i++) - { - if (args[i].Type != overloadCacheItem.ArgsDataType[i]) - return false; - - if (args[i].Type == DataType.UserData) - { - if (args[i].UserData.Descriptor.Type != overloadCacheItem.ArgsUserDataType[i]) - return false; - } - } - - overloadCacheItem.HitIndexAtLastHit = ++m_CacheHits; - return true; - } - - - /// - /// Calculates the score for the overload. - /// - /// The context. - /// The arguments. - /// The method. - /// if set to true, is an extension method. - /// - private int CalcScoreForOverload(ScriptExecutionContext context, CallbackArguments args, IOverloadableMemberDescriptor method, bool isExtMethod) - { - int totalScore = ScriptToClrConversions.WEIGHT_EXACT_MATCH; - int argsBase = args.IsMethodCall ? 1 : 0; - int argsCnt = argsBase; - bool varArgsUsed = false; - - - for (int i = 0; i < method.Parameters.Length; i++) - { - if (isExtMethod && i == 0) - continue; - - if (method.Parameters[i].IsOut) - continue; - - Type parameterType = method.Parameters[i].Type; - - if ((parameterType == typeof(Script)) || (parameterType == typeof(ScriptExecutionContext)) || (parameterType == typeof(CallbackArguments))) - continue; - - if (i == method.Parameters.Length - 1 && method.VarArgsArrayType != null) - { - int varargCnt = 0; - DynValue firstArg = null; - int scoreBeforeVargars = totalScore; - - // update score for varargs - while (true) - { - var arg = args.RawGet(argsCnt, false); - if (arg == null) break; - - if (firstArg == null) firstArg = arg; - - argsCnt += 1; - - varargCnt += 1; - - int score = CalcScoreForSingleArgument(method.Parameters[i], method.VarArgsElementType, arg, isOptional: false); - totalScore = Math.Min(totalScore, score); - } - - // check if exact-match - if (varargCnt == 1) - { - if (firstArg.Type == DataType.UserData && firstArg.UserData.Object != null) - { - if (Framework.Do.IsAssignableFrom(method.VarArgsArrayType, firstArg.UserData.Object.GetType())) - { - totalScore = scoreBeforeVargars; - continue; - } - } - } - - // apply varargs penalty to score - if (varargCnt == 0) - totalScore = Math.Min(totalScore, ScriptToClrConversions.WEIGHT_VARARGS_EMPTY); - - varArgsUsed = true; - } - else - { - var arg = args.RawGet(argsCnt, false) ?? DynValue.Void; - - int score = CalcScoreForSingleArgument(method.Parameters[i], parameterType, arg, method.Parameters[i].HasDefaultValue); - - totalScore = Math.Min(totalScore, score); - - argsCnt += 1; - } - } - - if (totalScore > 0) - { - if ((args.Count - argsBase) <= method.Parameters.Length) - { - totalScore += ScriptToClrConversions.WEIGHT_NO_EXTRA_PARAMS_BONUS; - totalScore *= 1000; - } - else if (varArgsUsed) - { - totalScore -= ScriptToClrConversions.WEIGHT_VARARGS_MALUS; - totalScore *= 1000; - } - else - { - totalScore *= 1000; - totalScore -= ScriptToClrConversions.WEIGHT_EXTRA_PARAMS_MALUS * ((args.Count - argsBase) - method.Parameters.Length); - totalScore = Math.Max(1, totalScore); - } - } - -#if DEBUG_OVERLOAD_RESOLVER - System.Diagnostics.Debug.WriteLine(string.Format("[OVERLOAD] : Score {0} for method {1}", totalScore, method.SortDiscriminant)); -#endif - return totalScore; - } - - private static int CalcScoreForSingleArgument(ParameterDescriptor desc, Type parameterType, DynValue arg, bool isOptional) - { - int score = ScriptToClrConversions.DynValueToObjectOfTypeWeight(arg, - parameterType, isOptional); - - if (parameterType.IsByRef || desc.IsOut || desc.IsRef) - score = Math.Max(0, score + ScriptToClrConversions.WEIGHT_BYREF_BONUSMALUS); - - return score; - } - - - - /// - /// Gets a callback function as a delegate - /// - /// The script for which the callback must be generated. - /// The object (null for static). - /// - public Func GetCallback(Script script, object obj) - { - return (context, args) => PerformOverloadedCall(script, obj, context, args); - } - - - void IOptimizableDescriptor.Optimize() - { - foreach (var d in m_Overloads.OfType()) - d.Optimize(); - } - - /// - /// Gets the callback function. - /// - /// The script for which the callback must be generated. - /// The object (null for static). - /// - public CallbackFunction GetCallbackFunction(Script script, object obj = null) - { - return new CallbackFunction(GetCallback(script, obj), this.Name); - } - - /// - /// Gets a value indicating whether there is at least one static method in the resolution list - /// - /// - public bool IsStatic - { - get { return m_Overloads.Any(o => o.IsStatic); } - } - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get { return MemberDescriptorAccess.CanExecute | MemberDescriptorAccess.CanRead; } - } - - /// - /// Gets the value of this member as a to be exposed to scripts. - /// - /// The script. - /// The object owning this member, or null if static. - /// - /// The value of this member as a . - /// - public DynValue GetValue(Script script, object obj) - { - return DynValue.NewCallback(this.GetCallbackFunction(script, obj)); - } - - /// - /// Sets the value of this member from a . - /// - /// The script. - /// The object owning this member, or null if static. - /// The value to be set. - /// - public void SetValue(Script script, object obj, DynValue value) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("name", DynValue.NewString(this.Name)); - t.Set("decltype", DynValue.NewString(this.DeclaringType.FullName)); - DynValue mst = DynValue.NewPrimeTable(); - t.Set("overloads", mst); - - int i = 0; - - foreach (var m in this.m_Overloads) - { - IWireableDescriptor sd = m as IWireableDescriptor; - - if (sd != null) - { - DynValue mt = DynValue.NewPrimeTable(); - mst.Table.Set(++i, mt); - sd.PrepareForWiring(mt.Table); - } - else - { - mst.Table.Set(++i, DynValue.NewString(string.Format("unsupported - {0} is not serializable", m.GetType().FullName))); - } - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs deleted file mode 100644 index 618ee3cc..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs +++ /dev/null @@ -1,310 +0,0 @@ -using System; -using System.Linq.Expressions; -using System.Reflection; -using System.Threading; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Diagnostics; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Class providing easier marshalling of CLR properties - /// - public class PropertyMemberDescriptor : IMemberDescriptor, IOptimizableDescriptor, - IWireableDescriptor - { - /// - /// Gets the PropertyInfo got by reflection - /// - public PropertyInfo PropertyInfo { get; private set; } - /// - /// Gets the - /// - public InteropAccessMode AccessMode { get; private set; } - /// - /// Gets a value indicating whether the described property is static. - /// - public bool IsStatic { get; private set; } - /// - /// Gets the name of the property - /// - public string Name { get; private set; } - /// - /// Gets a value indicating whether this instance can be read from - /// - /// - /// true if this instance can be read from; otherwise, false. - /// - public bool CanRead { get { return m_Getter != null; } } - /// - /// Gets a value indicating whether this instance can be written to. - /// - /// - /// true if this instance can be written to; otherwise, false. - /// - public bool CanWrite { get { return m_Setter != null; } } - - - private MethodInfo m_Getter, m_Setter; - Func m_OptimizedGetter = null; - Action m_OptimizedSetter = null; - - - /// - /// Tries to create a new StandardUserDataPropertyDescriptor, returning null in case the property is not - /// visible to script code. - /// - /// The PropertyInfo. - /// The - /// A new StandardUserDataPropertyDescriptor or null. - public static PropertyMemberDescriptor TryCreateIfVisible(PropertyInfo pi, InteropAccessMode accessMode) - { - MethodInfo getter = Framework.Do.GetGetMethod(pi); - MethodInfo setter = Framework.Do.GetSetMethod(pi); - - bool? pvisible = pi.GetVisibilityFromAttributes(); - bool? gvisible = getter.GetVisibilityFromAttributes(); - bool? svisible = setter.GetVisibilityFromAttributes(); - - if (pvisible.HasValue) - { - return PropertyMemberDescriptor.TryCreate(pi, accessMode, - (gvisible ?? pvisible.Value) ? getter : null, - (svisible ?? pvisible.Value) ? setter : null); - } - else - { - return PropertyMemberDescriptor.TryCreate(pi, accessMode, - (gvisible ?? getter.IsPublic) ? getter : null, - (svisible ?? setter.IsPublic) ? setter : null); - } - } - - private static PropertyMemberDescriptor TryCreate(PropertyInfo pi, InteropAccessMode accessMode, MethodInfo getter, MethodInfo setter) - { - if (getter == null && setter == null) - return null; - else - return new PropertyMemberDescriptor(pi, accessMode, getter, setter); - } - - - /// - /// Initializes a new instance of the class. - /// NOTE: This constructor gives get/set visibility based exclusively on the CLR visibility of the - /// getter and setter methods. - /// - /// The pi. - /// The access mode. - public PropertyMemberDescriptor(PropertyInfo pi, InteropAccessMode accessMode) - : this(pi, accessMode, Framework.Do.GetGetMethod(pi), Framework.Do.GetSetMethod(pi)) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The PropertyInfo. - /// The - /// The getter method. Use null to make the property writeonly. - /// The setter method. Use null to make the property readonly. - public PropertyMemberDescriptor(PropertyInfo pi, InteropAccessMode accessMode, MethodInfo getter, MethodInfo setter) - { - if (getter == null && setter == null) - throw new ArgumentNullException("getter and setter cannot both be null"); - - if (Script.GlobalOptions.Platform.IsRunningOnAOT()) - accessMode = InteropAccessMode.Reflection; - - this.PropertyInfo = pi; - this.AccessMode = accessMode; - this.Name = pi.Name; - - m_Getter = getter; - m_Setter = setter; - - this.IsStatic = (m_Getter ?? m_Setter).IsStatic; - - if (AccessMode == InteropAccessMode.Preoptimized) - { - this.OptimizeGetter(); - this.OptimizeSetter(); - } - } - - - /// - /// Gets the value of the property - /// - /// The script. - /// The object. - /// - public DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - - if (m_Getter == null) - throw new ScriptRuntimeException("userdata property '{0}.{1}' cannot be read from.", this.PropertyInfo.DeclaringType.Name, this.Name); - - if (AccessMode == InteropAccessMode.LazyOptimized && m_OptimizedGetter == null) - OptimizeGetter(); - - object result = null; - - if (m_OptimizedGetter != null) - result = m_OptimizedGetter(obj); - else - result = m_Getter.Invoke(IsStatic ? null : obj, null); // convoluted workaround for --full-aot Mono execution - - return ClrToScriptConversions.ObjectToDynValue(script, result); - } - - internal void OptimizeGetter() - { - using (PerformanceStatistics.StartGlobalStopwatch(PerformanceCounter.AdaptersCompilation)) - { - if (m_Getter != null) - { - if (IsStatic) - { - var paramExp = Expression.Parameter(typeof(object), "dummy"); - var propAccess = Expression.Property(null, PropertyInfo); - var castPropAccess = Expression.Convert(propAccess, typeof(object)); - var lambda = Expression.Lambda>(castPropAccess, paramExp); - Interlocked.Exchange(ref m_OptimizedGetter, lambda.Compile()); - } - else - { - var paramExp = Expression.Parameter(typeof(object), "obj"); - var castParamExp = Expression.Convert(paramExp, this.PropertyInfo.DeclaringType); - var propAccess = Expression.Property(castParamExp, PropertyInfo); - var castPropAccess = Expression.Convert(propAccess, typeof(object)); - var lambda = Expression.Lambda>(castPropAccess, paramExp); - Interlocked.Exchange(ref m_OptimizedGetter, lambda.Compile()); - } - } - } - } - - internal void OptimizeSetter() - { - using (PerformanceStatistics.StartGlobalStopwatch(PerformanceCounter.AdaptersCompilation)) - { - if (m_Setter != null && !(Framework.Do.IsValueType(PropertyInfo.DeclaringType))) - { - MethodInfo setterMethod = Framework.Do.GetSetMethod(PropertyInfo); - - if (IsStatic) - { - var paramExp = Expression.Parameter(typeof(object), "dummy"); - var paramValExp = Expression.Parameter(typeof(object), "val"); - var castParamValExp = Expression.Convert(paramValExp, this.PropertyInfo.PropertyType); - var callExpression = Expression.Call(setterMethod, castParamValExp); - var lambda = Expression.Lambda>(callExpression, paramExp, paramValExp); - Interlocked.Exchange(ref m_OptimizedSetter, lambda.Compile()); - } - else - { - var paramExp = Expression.Parameter(typeof(object), "obj"); - var paramValExp = Expression.Parameter(typeof(object), "val"); - var castParamExp = Expression.Convert(paramExp, this.PropertyInfo.DeclaringType); - var castParamValExp = Expression.Convert(paramValExp, this.PropertyInfo.PropertyType); - var callExpression = Expression.Call(castParamExp, setterMethod, castParamValExp); - var lambda = Expression.Lambda>(callExpression, paramExp, paramValExp); - Interlocked.Exchange(ref m_OptimizedSetter, lambda.Compile()); - } - } - } - } - - /// - /// Sets the value of the property - /// - /// The script. - /// The object. - /// The value to set. - public void SetValue(Script script, object obj, DynValue v) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - - if (m_Setter == null) - throw new ScriptRuntimeException("userdata property '{0}.{1}' cannot be written to.", this.PropertyInfo.DeclaringType.Name, this.Name); - - object value = ScriptToClrConversions.DynValueToObjectOfType(v, this.PropertyInfo.PropertyType, null, false); - - try - { - if (value is double) - value = NumericConversions.DoubleToType(PropertyInfo.PropertyType, (double)value); - - if (AccessMode == InteropAccessMode.LazyOptimized && m_OptimizedSetter == null) - OptimizeSetter(); - - if (m_OptimizedSetter != null) - { - m_OptimizedSetter(obj, value); - } - else - { - m_Setter.Invoke(IsStatic ? null : obj, new object[] { value }); // convoluted workaround for --full-aot Mono execution - } - } - catch (ArgumentException) - { - // non-optimized setters fall here - throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, PropertyInfo.PropertyType); - } - catch (InvalidCastException) - { - // optimized setters fall here - throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, PropertyInfo.PropertyType); - } - } - - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get - { - MemberDescriptorAccess access = 0; - - if (m_Setter != null) access |= MemberDescriptorAccess.CanWrite; - if (m_Getter != null) access |= MemberDescriptorAccess.CanRead; - - return access; - } - } - - /// - /// Called by standard descriptors when background optimization or preoptimization needs to be performed. - /// - void IOptimizableDescriptor.Optimize() - { - this.OptimizeGetter(); - this.OptimizeSetter(); - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("visibility", DynValue.NewString(this.PropertyInfo.GetClrVisibility())); - t.Set("name", DynValue.NewString(this.Name)); - t.Set("static", DynValue.NewBoolean(this.IsStatic)); - t.Set("read", DynValue.NewBoolean(this.CanRead)); - t.Set("write", DynValue.NewBoolean(this.CanWrite)); - t.Set("decltype", DynValue.NewString(this.PropertyInfo.DeclaringType.FullName)); - t.Set("declvtype", DynValue.NewBoolean(Framework.Do.IsValueType(this.PropertyInfo.DeclaringType))); - t.Set("type", DynValue.NewString(this.PropertyInfo.PropertyType.FullName)); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs deleted file mode 100644 index 7001eac6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Member descriptor for the default constructor of value types. - /// - public class ValueTypeDefaultCtorMemberDescriptor : IOverloadableMemberDescriptor, - IWireableDescriptor - { - /// - /// Gets a value indicating whether the described method is static. - /// - public bool IsStatic { get { return true; } } - /// - /// Gets the name of the described method - /// - public string Name { get; private set; } - - /// - /// This property is equal to the value type to be constructed. - /// - public Type ValueTypeDefaultCtor { get; private set; } - - /// - /// Gets the type of the arguments of the underlying CLR function - /// - public ParameterDescriptor[] Parameters { get; private set; } - - - /// - /// Gets the type which this extension method extends, null if this is not an extension method. - /// - public Type ExtensionMethodType - { - get { return null; } - } - - /// - /// Gets a value indicating the type of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - public Type VarArgsArrayType - { - get { return null; } - } - - /// - /// Gets a value indicating the type of the elements of the ParamArray parameter of a var-args function. If the function is not var-args, - /// null is returned. - /// - public Type VarArgsElementType - { - get { return null; } - } - - /// - /// Initializes a new instance of the - /// class - /// representing the default empty ctor for a value type. - /// - /// Type of the value. - /// valueType is not a value type - public ValueTypeDefaultCtorMemberDescriptor(Type valueType) - { - if (!Framework.Do.IsValueType(valueType)) - throw new ArgumentException("valueType is not a value type"); - - this.Name = "__new"; - this.Parameters = new ParameterDescriptor[0]; - - ValueTypeDefaultCtor = valueType; - } - - - /// - /// Invokes the member from script. - /// Implementors should raise exceptions if the value cannot be executed or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object. - /// The context. - /// The arguments. - /// - public DynValue Execute(Script script, object obj, ScriptExecutionContext context, CallbackArguments args) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - - object vto = Activator.CreateInstance(ValueTypeDefaultCtor); - return ClrToScriptConversions.ObjectToDynValue(script, vto); - } - - - /// - /// Gets a sort discriminant to give consistent overload resolution matching in case of perfectly equal scores - /// - public string SortDiscriminant - { - get { return "@.ctor"; } - } - - - /// - /// Gets the types of access supported by this member - /// - public MemberDescriptorAccess MemberAccess - { - get { return MemberDescriptorAccess.CanRead | MemberDescriptorAccess.CanExecute; } - } - - /// - /// Gets the value of this member as a - /// to be exposed to scripts. - /// Implementors should raise exceptions if the value cannot be read or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object owning this member, or null if static. - /// - /// The value of this member as a . - /// - public DynValue GetValue(Script script, object obj) - { - this.CheckAccess(MemberDescriptorAccess.CanRead, obj); - - object vto = Activator.CreateInstance(ValueTypeDefaultCtor); - return ClrToScriptConversions.ObjectToDynValue(script, vto); - } - - /// - /// Sets the value of this member from a - /// . - /// Implementors should raise exceptions if the value cannot be read or if access to an - /// instance member through a static userdata is attempted. - /// - /// The script. - /// The object owning this member, or null if static. - /// The value to be set. - public void SetValue(Script script, object obj, DynValue value) - { - this.CheckAccess(MemberDescriptorAccess.CanWrite, obj); - } - - /// - /// Prepares the descriptor for hard-wiring. - /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code. - /// - /// The table to be filled - public void PrepareForWiring(Table t) - { - t.Set("class", DynValue.NewString(this.GetType().FullName)); - t.Set("type", DynValue.NewString(this.ValueTypeDefaultCtor.FullName)); - t.Set("name", DynValue.NewString(this.Name)); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs deleted file mode 100644 index 9f8c2e20..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs +++ /dev/null @@ -1,341 +0,0 @@ -using System; -using System.Linq; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Standard descriptor for Enum values - /// - public class StandardEnumUserDataDescriptor : DispatchingUserDataDescriptor - { - /// - /// Gets the underlying type of the enum. - /// - public Type UnderlyingType { get; private set; } - /// - /// Gets a value indicating whether underlying type of the enum is unsigned. - /// - public bool IsUnsigned { get; private set; } - /// - /// Gets a value indicating whether this instance describes a flags enumeration. - /// - public bool IsFlags { get; private set; } - - Func m_EnumToULong = null; - Func m_ULongToEnum = null; - Func m_EnumToLong = null; - Func m_LongToEnum = null; - - /// - /// Initializes a new instance of the class. - /// - /// Type of the enum. - /// Name of the friendly. - /// enumType must be an enum! - public StandardEnumUserDataDescriptor(Type enumType, string friendlyName = null, - string[] names = null, object[] values = null, Type underlyingType = null) - : base(enumType, friendlyName) - { - if (!Framework.Do.IsEnum(enumType)) - throw new ArgumentException("enumType must be an enum!"); - - UnderlyingType = underlyingType ?? Enum.GetUnderlyingType(enumType); - IsUnsigned = ((UnderlyingType == typeof(byte)) || (UnderlyingType == typeof(ushort)) || (UnderlyingType == typeof(uint)) || (UnderlyingType == typeof(ulong))); - - names = names ?? Enum.GetNames(this.Type); - values = values ?? Enum.GetValues(this.Type).OfType().ToArray(); - - FillMemberList(names, values); - } - - /// - /// Fills the member list. - /// - private void FillMemberList(string[] names, object[] values) - { - - for (int i = 0; i < names.Length; i++) - { - string name = names[i]; - object value = values.GetValue(i); - DynValue cvalue = UserData.Create(value, this); - - base.AddDynValue(name, cvalue); - } - - var attrs = Framework.Do.GetCustomAttributes(this.Type, typeof(FlagsAttribute), true); - - if (attrs != null && attrs.Length > 0) - { - IsFlags = true; - - AddEnumMethod("flagsAnd", DynValue.NewCallback(Callback_And)); - AddEnumMethod("flagsOr", DynValue.NewCallback(Callback_Or)); - AddEnumMethod("flagsXor", DynValue.NewCallback(Callback_Xor)); - AddEnumMethod("flagsNot", DynValue.NewCallback(Callback_BwNot)); - AddEnumMethod("hasAll", DynValue.NewCallback(Callback_HasAll)); - AddEnumMethod("hasAny", DynValue.NewCallback(Callback_HasAny)); - } - } - - - - /// - /// Adds an enum method to the object - /// - /// The name. - /// The dyn value. - private void AddEnumMethod(string name, DynValue dynValue) - { - if (!HasMember(name)) - AddDynValue(name, dynValue); - - if (!HasMember("__" + name)) - AddDynValue("__" + name, dynValue); - } - - - /// - /// Gets the value of the enum as a long - /// - private long GetValueSigned(DynValue dv) - { - CreateSignedConversionFunctions(); - - if (dv.Type == DataType.Number) - return (long)dv.Number; - - if ((dv.Type != DataType.UserData) || (dv.UserData.Descriptor != this) || (dv.UserData.Object == null)) - throw new ScriptRuntimeException("Enum userdata or number expected, or enum is not of the correct type."); - - return m_EnumToLong(dv.UserData.Object); - } - - /// - /// Gets the value of the enum as a ulong - /// - private ulong GetValueUnsigned(DynValue dv) - { - CreateUnsignedConversionFunctions(); - - if (dv.Type == DataType.Number) - return (ulong)dv.Number; - - if ((dv.Type != DataType.UserData) || (dv.UserData.Descriptor != this) || (dv.UserData.Object == null)) - throw new ScriptRuntimeException("Enum userdata or number expected, or enum is not of the correct type."); - - return m_EnumToULong(dv.UserData.Object); - } - - /// - /// Creates an enum value from a long - /// - private DynValue CreateValueSigned(long value) - { - CreateSignedConversionFunctions(); - return UserData.Create(m_LongToEnum(value), this); - } - - /// - /// Creates an enum value from a ulong - /// - private DynValue CreateValueUnsigned(ulong value) - { - CreateUnsignedConversionFunctions(); - return UserData.Create(m_ULongToEnum(value), this); - } - - /// - /// Creates conversion functions for signed enums - /// - private void CreateSignedConversionFunctions() - { - if (m_EnumToLong == null || m_LongToEnum == null) - { - if (UnderlyingType == typeof(sbyte)) - { - m_EnumToLong = o => (long)((sbyte)o); - m_LongToEnum = o => (sbyte)(o); - } - else if (UnderlyingType == typeof(short)) - { - m_EnumToLong = o => (long)((short)o); - m_LongToEnum = o => (short)(o); - } - else if (UnderlyingType == typeof(int)) - { - m_EnumToLong = o => (long)((int)o); - m_LongToEnum = o => (int)(o); - } - else if (UnderlyingType == typeof(long)) - { - m_EnumToLong = o => (long)(o); - m_LongToEnum = o => (long)(o); - } - else throw new ScriptRuntimeException("Unexpected enum underlying type : {0}", UnderlyingType.FullName); - } - } - - /// - /// Creates conversion functions for unsigned enums - /// - private void CreateUnsignedConversionFunctions() - { - if (m_EnumToULong == null || m_ULongToEnum == null) - { - if (UnderlyingType == typeof(byte)) - { - m_EnumToULong = o => (ulong)((byte)o); - m_ULongToEnum = o => (byte)(o); - } - else if (UnderlyingType == typeof(ushort)) - { - m_EnumToULong = o => (ulong)((ushort)o); - m_ULongToEnum = o => (ushort)(o); - } - else if (UnderlyingType == typeof(uint)) - { - m_EnumToULong = o => (ulong)((uint)o); - m_ULongToEnum = o => (uint)(o); - } - else if (UnderlyingType == typeof(ulong)) - { - m_EnumToULong = o => (ulong)(o); - m_ULongToEnum = o => (ulong)(o); - } - else throw new ScriptRuntimeException("Unexpected enum underlying type : {0}", UnderlyingType.FullName); - } - } - - private DynValue PerformBinaryOperationS(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - if (args.Count != 2) - throw new ScriptRuntimeException("Enum.{0} expects two arguments", funcName); - - long v1 = GetValueSigned(args[0]); - long v2 = GetValueSigned(args[1]); - return operation(v1, v2); - } - - private DynValue PerformBinaryOperationU(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - if (args.Count != 2) - throw new ScriptRuntimeException("Enum.{0} expects two arguments", funcName); - - ulong v1 = GetValueUnsigned(args[0]); - ulong v2 = GetValueUnsigned(args[1]); - return operation(v1, v2); - } - - private DynValue PerformBinaryOperationS(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - return PerformBinaryOperationS(funcName, ctx, args, (v1, v2) => CreateValueSigned(operation(v1, v2))); - } - - private DynValue PerformBinaryOperationU(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - return PerformBinaryOperationU(funcName, ctx, args, (v1, v2) => CreateValueUnsigned(operation(v1, v2))); - } - - private DynValue PerformUnaryOperationS(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - if (args.Count != 1) - throw new ScriptRuntimeException("Enum.{0} expects one argument.", funcName); - - long v1 = GetValueSigned(args[0]); - long r = operation(v1); - return CreateValueSigned(r); - } - - private DynValue PerformUnaryOperationU(string funcName, ScriptExecutionContext ctx, CallbackArguments args, Func operation) - { - if (args.Count != 1) - throw new ScriptRuntimeException("Enum.{0} expects one argument.", funcName); - - ulong v1 = GetValueUnsigned(args[0]); - ulong r = operation(v1); - return CreateValueUnsigned(r); - } - - internal DynValue Callback_Or(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformBinaryOperationU("or", ctx, args, (v1, v2) => v1 | v2); - else - return PerformBinaryOperationS("or", ctx, args, (v1, v2) => v1 | v2); - } - - internal DynValue Callback_And(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformBinaryOperationU("and", ctx, args, (v1, v2) => v1 & v2); - else - return PerformBinaryOperationS("and", ctx, args, (v1, v2) => v1 & v2); - } - - internal DynValue Callback_Xor(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformBinaryOperationU("xor", ctx, args, (v1, v2) => v1 ^ v2); - else - return PerformBinaryOperationS("xor", ctx, args, (v1, v2) => v1 ^ v2); - } - - internal DynValue Callback_BwNot(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformUnaryOperationU("not", ctx, args, v1 => ~v1); - else - return PerformUnaryOperationS("not", ctx, args, v1 => ~v1); - } - - internal DynValue Callback_HasAll(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformBinaryOperationU("hasAll", ctx, args, (v1, v2) => DynValue.NewBoolean((v1 & v2) == v2)); - else - return PerformBinaryOperationS("hasAll", ctx, args, (v1, v2) => DynValue.NewBoolean((v1 & v2) == v2)); - } - - internal DynValue Callback_HasAny(ScriptExecutionContext ctx, CallbackArguments args) - { - if (IsUnsigned) - return PerformBinaryOperationU("hasAny", ctx, args, (v1, v2) => DynValue.NewBoolean((v1 & v2) != 0)); - else - return PerformBinaryOperationS("hasAny", ctx, args, (v1, v2) => DynValue.NewBoolean((v1 & v2) != 0)); - } - - /// - /// Determines whether the specified object is compatible with the specified type. - /// - /// The type. - /// The object. - /// - public override bool IsTypeCompatible(Type type, object obj) - { - if (obj != null) - return (Type == type); - - return base.IsTypeCompatible(type, obj); - } - - /// - /// Gets a "meta" operation on this userdata. - /// In this specific case, only the concat operator is supported, only on flags enums and it implements the - /// 'or' operator. - /// - /// - /// - /// - /// - public override DynValue MetaIndex(Script script, object obj, string metaname) - { - if (metaname == "__concat" && IsFlags) - return DynValue.NewCallback(Callback_Or); - - return null; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs deleted file mode 100644 index 112e406c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Standard user data descriptor used to instantiate generics. - /// - public class StandardGenericsUserDataDescriptor : IUserDataDescriptor, IGeneratorUserDataDescriptor - { - /// - /// Gets the interop access mode this descriptor uses for members access - /// - public InteropAccessMode AccessMode { get; private set; } - - - /// - /// Initializes a new instance of the class. - /// - /// The type this descriptor refers to. - /// The interop access mode this descriptor uses for members access - public StandardGenericsUserDataDescriptor(Type type, InteropAccessMode accessMode) - { - if (accessMode == InteropAccessMode.NoReflectionAllowed) - throw new ArgumentException("Can't create a StandardGenericsUserDataDescriptor under a NoReflectionAllowed access mode"); - - AccessMode = accessMode; - this.Type = type; - this.Name = "@@" + type.FullName; - } - - - /// - public string Name { get; private set; } - - /// - public Type Type { get; private set; } - - /// - public DynValue Index(Script script, object obj, DynValue index, bool isDirectIndexing) - { - return null; - } - - /// - public bool SetIndex(Script script, object obj, DynValue index, DynValue value, bool isDirectIndexing) - { - return false; - } - - /// - public string AsString(object obj) - { - return obj.ToString(); - } - - /// - public DynValue MetaIndex(Script script, object obj, string metaname) - { - return null; - } - - /// - public bool IsTypeCompatible(Type type, object obj) - { - return Framework.Do.IsInstanceOfType(type, obj); - } - - /// - public IUserDataDescriptor Generate(Type type) - { - if (UserData.IsTypeRegistered(type)) - return null; - - if (Framework.Do.IsGenericTypeDefinition(type)) - return null; - - return UserData.RegisterType(type, AccessMode); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardUserDataDescriptor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardUserDataDescriptor.cs deleted file mode 100755 index 6eece605..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/StandardDescriptors/StandardUserDataDescriptor.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Standard descriptor for userdata types. - /// - public class StandardUserDataDescriptor : DispatchingUserDataDescriptor, IWireableDescriptor - { - /// - /// Gets the interop access mode this descriptor uses for members access - /// - public InteropAccessMode AccessMode { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The type this descriptor refers to. - /// The interop access mode this descriptor uses for members access - /// A human readable friendly name of the descriptor. - public StandardUserDataDescriptor(Type type, InteropAccessMode accessMode, string friendlyName = null) - : base(type, friendlyName) - { - if (accessMode == InteropAccessMode.NoReflectionAllowed) - throw new ArgumentException("Can't create a StandardUserDataDescriptor under a NoReflectionAllowed access mode"); - - if (Script.GlobalOptions.Platform.IsRunningOnAOT()) - accessMode = InteropAccessMode.Reflection; - - if (accessMode == InteropAccessMode.Default) - accessMode = UserData.DefaultAccessMode; - - AccessMode = accessMode; - - FillMemberList(); - } - - /// - /// Fills the member list. - /// - private void FillMemberList() - { - HashSet membersToIgnore = new HashSet( - Framework.Do.GetCustomAttributes(this.Type, typeof(MoonSharpHideMemberAttribute), true) - .OfType() - .Select(a => a.MemberName) - ); - - Type type = this.Type; - - if (AccessMode == InteropAccessMode.HideMembers) - return; - - if (!type.IsDelegateType()) - { - // add declared constructors - foreach (ConstructorInfo ci in Framework.Do.GetConstructors(type)) - { - if (membersToIgnore.Contains("__new")) - continue; - - AddMember("__new", MethodMemberDescriptor.TryCreateIfVisible(ci, this.AccessMode)); - } - - // valuetypes don't reflect their empty ctor.. actually empty ctors are a perversion, we don't care and implement ours - if (Framework.Do.IsValueType(type) && !membersToIgnore.Contains("__new")) - AddMember("__new", new ValueTypeDefaultCtorMemberDescriptor(type)); - } - - - // add methods to method list and metamethods - foreach (MethodInfo mi in Framework.Do.GetMethods(type)) - { - if (membersToIgnore.Contains(mi.Name)) continue; - - MethodMemberDescriptor md = MethodMemberDescriptor.TryCreateIfVisible(mi, this.AccessMode); - - if (md != null) - { - if (!MethodMemberDescriptor.CheckMethodIsCompatible(mi, false)) - continue; - - // transform explicit/implicit conversions to a friendlier name. - string name = mi.Name; - if (mi.IsSpecialName && (mi.Name == SPECIALNAME_CAST_EXPLICIT || mi.Name == SPECIALNAME_CAST_IMPLICIT)) - { - name = mi.ReturnType.GetConversionMethodName(); - } - - AddMember(name, md); - - foreach (string metaname in mi.GetMetaNamesFromAttributes()) - { - AddMetaMember(metaname, md); - } - } - } - - // get properties - foreach (PropertyInfo pi in Framework.Do.GetProperties(type)) - { - if (pi.IsSpecialName || pi.GetIndexParameters().Any() || membersToIgnore.Contains(pi.Name)) - continue; - - AddMember(pi.Name, PropertyMemberDescriptor.TryCreateIfVisible(pi, this.AccessMode)); - } - - // get fields - foreach (FieldInfo fi in Framework.Do.GetFields(type)) - { - if (fi.IsSpecialName || membersToIgnore.Contains(fi.Name)) - continue; - - AddMember(fi.Name, FieldMemberDescriptor.TryCreateIfVisible(fi, this.AccessMode)); - } - - // get events - foreach (EventInfo ei in Framework.Do.GetEvents(type)) - { - if (ei.IsSpecialName || membersToIgnore.Contains(ei.Name)) - continue; - - AddMember(ei.Name, EventMemberDescriptor.TryCreateIfVisible(ei, this.AccessMode)); - } - - // get nested types and create statics - foreach (Type nestedType in Framework.Do.GetNestedTypes(type)) - { - if (membersToIgnore.Contains(nestedType.Name)) - continue; - - if (!Framework.Do.IsGenericTypeDefinition(nestedType)) - { - if (Framework.Do.IsNestedPublic(nestedType) || Framework.Do.GetCustomAttributes(nestedType, typeof(MoonSharpUserDataAttribute), true).Length > 0) - { - var descr = UserData.RegisterType(nestedType, this.AccessMode); - - if (descr != null) - AddDynValue(nestedType.Name, UserData.CreateStatic(nestedType)); - } - } - } - - if (!membersToIgnore.Contains("[this]")) - { - if (Type.IsArray) - { - int rank = Type.GetArrayRank(); - - ParameterDescriptor[] get_pars = new ParameterDescriptor[rank]; - ParameterDescriptor[] set_pars = new ParameterDescriptor[rank + 1]; - - for (int i = 0; i < rank; i++) - get_pars[i] = set_pars[i] = new ParameterDescriptor("idx" + i.ToString(), typeof(int)); - - set_pars[rank] = new ParameterDescriptor("value", Type.GetElementType()); - - AddMember(SPECIALNAME_INDEXER_SET, new ArrayMemberDescriptor(SPECIALNAME_INDEXER_SET, true, set_pars)); - AddMember(SPECIALNAME_INDEXER_GET, new ArrayMemberDescriptor(SPECIALNAME_INDEXER_GET, false, get_pars)); - } - else if (Type == typeof(Array)) - { - AddMember(SPECIALNAME_INDEXER_SET, new ArrayMemberDescriptor(SPECIALNAME_INDEXER_SET, true)); - AddMember(SPECIALNAME_INDEXER_GET, new ArrayMemberDescriptor(SPECIALNAME_INDEXER_GET, false)); - } - } - } - - - - - public void PrepareForWiring(Table t) - { - if (AccessMode == InteropAccessMode.HideMembers || Framework.Do.GetAssembly(Type) == Framework.Do.GetAssembly(this.GetType())) - { - t.Set("skip", DynValue.NewBoolean(true)); - } - else - { - t.Set("visibility", DynValue.NewString(this.Type.GetClrVisibility())); - - t.Set("class", DynValue.NewString(this.GetType().FullName)); - DynValue tm = DynValue.NewPrimeTable(); - t.Set("members", tm); - DynValue tmm = DynValue.NewPrimeTable(); - t.Set("metamembers", tmm); - - Serialize(tm.Table, Members); - Serialize(tmm.Table, MetaMembers); - } - } - - private void Serialize(Table t, IEnumerable> members) - { - foreach (var pair in members) - { - IWireableDescriptor sd = pair.Value as IWireableDescriptor; - - if (sd != null) - { - DynValue mt = DynValue.NewPrimeTable(); - t.Set(pair.Key, mt); - sd.PrepareForWiring(mt.Table); - } - else - { - t.Set(pair.Key, DynValue.NewString("unsupported member type : " + pair.Value.GetType().FullName)); - } - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataMemberType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataMemberType.cs deleted file mode 100644 index 35d33681..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataMemberType.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Interop -{ - public enum UserDataMemberType - { - Constructor, - Method, - Property, - Field, - Event - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs deleted file mode 100755 index 24faf665..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.DataStructs; -using MoonSharp.Interpreter.Interop.BasicDescriptors; - -namespace MoonSharp.Interpreter.Interop.UserDataRegistries -{ - /// - /// Registry of all extension methods. Use UserData statics to access these. - /// - internal class ExtensionMethodsRegistry - { - private static object s_Lock = new object(); - private static MultiDictionary s_Registry = new MultiDictionary(); - private static MultiDictionary s_UnresolvedGenericsRegistry = new MultiDictionary(); - private static int s_ExtensionMethodChangeVersion = 0; - - private class UnresolvedGenericMethod - { - public readonly MethodInfo Method; - public readonly InteropAccessMode AccessMode; - public readonly HashSet AlreadyAddedTypes = new HashSet(); - - public UnresolvedGenericMethod(MethodInfo mi, InteropAccessMode mode) - { - AccessMode = mode; - Method = mi; - } - } - - /// - /// Registers an extension Type (that is a type containing extension methods) - /// - /// The type. - /// The InteropAccessMode. - public static void RegisterExtensionType(Type type, InteropAccessMode mode = InteropAccessMode.Default) - { - lock (s_Lock) - { - bool changesDone = false; - - foreach (MethodInfo mi in Framework.Do.GetMethods(type).Where(_mi => _mi.IsStatic)) - { - if (mi.GetCustomAttributes(typeof(ExtensionAttribute), false).Count() == 0) - continue; - - if (mi.ContainsGenericParameters) - { - s_UnresolvedGenericsRegistry.Add(mi.Name, new UnresolvedGenericMethod(mi, mode)); - changesDone = true; - continue; - } - - if (!MethodMemberDescriptor.CheckMethodIsCompatible(mi, false)) - continue; - - var desc = new MethodMemberDescriptor(mi, mode); - - s_Registry.Add(mi.Name, desc); - changesDone = true; - } - - if (changesDone) - ++s_ExtensionMethodChangeVersion; - } - } - - private static object FrameworkGetMethods() - { - throw new NotImplementedException(); - } - - /// - /// Gets all the extension methods which can match a given name - /// - /// The name. - /// - public static IEnumerable GetExtensionMethodsByName(string name) - { - lock (s_Lock) - return new List(s_Registry.Find(name)); - } - - /// - /// Gets a number which gets incremented everytime the extension methods registry changes. - /// Use this to invalidate caches based on extension methods - /// - /// - public static int GetExtensionMethodsChangeVersion() - { - return s_ExtensionMethodChangeVersion; - } - - - /// - /// Gets all the extension methods which can match a given name and extending a given Type - /// - /// The name. - /// The extended type. - /// - public static List GetExtensionMethodsByNameAndType(string name, Type extendedType) - { - List unresolvedGenerics = null; - - lock (s_Lock) - { - unresolvedGenerics = s_UnresolvedGenericsRegistry.Find(name).ToList(); - } - - foreach (UnresolvedGenericMethod ugm in unresolvedGenerics) - { - ParameterInfo[] args = ugm.Method.GetParameters(); - if (args.Length == 0) continue; - Type extensionType = args[0].ParameterType; - - Type genericType = GetGenericMatch(extensionType, extendedType); - - if (ugm.AlreadyAddedTypes.Add(genericType)) - { - if (genericType != null) - { - MethodInfo mi = InstantiateMethodInfo(ugm.Method, extensionType, genericType, extendedType); - if (mi != null) - { - if (!MethodMemberDescriptor.CheckMethodIsCompatible(mi, false)) - continue; - - var desc = new MethodMemberDescriptor(mi, ugm.AccessMode); - - s_Registry.Add(ugm.Method.Name, desc); - ++s_ExtensionMethodChangeVersion; - } - } - } - } - - return s_Registry.Find(name) - .Where(d => d.ExtensionMethodType != null && Framework.Do.IsAssignableFrom(d.ExtensionMethodType, extendedType)) - .ToList(); - } - - private static MethodInfo InstantiateMethodInfo(MethodInfo mi, Type extensionType, Type genericType, Type extendedType) - { - Type[] defs = mi.GetGenericArguments(); - Type[] tdefs = Framework.Do.GetGenericArguments(genericType); - - if (tdefs.Length == defs.Length) - { - return mi.MakeGenericMethod(tdefs); - } - - return null; - } - - private static Type GetGenericMatch(Type extensionType, Type extendedType) - { - if (!extensionType.IsGenericParameter) - { - extensionType = extensionType.GetGenericTypeDefinition(); - - foreach (Type t in extendedType.GetAllImplementedTypes()) - { - if (Framework.Do.IsGenericType(t) && t.GetGenericTypeDefinition() == extensionType) - { - return t; - } - } - } - - return null; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/TypeDescriptorRegistry.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/TypeDescriptorRegistry.cs deleted file mode 100755 index 945fbc88..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Interop/UserDataRegistries/TypeDescriptorRegistry.cs +++ /dev/null @@ -1,388 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.BasicDescriptors; -using MoonSharp.Interpreter.Interop.RegistrationPolicies; - -namespace MoonSharp.Interpreter.Interop.UserDataRegistries -{ - /// - /// Registry of all type descriptors. Use UserData statics to access these. - /// - internal static class TypeDescriptorRegistry - { - private static object s_Lock = new object(); - private static Dictionary s_TypeRegistry = new Dictionary(); - private static Dictionary s_TypeRegistryHistory = new Dictionary(); - private static InteropAccessMode s_DefaultAccessMode; - - /// - /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. - /// - /// The assembly. - /// if set to true extension types are registered to the appropriate registry. - internal static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) - { - if (asm == null) - { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif - } - - if (includeExtensionTypes) - { - var extensionTypes = from t in asm.SafeGetTypes() - let attributes = Framework.Do.GetCustomAttributes(t, typeof(ExtensionAttribute), true) - where attributes != null && attributes.Length > 0 - select new { Attributes = attributes, DataType = t }; - - foreach (var extType in extensionTypes) - { - UserData.RegisterExtensionType(extType.DataType); - } - } - - - var userDataTypes = from t in asm.SafeGetTypes() - let attributes = Framework.Do.GetCustomAttributes(t, typeof(MoonSharpUserDataAttribute), true) - where attributes != null && attributes.Length > 0 - select new { Attributes = attributes, DataType = t }; - - foreach (var userDataType in userDataTypes) - { - UserData.RegisterType(userDataType.DataType, userDataType.Attributes - .OfType() - .First() - .AccessMode); - } - } - - - /// - /// Determines whether the specified type is registered. Note that this should be used only to check if a descriptor - /// has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor - /// of a base type or implemented interfaces. - /// - /// The type - /// - internal static bool IsTypeRegistered(Type type) - { - lock (s_Lock) - return s_TypeRegistry.ContainsKey(type); - } - - - /// - /// Unregisters a type. - /// WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. - /// Use this only for testing purposes or to re-register the same type in a slightly different way. - /// Additionally, it's a good practice to discard all previous loaded scripts after calling this method. - /// - /// The The type to be unregistered - internal static void UnregisterType(Type t) - { - lock (s_Lock) - { - if (s_TypeRegistry.ContainsKey(t)) - { - PerformRegistration(t, null, s_TypeRegistry[t]); - } - } - } - - /// - /// Gets or sets the default access mode to be used in the whole application - /// - /// - /// The default access mode. - /// - /// InteropAccessMode is InteropAccessMode.Default - internal static InteropAccessMode DefaultAccessMode - { - get { return s_DefaultAccessMode; } - set - { - if (value == InteropAccessMode.Default) - throw new ArgumentException("InteropAccessMode is InteropAccessMode.Default"); - - s_DefaultAccessMode = value; - } - } - - /// - /// Registers a proxy type. - /// - /// The proxy factory. - /// The access mode. - /// Name of the friendly. - /// - internal static IUserDataDescriptor RegisterProxyType_Impl(IProxyFactory proxyFactory, InteropAccessMode accessMode, string friendlyName) - { - IUserDataDescriptor proxyDescriptor = RegisterType_Impl(proxyFactory.ProxyType, accessMode, friendlyName, null); - return RegisterType_Impl(proxyFactory.TargetType, accessMode, friendlyName, new ProxyUserDataDescriptor(proxyFactory, proxyDescriptor, friendlyName)); - } - - - /// - /// Registers a type - /// - /// The type. - /// The access mode (used only if a default type descriptor is created). - /// Friendly name of the descriptor. - /// The descriptor, or null to use a default one. - /// - internal static IUserDataDescriptor RegisterType_Impl(Type type, InteropAccessMode accessMode, string friendlyName, IUserDataDescriptor descriptor) - { - accessMode = ResolveDefaultAccessModeForType(accessMode, type); - - lock (s_Lock) - { - IUserDataDescriptor oldDescriptor = null; - s_TypeRegistry.TryGetValue(type, out oldDescriptor); - - if (descriptor == null) - { - if (IsTypeBlacklisted(type)) - return null; - - if (Framework.Do.GetInterfaces(type).Any(ii => ii == typeof(IUserDataType))) - { - AutoDescribingUserDataDescriptor audd = new AutoDescribingUserDataDescriptor(type, friendlyName); - return PerformRegistration(type, audd, oldDescriptor); - } - else if (Framework.Do.IsGenericTypeDefinition(type)) - { - StandardGenericsUserDataDescriptor typeGen = new StandardGenericsUserDataDescriptor(type, accessMode); - return PerformRegistration(type, typeGen, oldDescriptor); - } - else if (Framework.Do.IsEnum(type)) - { - var enumDescr = new StandardEnumUserDataDescriptor(type, friendlyName); - return PerformRegistration(type, enumDescr, oldDescriptor); - } - else - { - StandardUserDataDescriptor udd = new StandardUserDataDescriptor(type, accessMode, friendlyName); - - if (accessMode == InteropAccessMode.BackgroundOptimized) - { -#if NETFX_CORE - System.Threading.Tasks.Task.Run(() => ((IOptimizableDescriptor)udd).Optimize()); -#else - ThreadPool.QueueUserWorkItem(o => ((IOptimizableDescriptor)udd).Optimize()); -#endif - } - - return PerformRegistration(type, udd, oldDescriptor); - } - } - else - { - PerformRegistration(type, descriptor, oldDescriptor); - return descriptor; - } - } - } - - private static IUserDataDescriptor PerformRegistration(Type type, IUserDataDescriptor newDescriptor, IUserDataDescriptor oldDescriptor) - { - IUserDataDescriptor result = RegistrationPolicy.HandleRegistration(newDescriptor, oldDescriptor); - - if (result != oldDescriptor) - { - if (result == null) - { - s_TypeRegistry.Remove(type); - } - else - { - s_TypeRegistry[type] = result; - s_TypeRegistryHistory[type] = result; - } - } - - return result; - } - - /// - /// Resolves the default type of the access mode for the given type - /// - /// The access mode. - /// The type. - /// - internal static InteropAccessMode ResolveDefaultAccessModeForType(InteropAccessMode accessMode, Type type) - { - if (accessMode == InteropAccessMode.Default) - { - MoonSharpUserDataAttribute attr = Framework.Do.GetCustomAttributes(type, true).OfType() - .SingleOrDefault(); - - if (attr != null) - accessMode = attr.AccessMode; - } - - - if (accessMode == InteropAccessMode.Default) - accessMode = s_DefaultAccessMode; - - return accessMode; - } - - - - /// - /// Gets the best possible type descriptor for a specified CLR type. - /// - /// The CLR type for which the descriptor is desired. - /// if set to true interfaces are used in the search. - /// - internal static IUserDataDescriptor GetDescriptorForType(Type type, bool searchInterfaces) - { - lock (s_Lock) - { - IUserDataDescriptor typeDescriptor = null; - - // if the type has been explicitly registered, return its descriptor as it's complete - if (s_TypeRegistry.ContainsKey(type)) - return s_TypeRegistry[type]; - - if (RegistrationPolicy.AllowTypeAutoRegistration(type)) - { - // no autoreg of delegates - if (!Framework.Do.IsAssignableFrom((typeof(Delegate)), type)) - { - return RegisterType_Impl(type, DefaultAccessMode, type.FullName, null); - } - } - - // search for the base object descriptors - for (Type t = type; t != null; t = Framework.Do.GetBaseType(t)) - { - IUserDataDescriptor u; - - if (s_TypeRegistry.TryGetValue(t, out u)) - { - typeDescriptor = u; - break; - } - else if (Framework.Do.IsGenericType(t)) - { - if (s_TypeRegistry.TryGetValue(t.GetGenericTypeDefinition(), out u)) - { - typeDescriptor = u; - break; - } - } - } - - if (typeDescriptor is IGeneratorUserDataDescriptor) - typeDescriptor = ((IGeneratorUserDataDescriptor)typeDescriptor).Generate(type); - - - // we should not search interfaces (for example, it's just for statics..), no need to look further - if (!searchInterfaces) - return typeDescriptor; - - List descriptors = new List(); - - if (typeDescriptor != null) - descriptors.Add(typeDescriptor); - - - if (searchInterfaces) - { - foreach (Type interfaceType in Framework.Do.GetInterfaces(type)) - { - IUserDataDescriptor interfaceDescriptor; - - if (s_TypeRegistry.TryGetValue(interfaceType, out interfaceDescriptor)) - { - if (interfaceDescriptor is IGeneratorUserDataDescriptor) - interfaceDescriptor = ((IGeneratorUserDataDescriptor)interfaceDescriptor).Generate(type); - - if (interfaceDescriptor != null) - descriptors.Add(interfaceDescriptor); - } - else if (Framework.Do.IsGenericType(interfaceType)) - { - if (s_TypeRegistry.TryGetValue(interfaceType.GetGenericTypeDefinition(), out interfaceDescriptor)) - { - if (interfaceDescriptor is IGeneratorUserDataDescriptor) - interfaceDescriptor = ((IGeneratorUserDataDescriptor)interfaceDescriptor).Generate(type); - - if (interfaceDescriptor != null) - descriptors.Add(interfaceDescriptor); - } - } - } - } - - if (descriptors.Count == 1) - return descriptors[0]; - else if (descriptors.Count == 0) - return null; - else - return new CompositeUserDataDescriptor(descriptors, type); - } - } - - private static bool FrameworkIsAssignableFrom(Type type) - { - throw new NotImplementedException(); - } - - - /// - /// Determines whether the specified type is blacklisted. - /// Blacklisted types CANNOT be registered using default descriptors but they can still be registered - /// with custom descriptors. Forcing registration of blacklisted types in this way can introduce - /// side effects. - /// - /// The t. - /// - public static bool IsTypeBlacklisted(Type t) - { - if (Framework.Do.IsValueType(t) && Framework.Do.GetInterfaces(t).Contains(typeof(System.Collections.IEnumerator))) - return true; - - return false; - } - - /// - /// Gets the list of registered types. - /// - /// - /// The registered types. - /// - public static IEnumerable> RegisteredTypes - { - get { lock (s_Lock) return s_TypeRegistry.ToArray(); } - } - - /// - /// Gets the list of registered types, including unregistered types. - /// - /// - /// The registered types. - /// - public static IEnumerable> RegisteredTypesHistory - { - get { lock (s_Lock) return s_TypeRegistryHistory.ToArray(); } - } - - - /// - /// Gets or sets the registration policy. - /// - internal static IRegistrationPolicy RegistrationPolicy { get; set; } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/LinqHelpers.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/LinqHelpers.cs deleted file mode 100644 index 1b92920e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/LinqHelpers.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace MoonSharp.Interpreter -{ - /// - /// LINQ helper methods - /// - public static class LinqHelpers - { - /// - /// Converts the specified enumerable dynvalues of a given script type to objects of a given type - /// - /// The desired type - /// The enumerable. - /// The type. - public static IEnumerable Convert(this IEnumerable enumerable, DataType type) - { - return enumerable.Where(v => v.Type == type).Select(v => v.ToObject()); - } - - /// - /// Filters an enumeration for items of the given script type - /// - /// The enumerable. - /// The script type. - public static IEnumerable OfDataType(this IEnumerable enumerable, DataType type) - { - return enumerable.Where(v => v.Type == type); - } - - /// - /// Converts the elements to CLR objects - /// - /// The enumerable. - public static IEnumerable AsObjects(this IEnumerable enumerable) - { - return enumerable.Select(v => v.ToObject()); - } - - /// - /// Converts the elements to CLR objects of the desired type - /// - /// The desired type - /// The enumerable. - public static IEnumerable AsObjects(this IEnumerable enumerable) - { - return enumerable.Select(v => v.ToObject()); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/EmbeddedResourcesScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/EmbeddedResourcesScriptLoader.cs deleted file mode 100644 index 5c76dfa1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/EmbeddedResourcesScriptLoader.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A script loader loading scripts from an assembly resources - /// - public class EmbeddedResourcesScriptLoader : ScriptLoaderBase - { - Assembly m_ResourceAssembly; - HashSet m_ResourceNames; - string m_Namespace; - - /// - /// Initializes a new instance of the class. - /// - /// The assembly containing the scripts as embedded resources or null to use the calling assembly. - public EmbeddedResourcesScriptLoader(Assembly resourceAssembly = null) - { - if (resourceAssembly == null) - { -#if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); -#else - resourceAssembly = Assembly.GetCallingAssembly(); -#endif - } - - m_ResourceAssembly = resourceAssembly; - m_Namespace = m_ResourceAssembly.FullName.Split(',').First(); - m_ResourceNames = new HashSet(m_ResourceAssembly.GetManifestResourceNames()); - } - - private string FileNameToResource(string file) - { - file = file.Replace('/', '.'); - file = file.Replace('\\', '.'); - return m_Namespace + "." + file; - } - - /// - /// Checks if a script file exists. - /// - /// The script filename. - /// - public override bool ScriptFileExists(string name) - { - name = FileNameToResource(name); - return m_ResourceNames.Contains(name); - } - - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - public override object LoadFile(string file, Table globalContext) - { - file = FileNameToResource(file); - return m_ResourceAssembly.GetManifestResourceStream(file); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/FileSystemScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/FileSystemScriptLoader.cs deleted file mode 100755 index 77e69eea..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/FileSystemScriptLoader.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if DOTNET_CORE || (!(PCL || ENABLE_DOTNET || NETFX_CORE)) -using System.IO; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A script loader loading scripts directly from the file system (does not go through platform object) - /// - public class FileSystemScriptLoader : ScriptLoaderBase - { - /// - /// Checks if a script file exists. - /// - /// The script filename. - /// - public override bool ScriptFileExists(string name) - { - return File.Exists(name); - } - - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - public override object LoadFile(string file, Table globalContext) - { - return new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - } - } -} -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/IScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/IScriptLoader.cs deleted file mode 100644 index f160abe6..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/IScriptLoader.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// Class dictating how requests to read scripts from files are handled. - /// - /// It's recommended that no class implement IScriptLoader directly, and rather extend ScriptLoaderBase. - /// - public interface IScriptLoader - { - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - object LoadFile(string file, Table globalContext); - /// - /// Resolves a filename [applying paths, etc.] - /// - /// The filename. - /// The global context. - /// - [Obsolete("This serves almost no purpose. Kept here just to preserve backward compatibility.")] - string ResolveFileName(string filename, Table globalContext); - /// - /// Resolves the name of a module to a filename (which will later be passed to OpenScriptFile) - /// - /// The modname. - /// The global context. - /// - string ResolveModuleName(string modname, Table globalContext); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/InvalidScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/InvalidScriptLoader.cs deleted file mode 100644 index 583382e4..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/InvalidScriptLoader.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A script loader used for platforms we cannot initialize in any better way.. - /// - internal class InvalidScriptLoader : IScriptLoader - { - string m_Error; - - internal InvalidScriptLoader(string frameworkname) - { - m_Error = string.Format( -@"Loading scripts from files is not automatically supported on {0}. -Please implement your own IScriptLoader (possibly, extending ScriptLoaderBase for easier implementation), -use a preexisting loader like EmbeddedResourcesScriptLoader or UnityAssetsScriptLoader or load scripts from strings.", frameworkname); - } - - public object LoadFile(string file, Table globalContext) - { - throw new PlatformNotSupportedException(m_Error); - } - - public string ResolveFileName(string filename, Table globalContext) - { - return filename; - } - - public string ResolveModuleName(string modname, Table globalContext) - { - throw new PlatformNotSupportedException(m_Error); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/ScriptLoaderBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/ScriptLoaderBase.cs deleted file mode 100644 index bc4e3697..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/ScriptLoaderBase.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Linq; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A base implementation of IScriptLoader, offering resolution of module names. - /// - public abstract class ScriptLoaderBase : IScriptLoader - { - /// - /// Checks if a script file exists. - /// - /// The script filename. - /// - public abstract bool ScriptFileExists(string name); - - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - public abstract object LoadFile(string file, Table globalContext); - - - /// - /// Resolves the name of a module on a set of paths. - /// - /// The modname. - /// The paths. - /// - protected virtual string ResolveModuleName(string modname, string[] paths) - { - if (paths == null) - return null; - - modname = modname.Replace('.', '/'); - - foreach (string path in paths) - { - string file = path.Replace("?", modname); - - if (ScriptFileExists(file)) - return file; - } - - return null; - } - - /// - /// Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - /// The resolution happens first on paths included in the LUA_PATH global variable (if and only if - /// the IgnoreLuaPathGlobal is false), and - if the variable does not exist - by consulting the - /// ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - /// - /// The modname. - /// The global context. - /// - public virtual string ResolveModuleName(string modname, Table globalContext) - { - if (!this.IgnoreLuaPathGlobal) - { - DynValue s = globalContext.RawGet("LUA_PATH"); - - if (s != null && s.Type == DataType.String) - return ResolveModuleName(modname, UnpackStringPaths(s.String)); - } - - return ResolveModuleName(modname, this.ModulePaths); - } - - /// - /// Gets or sets the modules paths used by the "require" function. If null, the default paths are used (using - /// environment variables etc.). - /// - public string[] ModulePaths { get; set; } - - /// - /// Unpacks a string path in a form like "?;?.lua" to an array - /// - public static string[] UnpackStringPaths(string str) - { - return str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.Trim()) - .Where(s => !string.IsNullOrEmpty(s)) - .ToArray(); - } - - /// - /// Gets the default environment paths. - /// - public static string[] GetDefaultEnvironmentPaths() - { - string[] modulePaths = null; - - if (modulePaths == null) - { - string env = Script.GlobalOptions.Platform.GetEnvironmentVariable("MOONSHARP_PATH"); - if (!string.IsNullOrEmpty(env)) modulePaths = UnpackStringPaths(env); - - if (modulePaths == null) - { - env = Script.GlobalOptions.Platform.GetEnvironmentVariable("LUA_PATH"); - if (!string.IsNullOrEmpty(env)) modulePaths = UnpackStringPaths(env); - } - - if (modulePaths == null) - modulePaths = UnpackStringPaths("?;?.lua"); - } - - return modulePaths; - } - - - - /// - /// Resolves a filename [applying paths, etc.] - /// - /// The filename. - /// The global context. - /// - public virtual string ResolveFileName(string filename, Table globalContext) - { - return filename; - } - - /// - /// Gets or sets a value indicating whether the LUA_PATH global is checked or not to get the path where modules are contained. - /// If true, the LUA_PATH global is NOT checked. - /// - public bool IgnoreLuaPathGlobal { get; set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/UnityAssetsScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/UnityAssetsScriptLoader.cs deleted file mode 100755 index 7db23081..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Loaders/UnityAssetsScriptLoader.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A script loader which can load scripts from assets in Unity3D. - /// Scripts should be saved as .txt files in a subdirectory of Assets/Resources. - /// - /// When MoonSharp is activated on Unity3D and the default script loader is used, - /// scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. - /// - public class UnityAssetsScriptLoader : ScriptLoaderBase - { - Dictionary m_Resources = new Dictionary(); - - /// - /// The default path where scripts are meant to be stored (if not changed) - /// - public const string DEFAULT_PATH = "MoonSharp/Scripts"; - - /// - /// Initializes a new instance of the class. - /// - /// The path, relative to Assets/Resources. For example - /// if your scripts are stored under Assets/Resources/Scripts, you should - /// pass the value "Scripts". If null, "MoonSharp/Scripts" is used. - public UnityAssetsScriptLoader(string assetsPath = null) - { - assetsPath = assetsPath ?? DEFAULT_PATH; -#if UNITY_5 - LoadResourcesUnityNative(assetsPath); -#else - LoadResourcesWithReflection(assetsPath); -#endif - } - - - /// - /// Initializes a new instance of the class. - /// - /// A dictionary mapping filenames to the proper Lua script code. - public UnityAssetsScriptLoader(Dictionary scriptToCodeMap) - { - m_Resources = scriptToCodeMap; - } - -#if UNITY_5 - void LoadResourcesUnityNative(string assetsPath) - { - try - { - UnityEngine.Object[] array = UnityEngine.Resources.LoadAll(assetsPath, typeof(UnityEngine.TextAsset)); - - for (int i = 0; i < array.Length; i++) - { - UnityEngine.TextAsset o = (UnityEngine.TextAsset)array[i]; - - string name = o.name; - string text = o.text; - - m_Resources.Add(name, text); - } - } - catch (Exception ex) - { - UnityEngine.Debug.LogErrorFormat("Error initializing UnityScriptLoader : {0}", ex); - } - } - -#else - - void LoadResourcesWithReflection(string assetsPath) - { - try - { - Type resourcesType = Type.GetType("UnityEngine.Resources, UnityEngine"); - Type textAssetType = Type.GetType("UnityEngine.TextAsset, UnityEngine"); - - MethodInfo textAssetNameGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "name")); - MethodInfo textAssetTextGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "text")); - - MethodInfo loadAll = Framework.Do.GetMethod(resourcesType, "LoadAll", - new Type[] { typeof(string), typeof(Type) }); - - Array array = (Array)loadAll.Invoke(null, new object[] { assetsPath, textAssetType }); - - for (int i = 0; i < array.Length; i++) - { - object o = array.GetValue(i); - - string name = textAssetNameGet.Invoke(o, null) as string; - string text = textAssetTextGet.Invoke(o, null) as string; - - m_Resources.Add(name, text); - } - } - catch (Exception ex) - { -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) - Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex); -#endif - System.Diagnostics.Debug.WriteLine(string.Format("Error initializing UnityScriptLoader : {0}", ex)); - } - } -#endif - - private string GetFileName(string filename) - { - int b = Math.Max(filename.LastIndexOf('\\'), filename.LastIndexOf('/')); - - if (b > 0) - filename = filename.Substring(b + 1); - - return filename; - } - - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - /// UnityAssetsScriptLoader.LoadFile : Cannot load + file - public override object LoadFile(string file, Table globalContext) - { - file = GetFileName(file); - - if (m_Resources.ContainsKey(file)) - return m_Resources[file]; - else - { - var error = string.Format( -@"Cannot load script '{0}'. By default, scripts should be .txt files placed under a Assets/Resources/{1} directory. -If you want scripts to be put in another directory or another way, use a custom instance of UnityAssetsScriptLoader or implement -your own IScriptLoader (possibly extending ScriptLoaderBase).", file, DEFAULT_PATH); - - throw new Exception(error); - } - } - - /// - /// Checks if a given file exists - /// - /// The file. - /// - public override bool ScriptFileExists(string file) - { - file = GetFileName(file); - return m_Resources.ContainsKey(file); - } - - - /// - /// Gets the list of loaded scripts filenames (useful for debugging purposes). - /// - /// - public string[] GetLoadedScripts() - { - return m_Resources.Keys.ToArray(); - } - - - - } -} - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/CoreModules.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/CoreModules.cs deleted file mode 100755 index 3f95615c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/CoreModules.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Enumeration (combinable as flags) of all the standard library modules - /// - [Flags] - public enum CoreModules - { - /// - /// Value used to specify no modules to be loaded (equals 0). - /// - None = 0, - - /// - /// The basic methods. Includes "assert", "collectgarbage", "error", "print", "select", "type", "tonumber" and "tostring". - /// - Basic = 0x40, - /// - /// The global constants: "_G", "_VERSION" and "_MOONSHARP". - /// - GlobalConsts = 0x1, - /// - /// The table iterators: "next", "ipairs" and "pairs". - /// - TableIterators = 0x2, - /// - /// The metatable methods : "setmetatable", "getmetatable", "rawset", "rawget", "rawequal" and "rawlen". - /// - Metatables = 0x4, - /// - /// The string package - /// - String = 0x8, - /// - /// The load methods: "load", "loadsafe", "loadfile", "loadfilesafe", "dofile" and "require" - /// - LoadMethods = 0x10, - /// - /// The table package - /// - Table = 0x20, - /// - /// The error handling methods: "pcall" and "xpcall" - /// - ErrorHandling = 0x80, - /// - /// The math package - /// - Math = 0x100, - /// - /// The coroutine package - /// - Coroutine = 0x200, - /// - /// The bit32 package - /// - Bit32 = 0x400, - /// - /// The time methods of the "os" package: "clock", "difftime", "date" and "time" - /// - OS_Time = 0x800, - /// - /// The methods of "os" package excluding those listed for OS_Time. These are not supported under Unity. - /// - OS_System = 0x1000, - /// - /// The methods of "io" and "file" packages. These are not supported under Unity. - /// - IO = 0x2000, - /// - /// The "debug" package (it has limited support) - /// - Debug = 0x4000, - /// - /// The "dynamic" package (introduced by MoonSharp). - /// - Dynamic = 0x8000, - /// - /// The "json" package (introduced by MoonSharp). - /// - Json = 0x10000, - - - /// - /// A sort of "hard" sandbox preset, including string, math, table, bit32 packages, constants and table iterators. - /// - Preset_HardSandbox = GlobalConsts | TableIterators | String | Table | Basic | Math | Bit32, - /// - /// A softer sandbox preset, adding metatables support, error handling, coroutine, time functions, json parsing and dynamic evaluations. - /// - Preset_SoftSandbox = Preset_HardSandbox | Metatables | ErrorHandling | Coroutine | OS_Time | Dynamic | Json, - /// - /// The default preset. Includes everything except "debug" as now. - /// Beware that using this preset allows scripts unlimited access to the system. - /// - Preset_Default = Preset_SoftSandbox | LoadMethods | OS_System | IO, - /// - /// The complete package. - /// Beware that using this preset allows scripts unlimited access to the system. - /// - Preset_Complete = Preset_Default | Debug, - - } - - internal static class CoreModules_ExtensionMethods - { - public static bool Has(this CoreModules val, CoreModules flag) - { - return (val & flag) == flag; - } - } - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/ModuleRegister.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/ModuleRegister.cs deleted file mode 100755 index f2993260..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/ModuleRegister.cs +++ /dev/null @@ -1,231 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.CoreLib; -using MoonSharp.Interpreter.Platforms; - -namespace MoonSharp.Interpreter -{ - /// - /// Class managing modules (mostly as extension methods) - /// - public static class ModuleRegister - { - /// - /// Register the core modules to a table - /// - /// The table. - /// The modules. - /// - public static Table RegisterCoreModules(this Table table, CoreModules modules) - { - modules = Script.GlobalOptions.Platform.FilterSupportedCoreModules(modules); - - if (modules.Has(CoreModules.GlobalConsts)) RegisterConstants(table); - if (modules.Has(CoreModules.TableIterators)) RegisterModuleType(table); - if (modules.Has(CoreModules.Basic)) RegisterModuleType(table); - if (modules.Has(CoreModules.Metatables)) RegisterModuleType(table); - if (modules.Has(CoreModules.String)) RegisterModuleType(table); - if (modules.Has(CoreModules.LoadMethods)) RegisterModuleType(table); - if (modules.Has(CoreModules.Table)) RegisterModuleType(table); - if (modules.Has(CoreModules.Table)) RegisterModuleType(table); - if (modules.Has(CoreModules.ErrorHandling)) RegisterModuleType(table); - if (modules.Has(CoreModules.Math)) RegisterModuleType(table); - if (modules.Has(CoreModules.Coroutine)) RegisterModuleType(table); - if (modules.Has(CoreModules.Bit32)) RegisterModuleType(table); - if (modules.Has(CoreModules.Dynamic)) RegisterModuleType(table); - if (modules.Has(CoreModules.OS_System)) RegisterModuleType(table); - if (modules.Has(CoreModules.OS_Time)) RegisterModuleType(table); - if (modules.Has(CoreModules.IO)) RegisterModuleType(table); - if (modules.Has(CoreModules.Debug)) RegisterModuleType(table); - if (modules.Has(CoreModules.Json)) RegisterModuleType(table); - - return table; - } - - - - /// - /// Registers the standard constants (_G, _VERSION, _MOONSHARP) to a table - /// - /// The table. - /// - public static Table RegisterConstants(this Table table) - { - DynValue moonsharp_table = DynValue.NewTable(table.OwnerScript); - Table m = moonsharp_table.Table; - - table.Set("_G", DynValue.NewTable(table)); - table.Set("_VERSION", DynValue.NewString(string.Format("MoonSharp {0}", Script.VERSION))); - table.Set("_MOONSHARP", moonsharp_table); - - m.Set("version", DynValue.NewString(Script.VERSION)); - m.Set("luacompat", DynValue.NewString(Script.LUA_VERSION)); - m.Set("platform", DynValue.NewString(Script.GlobalOptions.Platform.GetPlatformName())); - m.Set("is_aot", DynValue.NewBoolean(Script.GlobalOptions.Platform.IsRunningOnAOT())); - m.Set("is_unity", DynValue.NewBoolean(PlatformAutoDetector.IsRunningOnUnity)); - m.Set("is_mono", DynValue.NewBoolean(PlatformAutoDetector.IsRunningOnMono)); - m.Set("is_clr4", DynValue.NewBoolean(PlatformAutoDetector.IsRunningOnClr4)); - m.Set("is_pcl", DynValue.NewBoolean(PlatformAutoDetector.IsPortableFramework)); - m.Set("banner", DynValue.NewString(Script.GetBanner())); - - return table; - } - - - - /// - /// Registers a module type to the specified table - /// - /// The table. - /// The type - /// - /// If the module contains some incompatibility - public static Table RegisterModuleType(this Table gtable, Type t) - { - Table table = CreateModuleNamespace(gtable, t); - - foreach (MethodInfo mi in Framework.Do.GetMethods(t).Where(__mi => __mi.IsStatic)) - { - if (mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).ToArray().Length > 0) - { - MoonSharpModuleMethodAttribute attr = (MoonSharpModuleMethodAttribute)mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).First(); - - if (!CallbackFunction.CheckCallbackSignature(mi, true)) - throw new ArgumentException(string.Format("Method {0} does not have the right signature.", mi.Name)); - -#if NETFX_CORE - Delegate deleg = mi.CreateDelegate(typeof(Func)); -#else - Delegate deleg = Delegate.CreateDelegate(typeof(Func), mi); -#endif - - Func func = - (Func)deleg; - - - string name = (!string.IsNullOrEmpty(attr.Name)) ? attr.Name : mi.Name; - - table.Set(name, DynValue.NewCallback(func, name)); - } - else if (mi.Name == "MoonSharpInit") - { - object[] args = new object[2] { gtable, table }; - mi.Invoke(null, args); - } - } - - foreach (FieldInfo fi in Framework.Do.GetFields(t).Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).ToArray().Length > 0)) - { - MoonSharpModuleMethodAttribute attr = (MoonSharpModuleMethodAttribute)fi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).First(); - string name = (!string.IsNullOrEmpty(attr.Name)) ? attr.Name : fi.Name; - - RegisterScriptField(fi, null, table, t, name); - } - - foreach (FieldInfo fi in Framework.Do.GetFields(t).Where(_mi => _mi.IsStatic && _mi.GetCustomAttributes(typeof(MoonSharpModuleConstantAttribute), false).ToArray().Length > 0)) - { - MoonSharpModuleConstantAttribute attr = (MoonSharpModuleConstantAttribute)fi.GetCustomAttributes(typeof(MoonSharpModuleConstantAttribute), false).First(); - string name = (!string.IsNullOrEmpty(attr.Name)) ? attr.Name : fi.Name; - - RegisterScriptFieldAsConst(fi, null, table, t, name); - } - - return gtable; - } - - private static void RegisterScriptFieldAsConst(FieldInfo fi, object o, Table table, Type t, string name) - { - if (fi.FieldType == typeof(string)) - { - string val = fi.GetValue(o) as string; - table.Set(name, DynValue.NewString(val)); - } - else if (fi.FieldType == typeof(double)) - { - double val = (double)fi.GetValue(o); - table.Set(name, DynValue.NewNumber(val)); - } - else - { - throw new ArgumentException(string.Format("Field {0} does not have the right type - it must be string or double.", name)); - } - } - - private static void RegisterScriptField(FieldInfo fi, object o, Table table, Type t, string name) - { - if (fi.FieldType != typeof(string)) - { - throw new ArgumentException(string.Format("Field {0} does not have the right type - it must be string.", name)); - } - - string val = fi.GetValue(o) as string; - - DynValue fn = table.OwnerScript.LoadFunction(val, table, name); - - table.Set(name, fn); - } - - - private static Table CreateModuleNamespace(Table gtable, Type t) - { - MoonSharpModuleAttribute attr = (MoonSharpModuleAttribute)(Framework.Do.GetCustomAttributes(t, typeof(MoonSharpModuleAttribute), false).First()); - - if (string.IsNullOrEmpty(attr.Namespace)) - { - return gtable; - } - else - { - Table table = null; - - DynValue found = gtable.Get(attr.Namespace); - - if (found.Type == DataType.Table) - { - table = found.Table; - } - else - { - table = new Table(gtable.OwnerScript); - gtable.Set(attr.Namespace, DynValue.NewTable(table)); - } - - - DynValue package = gtable.RawGet("package"); - - if (package == null || package.Type != DataType.Table) - { - gtable.Set("package", package = DynValue.NewTable(gtable.OwnerScript)); - } - - - DynValue loaded = package.Table.RawGet("loaded"); - - if (loaded == null || loaded.Type != DataType.Table) - { - package.Table.Set("loaded", loaded = DynValue.NewTable(gtable.OwnerScript)); - } - - loaded.Table.Set(attr.Namespace, DynValue.NewTable(table)); - - return table; - } - } - - /// - /// Registers a module type to the specified table - /// - /// The module type - /// The table. - /// - /// If the module contains some incompatibility - public static Table RegisterModuleType(this Table table) - { - return RegisterModuleType(table, typeof(T)); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleAttribute.cs deleted file mode 100644 index 64b5deb1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleAttribute.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// Marks a CLR type to be a MoonSharp module. - /// Modules are the fastest way to bring interop between scripts and CLR code, albeit at the cost of a very increased - /// complexity in writing them. Modules is what's used for the standard library, for maximum efficiency. - /// - /// Modules are basically classes containing only static methods, with the callback function signature. - /// - /// See and for (extension) methods used to register modules to a - /// table. - /// - /// See for information regarding the standard callback signature along with easier ways - /// to marshal methods. - /// - /// See for easier object marshalling. - /// - [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] - public sealed class MoonSharpModuleAttribute : Attribute - { - /// - /// Gets or sets the namespace, that is the name of the table which will contain the defined functions. - /// Can be null to be in the global table. - /// - public string Namespace { get; set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleConstantAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleConstantAttribute.cs deleted file mode 100644 index b633bed2..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleConstantAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// In a module type, mark fields with this attribute to have them exposed as a module constant. - /// - /// See for more information about modules. - /// - [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] - public sealed class MoonSharpModuleConstantAttribute : Attribute - { - /// - /// Gets or sets the name of the constant - if different from the name of the field itself - /// - public string Name { get; set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleMethodAttribute.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleMethodAttribute.cs deleted file mode 100644 index 50b58f51..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Modules/MoonSharpModuleMethodAttribute.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter -{ - /// - /// In a module type, mark methods or fields with this attribute to have them exposed as module functions. - /// Methods must have the signature "public static DynValue ...(ScriptExecutionContextCallbackArguments)". - /// Fields must be static or const strings, with an anonymous Lua function inside. - /// - /// See for more information about modules. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] - public sealed class MoonSharpModuleMethodAttribute : Attribute - { - /// - /// Gets or sets the name of the function in the module (defaults to member name) - /// - public string Name { get; set; } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/NameSpace_XmlHelp.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/NameSpace_XmlHelp.cs deleted file mode 100644 index 8f2615bb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/NameSpace_XmlHelp.cs +++ /dev/null @@ -1,95 +0,0 @@ - -namespace MoonSharp.Interpreter -{ - /// - /// Namespace containing all the most commonly used classes for MoonSharp operation. - /// When in doubt, refer to and classes as starting points. - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.CoreLib -{ - /// - /// Namespace containing the implementation of the Lua standard library, as MoonSharp modules. - /// There's seldom the need to access these classes directly. - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.CoreLib.IO -{ - /// - /// Namespace containing userdata classes for the 'io' module - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.Debugging -{ - /// - /// Namespace containing classes used to support debuggers - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.Diagnostics -{ - /// - /// Namespace containing classes used to support self diagnostics (e.g. performance counters) - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.Interop -{ - /// - /// Namespace containing classes used to customize and support advanced interoperations between - /// scripts and CLR code. - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.Interop.LuaStateInterop -{ - /// - /// Namespace containing classes used to provide a minimal support for porting code based on the classic - /// "LuaState" model (e.g. code based on KopiLua, UniLua or Lua itself). - /// - internal static class NamespaceDoc { } -} - - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// Namespace containing classes used to customized how scripts are loaded from external files. - /// - internal static class NamespaceDoc { } -} - - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Namespace containing classes used to customize how the interfacing with the operative system happens - /// for the 'os' and 'io' modules, and for future modules/classes which may require OS access. - /// See and . - /// - internal static class NamespaceDoc { } -} - -namespace MoonSharp.Interpreter.REPL -{ - /// - /// Contains classes useful to implement REPL interpreters. - /// See : - /// - internal static class NamespaceDoc { } -} - - - - - - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/ColonOperatorBehaviour.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/ColonOperatorBehaviour.cs deleted file mode 100644 index c8b9a04e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/ColonOperatorBehaviour.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter -{ - /// - /// Defines behaviour of the colon ':' operator in CLR callbacks. - /// Default behaviour is for ':' being treated the same as a '.' if the functions is implemented on the CLR side (e.g. in C#). - /// - public enum ColonOperatorBehaviour - { - /// - /// The colon is treated the same as the dot ('.') operator. - /// - TreatAsDot, - /// - /// The colon is treated the same as the dot ('.') operator if the first argument is userdata, as a Lua colon operator otherwise. - /// - TreatAsDotOnUserData, - /// - /// The colon is treated in the same as the Lua colon operator works. - /// - TreatAsColon - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/FuzzySymbolMatchingBehavior.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/FuzzySymbolMatchingBehavior.cs deleted file mode 100644 index dcb0a006..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Options/FuzzySymbolMatchingBehavior.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter { - - /// - /// A flag that controls if/how symbols (method, property, userdata) are fuzzily matched when they do not exist. Flags can be combined for multiple checks. - /// - [Flags] - public enum FuzzySymbolMatchingBehavior { - - /// No fuzzy matching is performed. - None = 0, - - /// The first letter of a symbol will be uppercased (to check for common C# naming conventions). For example, testMethod() becomes TestMethod() - UpperFirstLetter = 1, - - /// Underscores in symbols are converted to camelcase. For example, test_method() becomes testMethod() - Camelify = 2, - - /// - /// Converts a symbol to pascal case. For example, test_Method_two() becomes TestMethodTwo() - /// - PascalCase = 4 - - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/DotNetCorePlatformAccessor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/DotNetCorePlatformAccessor.cs deleted file mode 100755 index 2671fac8..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/DotNetCorePlatformAccessor.cs +++ /dev/null @@ -1,218 +0,0 @@ -#if DOTNET_CORE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Class providing the IPlatformAccessor interface for .NET Core builds - /// - public class DotNetCorePlatformAccessor : PlatformAccessorBase - { - /// - /// Converts a Lua string access mode to a FileAccess enum - /// - /// The mode. - /// - public static FileAccess ParseFileAccess(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileAccess.Read; - else if (mode == "r+") - return FileAccess.ReadWrite; - else if (mode == "w") - return FileAccess.Write; - else if (mode == "w+") - return FileAccess.ReadWrite; - else - return FileAccess.ReadWrite; - } - - /// - /// Converts a Lua string access mode to a ParseFileMode enum - /// - /// The mode. - /// - public static FileMode ParseFileMode(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileMode.Open; - else if (mode == "r+") - return FileMode.OpenOrCreate; - else if (mode == "w") - return FileMode.Create; - else if (mode == "w+") - return FileMode.Truncate; - else - return FileMode.Append; - } - - - /// - /// A function used to open files in the 'io' module. - /// Can have an invalid implementation if 'io' module is filtered out. - /// It should return a correctly initialized Stream for the given file and access - /// - /// - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - return new FileStream(filename, ParseFileMode(mode), ParseFileAccess(mode), FileShare.ReadWrite | FileShare.Delete); - } - - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - public override string GetEnvironmentVariable(string envvarname) - { - return Environment.GetEnvironmentVariable(envvarname); - } - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// - /// The type. - /// - /// type - public override Stream IO_GetStandardStream(StandardFileType type) - { - switch (type) - { - case StandardFileType.StdIn: - return Console.OpenStandardInput(); - case StandardFileType.StdOut: - return Console.OpenStandardOutput(); - case StandardFileType.StdErr: - return Console.OpenStandardError(); - default: - throw new ArgumentException("type"); - } - } - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - public override void DefaultPrint(string content) - { - Console.WriteLine(content); - } - - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. - /// - /// - public override string IO_OS_GetTempFilename() - { - return Path.GetTempFileName(); - } - - /// - /// Exits the process, returning the specified exit code. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The exit code. - public override void OS_ExitFast(int exitCode) - { - Environment.Exit(exitCode); - } - - /// - /// Checks if a file exists. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - /// - /// True if the file exists, false otherwise. - /// - public override bool OS_FileExists(string file) - { - return File.Exists(file); - } - - /// - /// Deletes the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - public override void OS_FileDelete(string file) - { - File.Delete(file); - } - - /// - /// Moves the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The source. - /// The DST. - public override void OS_FileMove(string src, string dst) - { -#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - File.Move(src, dst); -#endif - } - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The cmdline. - /// - public override int OS_Execute(string cmdline) - { - // This is windows only! - throw new NotSupportedException("Not supported on .NET core"); - - //ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", string.Format("/C {0}", cmdline)); - //psi.ErrorDialog = false; - - //Process proc = Process.Start(psi); - //proc.WaitForExit(); - //return proc.ExitCode; - } - - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - return module; - } - - /// - /// Gets the platform name prefix - /// - /// - /// - public override string GetPlatformNamePrefix() - { - return "core"; - } - } -} - -#endif diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/IPlatformAccessor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/IPlatformAccessor.cs deleted file mode 100644 index 0fe38d6c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/IPlatformAccessor.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Interface to abstract all accesses made to the underlying platform (OS, framework) by the scripting engine. - /// Can be used both to support "non-standard" platforms (i.e. non-posix, non-windows) and/or to sandbox the behaviour - /// of the scripting engine. - /// - /// It's recommended that no class implement IPlatformAccessor directly, and rather extend . - /// - public interface IPlatformAccessor - { - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - CoreModules FilterSupportedCoreModules(CoreModules module); - - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - string GetEnvironmentVariable(string envvarname); - - /// - /// Determines whether the application is running in AOT (ahead-of-time) mode - /// - bool IsRunningOnAOT(); - - /// - /// Gets the name of the platform (used for debug purposes). - /// - /// The name of the platform (used for debug purposes) - string GetPlatformName(); - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - void DefaultPrint(string content); - - /// - /// Default handler for interactive line input calls. Can be customized in ScriptOptions. - /// If a meaningful implementation cannot be provided, this method should return null. - /// - /// - string DefaultInput(string prompt); - - /// - /// A function used to open files in the 'io' module. - /// Can have an invalid implementation if 'io' module is filtered out. - /// It should return a correctly initialized Stream for the given file and access - /// - /// The script. - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode); - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// - /// The type. - /// - Stream IO_GetStandardStream(StandardFileType type); - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. - /// - /// - string IO_OS_GetTempFilename(); - - /// - /// Exits the process, returning the specified exit code. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The exit code. - void OS_ExitFast(int exitCode); - - /// - /// Checks if a file exists. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - /// True if the file exists, false otherwise. - bool OS_FileExists(string file); - - /// - /// Deletes the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - void OS_FileDelete(string file); - - /// - /// Moves the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The source. - /// The DST. - void OS_FileMove(string src, string dst); - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The cmdline. - /// - int OS_Execute(string cmdline); - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/LimitedPlatformAccessor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/LimitedPlatformAccessor.cs deleted file mode 100644 index 18bd1765..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/LimitedPlatformAccessor.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Text; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// A class implementing all the bits needed to have a minimal support of a platform. - /// This does not support the 'io'/'file' modules and has partial support of the 'os' module. - /// - public class LimitedPlatformAccessor : PlatformAccessorBase - { - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - public override string GetEnvironmentVariable(string envvarname) - { - return null; - } - - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - return module & (~(CoreModules.IO | CoreModules.OS_System)); - } - - /// - /// A function used to open files in the 'io' module. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override System.IO.Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The type. - /// - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override System.IO.Stream IO_GetStandardStream(StandardFileType type) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override string IO_OS_GetTempFilename() - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Exits the process, returning the specified exit code. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The exit code. - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override void OS_ExitFast(int exitCode) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Checks if a file exists. Used by the 'os' module. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The file. - /// - /// True if the file exists, false otherwise. - /// - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override bool OS_FileExists(string file) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Deletes the specified file. Used by the 'os' module. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The file. - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override void OS_FileDelete(string file) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Moves the specified file. Used by the 'os' module. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The source. - /// The DST. - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override void OS_FileMove(string src, string dst) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and - /// thus does not support 'io' and 'os' modules. - /// - /// The cmdline. - /// - /// The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed. - public override int OS_Execute(string cmdline) - { - throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed."); - } - - /// - /// Gets the platform name prefix - /// - /// - /// - public override string GetPlatformNamePrefix() - { - return "limited"; - } - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - /// - public override void DefaultPrint(string content) - { - System.Diagnostics.Debug.WriteLine(content); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAccessorBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAccessorBase.cs deleted file mode 100755 index f09c7cc5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAccessorBase.cs +++ /dev/null @@ -1,265 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// An abstract class which offers basic services on top of IPlatformAccessor to provide easier implementation of platforms. - /// - public abstract class PlatformAccessorBase : IPlatformAccessor - { - /// - /// Gets the platform name prefix - /// - /// - public abstract string GetPlatformNamePrefix(); - - /// - /// Gets the name of the platform (used for debug purposes). - /// - /// - /// The name of the platform (used for debug purposes) - /// - public string GetPlatformName() - { - string suffix = null; - - if (PlatformAutoDetector.IsRunningOnUnity) - { - if (PlatformAutoDetector.IsUnityNative) - { - suffix = "unity." + GetUnityPlatformName().ToLower() + "." + GetUnityRuntimeName(); - } - else - { - if (PlatformAutoDetector.IsRunningOnMono) - suffix = "unity.dll.mono"; - else - suffix = "unity.dll.unknown"; - } - } - else if (PlatformAutoDetector.IsRunningOnMono) - suffix = "mono"; - else - suffix = "dotnet"; - - if (PlatformAutoDetector.IsPortableFramework) - suffix = suffix + ".portable"; - - if (PlatformAutoDetector.IsRunningOnClr4) - suffix = suffix + ".clr4"; - else - suffix = suffix + ".clr2"; - -#if DOTNET_CORE - suffix += ".netcore"; -#endif - - if (PlatformAutoDetector.IsRunningOnAOT) - suffix = suffix + ".aot"; - - return GetPlatformNamePrefix() + "." + suffix; - } - - private string GetUnityRuntimeName() - { -#if ENABLE_MONO - return "mono"; -#elif ENABLE_IL2CPP - return "il2cpp"; -#elif ENABLE_DOTNET - return "dotnet"; -#else - return "unknown"; -#endif - } - - private string GetUnityPlatformName() - { -#if UNITY_STANDALONE_OSX - return "OSX"; -#elif UNITY_STANDALONE_WIN - return "WIN"; -#elif UNITY_STANDALONE_LINUX - return "LINUX"; -#elif UNITY_STANDALONE - return "STANDALONE"; -#elif UNITY_WII - return "WII"; -#elif UNITY_IOS - return "IOS"; -#elif UNITY_IPHONE - return "IPHONE"; -#elif UNITY_ANDROID - return "ANDROID"; -#elif UNITY_PS3 - return "PS3"; -#elif UNITY_PS4 - return "PS4"; -#elif UNITY_SAMSUNGTV - return "SAMSUNGTV"; -#elif UNITY_XBOX360 - return "XBOX360"; -#elif UNITY_XBOXONE - return "XBOXONE"; -#elif UNITY_TIZEN - return "TIZEN"; -#elif UNITY_TVOS - return "TVOS"; -#elif UNITY_WP_8_1 - return "WP_8_1"; -#elif UNITY_WSA_10_0 - return "WSA_10_0"; -#elif UNITY_WSA_8_1 - return "WSA_8_1"; -#elif UNITY_WSA - return "WSA"; -#elif UNITY_WINRT_10_0 - return "WINRT_10_0"; -#elif UNITY_WINRT_8_1 - return "WINRT_8_1"; -#elif UNITY_WINRT - return "WINRT"; -#elif UNITY_WEBGL - return "WEBGL"; -#else - return "UNKNOWNHW"; -#endif - } - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - public abstract void DefaultPrint(string content); - - /// - /// DEPRECATED. - /// This is kept for backward compatibility, see the overload taking a prompt as an input parameter. - /// - /// Default handler for interactive line input calls. Can be customized in ScriptOptions. - /// If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - /// - /// null - [Obsolete("Replace with DefaultInput(string)")] - public virtual string DefaultInput() - { - return null; - } - - /// - /// Default handler for interactive line input calls. Can be customized in ScriptOptions. - /// If an inheriting class whants to give a meaningful implementation, this method MUST be overridden. - /// - /// null - public virtual string DefaultInput(string prompt) - { -#pragma warning disable 618 - return DefaultInput(); -#pragma warning restore 618 - } - - /// - /// A function used to open files in the 'io' module. - /// Can have an invalid implementation if 'io' module is filtered out. - /// It should return a correctly initialized Stream for the given file and access - /// - /// - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - public abstract Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode); - - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// - /// The type. - /// - public abstract Stream IO_GetStandardStream(StandardFileType type); - - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. - /// - /// - public abstract string IO_OS_GetTempFilename(); - - - /// - /// Exits the process, returning the specified exit code. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The exit code. - public abstract void OS_ExitFast(int exitCode); - - - /// - /// Checks if a file exists. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - /// - /// True if the file exists, false otherwise. - /// - public abstract bool OS_FileExists(string file); - - - /// - /// Deletes the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - public abstract void OS_FileDelete(string file); - - - /// - /// Moves the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The source. - /// The DST. - public abstract void OS_FileMove(string src, string dst); - - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The cmdline. - /// - public abstract int OS_Execute(string cmdline); - - - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - public abstract CoreModules FilterSupportedCoreModules(CoreModules module); - - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - public abstract string GetEnvironmentVariable(string envvarname); - - /// - /// Determines whether the application is running in AOT (ahead-of-time) mode - /// - public virtual bool IsRunningOnAOT() - { - return PlatformAutoDetector.IsRunningOnAOT; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAutoDetector.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAutoDetector.cs deleted file mode 100755 index b1765517..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/PlatformAutoDetector.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Linq; -using MoonSharp.Interpreter.Interop; -using MoonSharp.Interpreter.Loaders; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// A static class offering properties for autodetection of system/platform details - /// - public static class PlatformAutoDetector - { - private static bool? m_IsRunningOnAOT = null; - - private static bool m_AutoDetectionsDone = false; - - /// - /// Gets a value indicating whether this instance is running on mono. - /// - public static bool IsRunningOnMono { get; private set; } - /// - /// Gets a value indicating whether this instance is running on a CLR4 compatible implementation - /// - public static bool IsRunningOnClr4 { get; private set; } - /// - /// Gets a value indicating whether this instance is running on Unity-3D - /// - public static bool IsRunningOnUnity { get; private set; } - /// - /// Gets a value indicating whether this instance has been built as a Portable Class Library - /// - public static bool IsPortableFramework { get; private set; } - /// - /// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL). - /// - public static bool IsUnityNative { get; private set; } - /// - /// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP - /// - public static bool IsUnityIL2CPP { get; private set; } - - - /// - /// Gets a value indicating whether this instance is running a system using Ahead-Of-Time compilation - /// and not supporting JIT. - /// - public static bool IsRunningOnAOT - { - // We do a lazy eval here, so we can wire out this code by not calling it, if necessary.. - get - { -#if UNITY_WEBGL || UNITY_IOS || UNITY_TVOS || ENABLE_IL2CPP - return true; -#else - - if (!m_IsRunningOnAOT.HasValue) - { - try - { - System.Linq.Expressions.Expression e = System.Linq.Expressions.Expression.Constant(5, typeof(int)); - var lambda = System.Linq.Expressions.Expression.Lambda>(e); - lambda.Compile(); - m_IsRunningOnAOT = false; - } - catch (Exception) - { - m_IsRunningOnAOT = true; - } - } - - return m_IsRunningOnAOT.Value; -#endif - } - } - - private static void AutoDetectPlatformFlags() - { - if (m_AutoDetectionsDone) - return; -#if PCL - IsPortableFramework = true; -#if ENABLE_DOTNET - IsRunningOnUnity = true; - IsUnityNative = true; -#endif -#else -#if UNITY_5 - IsRunningOnUnity = true; - IsUnityNative = true; - - #if ENABLE_IL2CPP - IsUnityIL2CPP = true; - #endif - #elif !(NETFX_CORE) - IsRunningOnUnity = AppDomain.CurrentDomain - .GetAssemblies() - .SelectMany(a => a.SafeGetTypes()) - .Any(t => t.FullName.StartsWith("UnityEngine.")); - #endif -#endif - - IsRunningOnMono = (Type.GetType("Mono.Runtime") != null); - - IsRunningOnClr4 = (Type.GetType("System.Lazy`1") != null); - - m_AutoDetectionsDone = true; - } - - - - internal static IPlatformAccessor GetDefaultPlatform() - { - AutoDetectPlatformFlags(); - -#if PCL || ENABLE_DOTNET - return new LimitedPlatformAccessor(); -#else - if (IsRunningOnUnity) - return new LimitedPlatformAccessor(); - -#if DOTNET_CORE - return new DotNetCorePlatformAccessor(); -#else - return new StandardPlatformAccessor(); -#endif -#endif - } - - internal static IScriptLoader GetDefaultScriptLoader() - { - AutoDetectPlatformFlags(); - - if (IsRunningOnUnity) - return new UnityAssetsScriptLoader(); - else - { -#if (DOTNET_CORE) - return new FileSystemScriptLoader(); -#elif (PCL || ENABLE_DOTNET || NETFX_CORE) - return new InvalidScriptLoader("Portable Framework"); -#else - return new FileSystemScriptLoader(); -#endif - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardFileType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardFileType.cs deleted file mode 100644 index 4e15df3d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardFileType.cs +++ /dev/null @@ -1,22 +0,0 @@ - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Enumeration of standard file handles - /// - public enum StandardFileType - { - /// - /// Standard Input - /// - StdIn, - /// - /// Standard Output - /// - StdOut, - /// - /// Standard Error Output - /// - StdErr - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardPlatformAccessor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardPlatformAccessor.cs deleted file mode 100755 index fae7c2e1..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Platforms/StandardPlatformAccessor.cs +++ /dev/null @@ -1,287 +0,0 @@ -#if (PCL) || (UNITY_5) || NETFX_CORE -// Dummy implementation for PCL and Unity targets -using System; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Class providing the IPlatformAccessor interface for standard full-feaured implementations. - /// - public class StandardPlatformAccessor : PlatformAccessorBase - { - public override void DefaultPrint(string content) - { - throw new NotImplementedException(); - } - - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - throw new NotImplementedException(); - } - - public override string GetEnvironmentVariable(string envvarname) - { - throw new NotImplementedException(); - } - - public override string GetPlatformNamePrefix() - { - throw new NotImplementedException(); - } - - public override Stream IO_GetStandardStream(StandardFileType type) - { - throw new NotImplementedException(); - } - - public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - throw new NotImplementedException(); - } - - public override string IO_OS_GetTempFilename() - { - throw new NotImplementedException(); - } - - public override int OS_Execute(string cmdline) - { - throw new NotImplementedException(); - } - - public override void OS_ExitFast(int exitCode) - { - throw new NotImplementedException(); - } - - public override void OS_FileDelete(string file) - { - throw new NotImplementedException(); - } - - public override bool OS_FileExists(string file) - { - throw new NotImplementedException(); - } - - public override void OS_FileMove(string src, string dst) - { - throw new NotImplementedException(); - } - } -} -#else -using System; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace MoonSharp.Interpreter.Platforms -{ - /// - /// Class providing the IPlatformAccessor interface for standard full-feaured implementations. - /// - public class StandardPlatformAccessor : PlatformAccessorBase - { - /// - /// Converts a Lua string access mode to a FileAccess enum - /// - /// The mode. - /// - public static FileAccess ParseFileAccess(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileAccess.Read; - else if (mode == "r+") - return FileAccess.ReadWrite; - else if (mode == "w") - return FileAccess.Write; - else if (mode == "w+") - return FileAccess.ReadWrite; - else - return FileAccess.ReadWrite; - } - - /// - /// Converts a Lua string access mode to a ParseFileMode enum - /// - /// The mode. - /// - public static FileMode ParseFileMode(string mode) - { - mode = mode.Replace("b", ""); - - if (mode == "r") - return FileMode.Open; - else if (mode == "r+") - return FileMode.OpenOrCreate; - else if (mode == "w") - return FileMode.Create; - else if (mode == "w+") - return FileMode.Truncate; - else - return FileMode.Append; - } - - - /// - /// A function used to open files in the 'io' module. - /// Can have an invalid implementation if 'io' module is filtered out. - /// It should return a correctly initialized Stream for the given file and access - /// - /// - /// The filename. - /// The encoding. - /// The mode (as per Lua usage - e.g. 'w+', 'rb', etc.). - /// - public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - return new FileStream(filename, ParseFileMode(mode), ParseFileAccess(mode), FileShare.ReadWrite | FileShare.Delete); - } - - /// - /// Gets an environment variable. Must be implemented, but an implementation is allowed - /// to always return null if a more meaningful implementation cannot be achieved or is - /// not desired. - /// - /// The envvarname. - /// - /// The environment variable value, or null if not found - /// - public override string GetEnvironmentVariable(string envvarname) - { - return Environment.GetEnvironmentVariable(envvarname); - } - - /// - /// Gets a standard stream (stdin, stdout, stderr). - /// - /// The type. - /// - /// type - public override Stream IO_GetStandardStream(StandardFileType type) - { - switch (type) - { - case StandardFileType.StdIn: - return Console.OpenStandardInput(); - case StandardFileType.StdOut: - return Console.OpenStandardOutput(); - case StandardFileType.StdErr: - return Console.OpenStandardError(); - default: - throw new ArgumentException("type"); - } - } - - /// - /// Default handler for 'print' calls. Can be customized in ScriptOptions - /// - /// The content. - public override void DefaultPrint(string content) - { - Console.WriteLine(content); - } - - - /// - /// Gets a temporary filename. Used in 'io' and 'os' modules. - /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. - /// - /// - public override string IO_OS_GetTempFilename() - { - return Path.GetTempFileName(); - } - - /// - /// Exits the process, returning the specified exit code. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The exit code. - public override void OS_ExitFast(int exitCode) - { - Environment.Exit(exitCode); - } - - /// - /// Checks if a file exists. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - /// - /// True if the file exists, false otherwise. - /// - public override bool OS_FileExists(string file) - { - return File.Exists(file); - } - - /// - /// Deletes the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The file. - public override void OS_FileDelete(string file) - { - File.Delete(file); - } - - /// - /// Moves the specified file. Used by the 'os' module. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The source. - /// The DST. - public override void OS_FileMove(string src, string dst) - { -#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - File.Move(src, dst); -#endif - } - - /// - /// Executes the specified command line, returning the child process exit code and blocking in the meantime. - /// Can have an invalid implementation if the 'os' module is filtered out. - /// - /// The cmdline. - /// - public override int OS_Execute(string cmdline) - { - // This is windows only! - ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", string.Format("/C {0}", cmdline)); - psi.ErrorDialog = false; - - Process proc = Process.Start(psi); - proc.WaitForExit(); - return proc.ExitCode; - } - - /// - /// Filters the CoreModules enumeration to exclude non-supported operations - /// - /// The requested modules. - /// - /// The requested modules, with unsupported modules filtered out. - /// - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - return module; - } - - /// - /// Gets the platform name prefix - /// - /// - /// - public override string GetPlatformNamePrefix() - { - return "std"; - } - } -} -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplHistoryNavigator.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplHistoryNavigator.cs deleted file mode 100644 index 61fb7ce0..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplHistoryNavigator.cs +++ /dev/null @@ -1,73 +0,0 @@ - -namespace MoonSharp.Interpreter.REPL -{ - /// - /// An implementation of which supports a very basic history of recent input lines. - /// - public class ReplHistoryInterpreter : ReplInterpreter - { - string[] m_History; - int m_Last = -1; - int m_Navi = -1; - - /// - /// Initializes a new instance of the class. - /// - /// The script. - /// Size of the history. - public ReplHistoryInterpreter(Script script, int historySize) - : base(script) - { - m_History = new string[historySize]; - } - - - /// - /// Evaluate a REPL command. - /// This method returns the result of the computation, or null if more input is needed for having valid code. - /// In case of errors, exceptions are propagated to the caller. - /// - /// The input. - /// - /// This method returns the result of the computation, or null if more input is needed for a computation. - /// - public override DynValue Evaluate(string input) - { - m_Navi = -1; - m_Last = (m_Last + 1) % m_History.Length; - m_History[m_Last] = input; - return base.Evaluate(input); - } - - /// - /// Gets the previous item in history, or null - /// - public string HistoryPrev() - { - if (m_Navi == -1) - m_Navi = m_Last; - else - m_Navi = ((m_Navi - 1) + m_History.Length) % m_History.Length; - - if (m_Navi >= 0) return m_History[m_Navi]; - return null; - } - - /// - /// Gets the next item in history, or null - /// - public string HistoryNext() - { - if (m_Navi == -1) - return null; - else - m_Navi = (m_Navi + 1) % m_History.Length; - - if (m_Navi >= 0) return m_History[m_Navi]; - return null; - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreter.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreter.cs deleted file mode 100644 index 155abd0e..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreter.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.REPL -{ - /// - /// This class provides a simple REPL intepreter ready to be reused in a simple way. - /// - public class ReplInterpreter - { - Script m_Script; - string m_CurrentCommand = string.Empty; - - /// - /// Initializes a new instance of the class. - /// - /// The script. - public ReplInterpreter(Script script) - { - this.m_Script = script; - } - - /// - /// Gets or sets a value indicating whether this instances handle inputs starting with a "?" as a - /// dynamic expression to evaluate instead of script code (likely invalid) - /// - public bool HandleDynamicExprs { get; set; } - - /// - /// Gets or sets a value indicating whether this instances handle inputs starting with a "=" as a - /// non-dynamic expression to evaluate (just like the Lua interpreter does by default). - /// - public bool HandleClassicExprsSyntax { get; set; } - - /// - /// Gets a value indicating whether this instance has a pending command - /// - public virtual bool HasPendingCommand { get { return m_CurrentCommand.Length > 0; } } - - /// - /// Gets the current pending command. - /// - public virtual string CurrentPendingCommand { get { return m_CurrentCommand; } } - - /// - /// Gets the classic prompt (">" or ">>") given the current state of the interpreter - /// - public virtual string ClassicPrompt { get { return HasPendingCommand ? ">>" : ">"; } } - - /// - /// Evaluate a REPL command. - /// This method returns the result of the computation, or null if more input is needed for having valid code. - /// In case of errors, exceptions are propagated to the caller. - /// - /// The input. - /// This method returns the result of the computation, or null if more input is needed for a computation. - public virtual DynValue Evaluate(string input) - { - bool isFirstLine = !HasPendingCommand; - - bool forced = (input == ""); - - m_CurrentCommand += input; - - if (m_CurrentCommand.Length == 0) - return DynValue.Void; - - m_CurrentCommand += "\n"; - - try - { - DynValue result = null; - - if (isFirstLine && HandleClassicExprsSyntax && m_CurrentCommand.StartsWith("=")) - { - m_CurrentCommand = "return " + m_CurrentCommand.Substring(1); - } - - if (isFirstLine && HandleDynamicExprs && m_CurrentCommand.StartsWith("?")) - { - var code = m_CurrentCommand.Substring(1); - var exp = m_Script.CreateDynamicExpression(code); - result = exp.Evaluate(); - } - else - { - var v = m_Script.LoadString(m_CurrentCommand, null, "stdin"); - result = m_Script.Call(v); - } - - m_CurrentCommand = ""; - return result; - } - catch (SyntaxErrorException ex) - { - if (forced || !ex.IsPrematureStreamTermination) - { - m_CurrentCommand = ""; - ex.Rethrow(); - throw; - } - else - { - return null; - } - } - catch (ScriptRuntimeException sre) - { - m_CurrentCommand = ""; - sre.Rethrow(); - throw; - } - catch (Exception) - { - m_CurrentCommand = ""; - throw; - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreterScriptLoader.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreterScriptLoader.cs deleted file mode 100755 index 198bade8..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/REPL/ReplInterpreterScriptLoader.cs +++ /dev/null @@ -1,71 +0,0 @@ -#if !(PCL || ENABLE_DOTNET || NETFX_CORE) -using System; -using MoonSharp.Interpreter.Loaders; - -namespace MoonSharp.Interpreter.REPL -{ - /// - /// A script loader loading scripts directly from the file system (does not go through platform object) - /// AND starts with module paths taken from environment variables (again, not going through the platform object). - /// - /// The paths are preconstructed using : - /// * The MOONSHARP_PATH environment variable if it exists - /// * The LUA_PATH_5_2 environment variable if MOONSHARP_PATH does not exists - /// * The LUA_PATH environment variable if LUA_PATH_5_2 and MOONSHARP_PATH do not exists - /// * The "?;?.lua" path if all the above fail - /// - /// Also, everytime a module is require(d), the "LUA_PATH" global variable is checked. If it exists, those paths - /// will be used to load the module instead of the global ones. - /// - public class ReplInterpreterScriptLoader : FileSystemScriptLoader - { - /// - /// Initializes a new instance of the class. - /// - public ReplInterpreterScriptLoader() - { - string env = Environment.GetEnvironmentVariable("MOONSHARP_PATH"); - if (!string.IsNullOrEmpty(env)) ModulePaths = UnpackStringPaths(env); - - if (ModulePaths == null) - { - env = Environment.GetEnvironmentVariable("LUA_PATH_5_2"); - if (!string.IsNullOrEmpty(env)) ModulePaths = UnpackStringPaths(env); - } - - if (ModulePaths == null) - { - env = Environment.GetEnvironmentVariable("LUA_PATH"); - if (!string.IsNullOrEmpty(env)) ModulePaths = UnpackStringPaths(env); - } - - if (ModulePaths == null) - { - ModulePaths = UnpackStringPaths("?;?.lua"); - } - } - - /// - /// Resolves the name of a module to a filename (which will later be passed to OpenScriptFile). - /// The resolution happens first on paths included in the LUA_PATH global variable, and - - /// if the variable does not exist - by consulting the - /// ScriptOptions.ModulesPaths array. Override to provide a different behaviour. - /// - /// The modname. - /// The global context. - /// - public override string ResolveModuleName(string modname, Table globalContext) - { - DynValue s = globalContext.RawGet("LUA_PATH"); - - if (s != null && s.Type == DataType.String) - return ResolveModuleName(modname, UnpackStringPaths(s.String)); - - else - return base.ResolveModuleName(modname, globalContext); - } - } -} - - -#endif \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Script.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Script.cs deleted file mode 100755 index 6e3bb11a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Script.cs +++ /dev/null @@ -1,749 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.CoreLib; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Diagnostics; -using MoonSharp.Interpreter.Execution.VM; -using MoonSharp.Interpreter.IO; -using MoonSharp.Interpreter.Platforms; -using MoonSharp.Interpreter.Tree.Expressions; -using MoonSharp.Interpreter.Tree.Fast_Interface; - -namespace MoonSharp.Interpreter -{ - /// - /// This class implements a MoonSharp scripting session. Multiple Script objects can coexist in the same program but cannot share - /// data among themselves unless some mechanism is put in place. - /// - public class Script : IScriptPrivateResource - { - /// - /// The version of the MoonSharp engine - /// - public const string VERSION = "2.0.0.0"; - - /// - /// The Lua version being supported - /// - public const string LUA_VERSION = "5.2"; - - Processor m_MainProcessor = null; - ByteCode m_ByteCode; - List m_Sources = new List(); - Table m_GlobalTable; - IDebugger m_Debugger; - Table[] m_TypeMetatables = new Table[(int)LuaTypeExtensions.MaxMetaTypes]; - - /// - /// Initializes the class. - /// - static Script() - { - GlobalOptions = new ScriptGlobalOptions(); - - DefaultOptions = new ScriptOptions() - { - DebugPrint = s => { Script.GlobalOptions.Platform.DefaultPrint(s); }, - DebugInput = s => { return Script.GlobalOptions.Platform.DefaultInput(s); }, - CheckThreadAccess = true, - ScriptLoader = PlatformAutoDetector.GetDefaultScriptLoader(), - TailCallOptimizationThreshold = 65536 - }; - } - - /// - /// Initializes a new instance of the clas.s - /// - public Script() - : this(CoreModules.Preset_Default) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The core modules to be pre-registered in the default global table. - public Script(CoreModules coreModules) - { - Options = new ScriptOptions(DefaultOptions); - PerformanceStats = new PerformanceStatistics(); - Registry = new Table(this); - - m_ByteCode = new ByteCode(this); - m_MainProcessor = new Processor(this, m_GlobalTable, m_ByteCode); - m_GlobalTable = new Table(this).RegisterCoreModules(coreModules); - } - - - /// - /// Gets or sets the script loader which will be used as the value of the - /// ScriptLoader property for all newly created scripts. - /// - public static ScriptOptions DefaultOptions { get; private set; } - - /// - /// Gets access to the script options. - /// - public ScriptOptions Options { get; private set; } - - /// - /// Gets the global options, that is options which cannot be customized per-script. - /// - public static ScriptGlobalOptions GlobalOptions { get; private set; } - - /// - /// Gets access to performance statistics. - /// - public PerformanceStatistics PerformanceStats { get; private set; } - - /// - /// Gets the default global table for this script. Unless a different table is intentionally passed (or setfenv has been used) - /// execution uses this table. - /// - public Table Globals - { - get { return m_GlobalTable; } - } - - /// - /// Loads a string containing a Lua/MoonSharp function. - /// - /// The code. - /// The global table to bind to this chunk. - /// Name of the function used to report errors, etc. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public DynValue LoadFunction(string code, Table globalTable = null, string funcFriendlyName = null) - { - this.CheckScriptOwnership(globalTable); - - string chunkName = string.Format("libfunc_{0}", funcFriendlyName ?? m_Sources.Count.ToString()); - - SourceCode source = new SourceCode(chunkName, code, m_Sources.Count, this); - - m_Sources.Add(source); - - int address = Loader_Fast.LoadFunction(this, source, m_ByteCode, globalTable != null || m_GlobalTable != null); - - SignalSourceCodeChange(source); - SignalByteCodeChange(); - - return MakeClosure(address, globalTable ?? m_GlobalTable); - } - - private void SignalByteCodeChange() - { - if (m_Debugger != null) - { - m_Debugger.SetByteCode(m_ByteCode.Code.Select(s => s.ToString()).ToArray()); - } - } - - private void SignalSourceCodeChange(SourceCode source) - { - if (m_Debugger != null) - { - m_Debugger.SetSourceCode(source); - } - } - - - /// - /// Loads a string containing a Lua/MoonSharp script. - /// - /// The code. - /// The global table to bind to this chunk. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public DynValue LoadString(string code, Table globalTable = null, string codeFriendlyName = null) - { - this.CheckScriptOwnership(globalTable); - - if (code.StartsWith(StringModule.BASE64_DUMP_HEADER)) - { - code = code.Substring(StringModule.BASE64_DUMP_HEADER.Length); - byte[] data = Convert.FromBase64String(code); - using (MemoryStream ms = new MemoryStream(data)) - return LoadStream(ms, globalTable, codeFriendlyName); - } - - string chunkName = string.Format("{0}", codeFriendlyName ?? "chunk_" + m_Sources.Count.ToString()); - - SourceCode source = new SourceCode(codeFriendlyName ?? chunkName, code, m_Sources.Count, this); - - m_Sources.Add(source); - - int address = Loader_Fast.LoadChunk(this, - source, - m_ByteCode); - - SignalSourceCodeChange(source); - SignalByteCodeChange(); - - return MakeClosure(address, globalTable ?? m_GlobalTable); - } - - /// - /// Loads a Lua/MoonSharp script from a System.IO.Stream. NOTE: This will *NOT* close the stream! - /// - /// The stream containing code. - /// The global table to bind to this chunk. - /// Name of the code - used to report errors, etc. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public DynValue LoadStream(Stream stream, Table globalTable = null, string codeFriendlyName = null) - { - this.CheckScriptOwnership(globalTable); - - Stream codeStream = new UndisposableStream(stream); - - if (!Processor.IsDumpStream(codeStream)) - { - using (StreamReader sr = new StreamReader(codeStream)) - { - string scriptCode = sr.ReadToEnd(); - return LoadString(scriptCode, globalTable, codeFriendlyName); - } - } - else - { - string chunkName = string.Format("{0}", codeFriendlyName ?? "dump_" + m_Sources.Count.ToString()); - - SourceCode source = new SourceCode(codeFriendlyName ?? chunkName, - string.Format("-- This script was decoded from a binary dump - dump_{0}", m_Sources.Count), - m_Sources.Count, this); - - m_Sources.Add(source); - - bool hasUpvalues; - int address = m_MainProcessor.Undump(codeStream, m_Sources.Count - 1, globalTable ?? m_GlobalTable, out hasUpvalues); - - SignalSourceCodeChange(source); - SignalByteCodeChange(); - - if (hasUpvalues) - return MakeClosure(address, globalTable ?? m_GlobalTable); - else - return MakeClosure(address); - } - } - - /// - /// Dumps on the specified stream. - /// - /// The function. - /// The stream. - /// - /// function arg is not a function! - /// or - /// stream is readonly! - /// or - /// function arg has upvalues other than _ENV - /// - public void Dump(DynValue function, Stream stream) - { - this.CheckScriptOwnership(function); - - if (function.Type != DataType.Function) - throw new ArgumentException("function arg is not a function!"); - - if (!stream.CanWrite) - throw new ArgumentException("stream is readonly!"); - - Closure.UpvaluesType upvaluesType = function.Function.GetUpvaluesType(); - - if (upvaluesType == Closure.UpvaluesType.Closure) - throw new ArgumentException("function arg has upvalues other than _ENV"); - - UndisposableStream outStream = new UndisposableStream(stream); - m_MainProcessor.Dump(outStream, function.Function.EntryPointByteCodeLocation, upvaluesType == Closure.UpvaluesType.Environment); - } - - - /// - /// Loads a string containing a Lua/MoonSharp script. - /// - /// The code. - /// The global table to bind to this chunk. - /// The filename to be used in error messages. - /// - /// A DynValue containing a function which will execute the loaded code. - /// - public DynValue LoadFile(string filename, Table globalContext = null, string friendlyFilename = null) - { - this.CheckScriptOwnership(globalContext); - -#pragma warning disable 618 - filename = Options.ScriptLoader.ResolveFileName(filename, globalContext ?? m_GlobalTable); -#pragma warning restore 618 - - object code = Options.ScriptLoader.LoadFile(filename, globalContext ?? m_GlobalTable); - - if (code is string) - { - return LoadString((string)code, globalContext, friendlyFilename ?? filename); - } - else if (code is byte[]) - { - using (MemoryStream ms = new MemoryStream((byte[])code)) - return LoadStream(ms, globalContext, friendlyFilename ?? filename); - } - else if (code is Stream) - { - try - { - return LoadStream((Stream)code, globalContext, friendlyFilename ?? filename); - } - finally - { - ((Stream)code).Dispose(); - } - } - else - { - if (code == null) - throw new InvalidCastException("Unexpected null from IScriptLoader.LoadFile"); - else - throw new InvalidCastException(string.Format("Unsupported return type from IScriptLoader.LoadFile : {0}", code.GetType())); - } - } - - - /// - /// Loads and executes a string containing a Lua/MoonSharp script. - /// - /// The code. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public DynValue DoString(string code, Table globalContext = null, string codeFriendlyName = null) - { - DynValue func = LoadString(code, globalContext, codeFriendlyName); - return Call(func); - } - - - /// - /// Loads and executes a stream containing a Lua/MoonSharp script. - /// - /// The stream. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public DynValue DoStream(Stream stream, Table globalContext = null, string codeFriendlyName = null) - { - DynValue func = LoadStream(stream, globalContext, codeFriendlyName); - return Call(func); - } - - - /// - /// Loads and executes a file containing a Lua/MoonSharp script. - /// - /// The filename. - /// The global context. - /// Name of the code - used to report errors, etc. Also used by debuggers to locate the original source file. - /// - /// A DynValue containing the result of the processing of the loaded chunk. - /// - public DynValue DoFile(string filename, Table globalContext = null, string codeFriendlyName = null) - { - DynValue func = LoadFile(filename, globalContext, codeFriendlyName); - return Call(func); - } - - - /// - /// Runs the specified file with all possible defaults for quick experimenting. - /// - /// The filename. - /// A DynValue containing the result of the processing of the executed script. - public static DynValue RunFile(string filename) - { - Script S = new Script(); - return S.DoFile(filename); - } - - /// - /// Runs the specified code with all possible defaults for quick experimenting. - /// - /// The Lua/MoonSharp code. - /// A DynValue containing the result of the processing of the executed script. - public static DynValue RunString(string code) - { - Script S = new Script(); - return S.DoString(code); - } - - /// - /// Creates a closure from a bytecode address. - /// - /// The address. - /// The env table to create a 0-upvalue - /// - private DynValue MakeClosure(int address, Table envTable = null) - { - this.CheckScriptOwnership(envTable); - Closure c; - - if (envTable == null) - { - Instruction meta = m_MainProcessor.FindMeta(ref address); - - // if we find the meta for a new chunk, we use the value in the meta for the _ENV upvalue - if ((meta != null) && (meta.NumVal2 == (int)OpCodeMetadataType.ChunkEntrypoint)) - { - c = new Closure(this, address, - new SymbolRef[] { SymbolRef.Upvalue(WellKnownSymbols.ENV, 0) }, - new DynValue[] { meta.Value }); - } - else - { - c = new Closure(this, address, new SymbolRef[0], new DynValue[0]); - } - } - else - { - var syms = new SymbolRef[] { - new SymbolRef() { i_Env = null, i_Index= 0, i_Name = WellKnownSymbols.ENV, i_Type = SymbolRefType.DefaultEnv }, - }; - - var vals = new DynValue[] { - DynValue.NewTable(envTable) - }; - - c = new Closure(this, address, syms, vals); - } - - return DynValue.NewClosure(c); - } - - /// - /// Calls the specified function. - /// - /// The Lua/MoonSharp function to be called - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(DynValue function) - { - return Call(function, new DynValue[0]); - } - - /// - /// Calls the specified function. - /// - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(DynValue function, params DynValue[] args) - { - this.CheckScriptOwnership(function); - this.CheckScriptOwnership(args); - - if (function.Type != DataType.Function && function.Type != DataType.ClrFunction) - { - DynValue metafunction = m_MainProcessor.GetMetamethod(function, "__call"); - - if (metafunction != null) - { - DynValue[] metaargs = new DynValue[args.Length + 1]; - metaargs[0] = function; - for (int i = 0; i < args.Length; i++) - metaargs[i + 1] = args[i]; - - function = metafunction; - args = metaargs; - } - else - { - throw new ArgumentException("function is not a function and has no __call metamethod."); - } - } - else if (function.Type == DataType.ClrFunction) - { - return function.Callback.ClrCallback(this.CreateDynamicExecutionContext(function.Callback), new CallbackArguments(args, false)); - } - - return m_MainProcessor.Call(function, args); - } - - /// - /// Calls the specified function. - /// - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// The return value(s) of the function call. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(DynValue function, params object[] args) - { - DynValue[] dargs = new DynValue[args.Length]; - - for (int i = 0; i < dargs.Length; i++) - dargs[i] = DynValue.FromObject(this, args[i]); - - return Call(function, dargs); - } - - /// - /// Calls the specified function. - /// - /// The Lua/MoonSharp function to be called - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(object function) - { - return Call(DynValue.FromObject(this, function)); - } - - /// - /// Calls the specified function. - /// - /// The Lua/MoonSharp function to be called - /// The arguments to pass to the function. - /// - /// Thrown if function is not of DataType.Function - public DynValue Call(object function, params object[] args) - { - return Call(DynValue.FromObject(this, function), args); - } - - /// - /// Creates a coroutine pointing at the specified function. - /// - /// The function. - /// - /// The coroutine handle. - /// - /// Thrown if function is not of DataType.Function or DataType.ClrFunction - public DynValue CreateCoroutine(DynValue function) - { - this.CheckScriptOwnership(function); - - if (function.Type == DataType.Function) - return m_MainProcessor.Coroutine_Create(function.Function); - else if (function.Type == DataType.ClrFunction) - return DynValue.NewCoroutine(new Coroutine(function.Callback)); - else - throw new ArgumentException("function is not of DataType.Function or DataType.ClrFunction"); - } - - /// - /// Creates a coroutine pointing at the specified function. - /// - /// The function. - /// - /// The coroutine handle. - /// - /// Thrown if function is not of DataType.Function or DataType.ClrFunction - public DynValue CreateCoroutine(object function) - { - return CreateCoroutine(DynValue.FromObject(this, function)); - } - - /// - /// Gets or sets a value indicating whether the debugger is enabled. - /// Note that unless a debugger attached, this property returns a - /// value which might not reflect the real status of the debugger. - /// Use this property if you want to disable the debugger for some - /// executions. - /// - public bool DebuggerEnabled - { - get { return m_MainProcessor.DebuggerEnabled; } - set { m_MainProcessor.DebuggerEnabled = value; } - } - - - /// - /// Attaches a debugger. This usually should be called by the debugger itself and not by user code. - /// - /// The debugger object. - public void AttachDebugger(IDebugger debugger) - { - DebuggerEnabled = true; - m_Debugger = debugger; - m_MainProcessor.AttachDebugger(debugger); - - foreach (SourceCode src in m_Sources) - SignalSourceCodeChange(src); - - SignalByteCodeChange(); - } - - /// - /// Gets the source code. - /// - /// The source code identifier. - /// - public SourceCode GetSourceCode(int sourceCodeID) - { - return m_Sources[sourceCodeID]; - } - - - /// - /// Gets the source code count. - /// - /// - /// The source code count. - /// - public int SourceCodeCount - { - get { return m_Sources.Count; } - } - - - - /// - /// Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html - /// - /// The module name - /// The global context. - /// - /// Raised if module is not found - public DynValue RequireModule(string modname, Table globalContext = null) - { - this.CheckScriptOwnership(globalContext); - - Table globals = globalContext ?? m_GlobalTable; - string filename = Options.ScriptLoader.ResolveModuleName(modname, globals); - - if (filename == null) - throw new ScriptRuntimeException("module '{0}' not found", modname); - - DynValue func = LoadFile(filename, globalContext, filename); - return func; - } - - - - /// - /// Gets a type metatable. - /// - /// The type. - /// - public Table GetTypeMetatable(DataType type) - { - int t = (int)type; - - if (t >= 0 && t < m_TypeMetatables.Length) - return m_TypeMetatables[t]; - - return null; - } - - /// - /// Sets a type metatable. - /// - /// The type. Must be Nil, Boolean, Number, String or Function - /// The metatable. - /// Specified type not supported : + type.ToString() - public void SetTypeMetatable(DataType type, Table metatable) - { - this.CheckScriptOwnership(metatable); - - int t = (int)type; - - if (t >= 0 && t < m_TypeMetatables.Length) - m_TypeMetatables[t] = metatable; - else - throw new ArgumentException("Specified type not supported : " + type.ToString()); - } - - - /// - /// Warms up the parser/lexer structures so that MoonSharp operations start faster. - /// - public static void WarmUp() - { - Script s = new Script(CoreModules.Basic); - s.LoadString("return 1;"); - } - - - /// - /// Creates a new dynamic expression. - /// - /// The code of the expression. - /// - public DynamicExpression CreateDynamicExpression(string code) - { - DynamicExprExpression dee = Loader_Fast.LoadDynamicExpr(this, new SourceCode("__dynamic", code, -1, this)); - return new DynamicExpression(this, code, dee); - } - - /// - /// Creates a new dynamic expression which is actually quite static, returning always the same constant value. - /// - /// The code of the not-so-dynamic expression. - /// The constant to return. - /// - public DynamicExpression CreateConstantDynamicExpression(string code, DynValue constant) - { - this.CheckScriptOwnership(constant); - - return new DynamicExpression(this, code, constant); - } - - /// - /// Gets an execution context exposing only partial functionality, which should be used for - /// those cases where the execution engine is not really running - for example for dynamic expression - /// or calls from CLR to CLR callbacks - /// - internal ScriptExecutionContext CreateDynamicExecutionContext(CallbackFunction func = null) - { - return new ScriptExecutionContext(m_MainProcessor, func, null, isDynamic: true); - } - - /// - /// MoonSharp (like Lua itself) provides a registry, a predefined table that can be used by any CLR code to - /// store whatever Lua values it needs to store. - /// Any CLR code can store data into this table, but it should take care to choose keys - /// that are different from those used by other libraries, to avoid collisions. - /// Typically, you should use as key a string GUID, a string containing your library name, or a - /// userdata with the address of a CLR object in your code. - /// - public Table Registry - { - get; - private set; - } - - /// - /// Gets a banner string with copyright info, link to website, version, etc. - /// - public static string GetBanner(string subproduct = null) - { - subproduct = (subproduct != null) ? (subproduct + " ") : ""; - - StringBuilder sb = new StringBuilder(); - sb.AppendLine(string.Format("MoonSharp {0}{1} [{2}]", subproduct, Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName())); - sb.AppendLine("Copyright (C) 2014-2016 Marco Mastropaolo"); - sb.AppendLine("http://www.moonsharp.org"); - return sb.ToString(); - } - - Script IScriptPrivateResource.OwnerScript - { - get { return this; } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptGlobalOptions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptGlobalOptions.cs deleted file mode 100644 index 3544c703..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptGlobalOptions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using MoonSharp.Interpreter.Interop; -using MoonSharp.Interpreter.Platforms; -using MoonSharp.Interpreter; - -namespace MoonSharp.Interpreter -{ - /// - /// Class containing script global options, that is options which cannot be customized per-script. - /// - /// - public class ScriptGlobalOptions { - internal ScriptGlobalOptions() { - Platform = PlatformAutoDetector.GetDefaultPlatform(); - CustomConverters = new CustomConvertersCollection(); - FuzzySymbolMatching = FuzzySymbolMatchingBehavior.Camelify | FuzzySymbolMatchingBehavior.UpperFirstLetter | FuzzySymbolMatchingBehavior.PascalCase; - } - - /// - /// Gets or sets the custom converters. - /// - public CustomConvertersCollection CustomConverters { get; set; } - - /// - /// Gets or sets the platform abstraction to use. - /// - /// - /// The current platform abstraction. - /// - public IPlatformAccessor Platform { get; set; } - - /// - /// Gets or sets a value indicating whether interpreter exceptions should be - /// re-thrown as nested exceptions. - /// - public bool RethrowExceptionNested { get; set; } - - /// - /// Gets or sets an enum that controls behaviour when a symbol (method, property, userdata) is not found in a userdata's descriptor. For instance, - /// when this value is and Lua code calls the non-existent method someuserdata.someMethod(), - /// someuserdata.SomeMethod() will also be tried. - /// - public FuzzySymbolMatchingBehavior FuzzySymbolMatching { get; set; } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptOptions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptOptions.cs deleted file mode 100644 index f74131a9..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/ScriptOptions.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.IO; -using MoonSharp.Interpreter.Loaders; - -namespace MoonSharp.Interpreter -{ - /// - /// This class contains options to customize behaviour of Script objects. - /// - public class ScriptOptions - { - internal ScriptOptions() - { - } - - internal ScriptOptions(ScriptOptions defaults) - { - this.DebugInput = defaults.DebugInput; - this.DebugPrint = defaults.DebugPrint; - - this.UseLuaErrorLocations = defaults.UseLuaErrorLocations; - this.Stdin = defaults.Stdin; - this.Stdout = defaults.Stdout; - this.Stderr = defaults.Stderr; - this.TailCallOptimizationThreshold = defaults.TailCallOptimizationThreshold; - - this.ScriptLoader = defaults.ScriptLoader; - - this.CheckThreadAccess = defaults.CheckThreadAccess; - } - - /// - /// Gets or sets the current script-loader. - /// - public IScriptLoader ScriptLoader { get; set; } - - /// - /// Gets or sets the debug print handler - /// - public Action DebugPrint { get; set; } - - /// - /// Gets or sets the debug input handler (takes a prompt as an input, for interactive interpreters, like debug.debug). - /// - public Func DebugInput { get; set; } - - /// - /// Gets or sets a value indicating whether error messages will use Lua error locations instead of MoonSharp - /// improved ones. Use this for compatibility with legacy Lua code which parses error messages. - /// - public bool UseLuaErrorLocations { get; set; } - - /// - /// Gets or sets a value which dictates the behaviour of the colon (':') operator in callbacks to CLR code. - /// - public ColonOperatorBehaviour ColonOperatorClrCallbackBehaviour { get; set; } - - /// - /// Gets or sets the stream used as stdin. If null, a default stream is used. - /// - public Stream Stdin { get; set; } - - /// - /// Gets or sets the stream used as stdout. If null, a default stream is used. - /// - public Stream Stdout { get; set; } - - /// - /// Gets or sets the stream used as stderr. If null, a default stream is used. - /// - public Stream Stderr { get; set; } - - /// - /// Gets or sets the stack depth threshold at which MoonSharp starts doing - /// tail call optimizations. - /// TCOs can provide the little benefit of avoiding stack overflows in corner case - /// scenarios, at the expense of losing debug information and error stack traces - /// in all other, more common scenarios. MoonSharp choice is to start performing - /// TCOs only after a certain threshold of stack usage is reached - by default - /// half the current stack depth (128K entries), thus 64K entries, on either - /// the internal stacks. - /// Set this to int.MaxValue to disable TCOs entirely, or to 0 to always have - /// TCOs enabled. - /// - public int TailCallOptimizationThreshold { get; set; } - - /// - /// Gets or sets a value indicating whether the thread check is enabled. - /// A "lazy" thread check is performed everytime execution is entered to ensure that no two threads - /// calls MoonSharp execution concurrently. However 1) the check is performed best effort (thus, it might - /// not detect all issues) and 2) it might trigger in very odd legal situations (like, switching threads - /// inside a CLR-callback without actually having concurrency. - /// - /// Disable this option if the thread check is giving problems in your scenario, but please check that - /// you are not calling MoonSharp execution concurrently as it is not supported. - /// - public bool CheckThreadAccess { get; set; } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonNull.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonNull.cs deleted file mode 100755 index 0c1e7490..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonNull.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Serialization.Json -{ - /// - /// UserData representing a null value in a table converted from Json - /// - public sealed class JsonNull - { - public static bool isNull() { return true; } - - [MoonSharpHidden] - public static bool IsJsonNull(DynValue v) - { - return v.Type == DataType.UserData && - v.UserData.Descriptor != null && - v.UserData.Descriptor.Type == typeof(JsonNull); - } - - [MoonSharpHidden] - public static DynValue Create() - { - return UserData.CreateStatic(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonTableConverter.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonTableConverter.cs deleted file mode 100755 index 2615d251..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/Json/JsonTableConverter.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Tree; - -namespace MoonSharp.Interpreter.Serialization.Json -{ - /// - /// Class performing conversions between Tables and Json. - /// NOTE : the conversions are done respecting json syntax but using Lua constructs. This means mostly that: - /// 1) Lua string escapes can be accepted while they are not technically valid JSON, and viceversa - /// 2) Null values are represented using a static userdata of type JsonNull - /// 3) Do not use it when input cannot be entirely trusted - /// - public static class JsonTableConverter - { - /// - /// Converts a table to a json string - /// - /// The table. - /// - public static string TableToJson(this Table table) - { - StringBuilder sb = new StringBuilder(); - TableToJson(sb, table); - return sb.ToString(); - } - - /// - /// Tables to json. - /// - /// The sb. - /// The table. - private static void TableToJson(StringBuilder sb, Table table) - { - bool first = true; - - if (table.Length == 0) - { - sb.Append("{"); - foreach (TablePair pair in table.Pairs) - { - if (pair.Key.Type == DataType.String && IsValueJsonCompatible(pair.Value)) - { - if (!first) - sb.Append(','); - - ValueToJson(sb, pair.Key); - sb.Append(':'); - ValueToJson(sb, pair.Value); - - first = false; - } - } - sb.Append("}"); - } - else - { - sb.Append("["); - for (int i = 1; i <= table.Length; i++) - { - DynValue value = table.Get(i); - if (IsValueJsonCompatible(value)) - { - if (!first) - sb.Append(','); - - ValueToJson(sb, value); - - first = false; - } - } - sb.Append("]"); - } - } - - /// - /// Converts a generic object to JSON - /// - public static string ObjectToJson(object obj) - { - DynValue v = ObjectValueConverter.SerializeObjectToDynValue(null, obj, JsonNull.Create()); - return JsonTableConverter.TableToJson(v.Table); - } - - - - private static void ValueToJson(StringBuilder sb, DynValue value) - { - switch (value.Type) - { - case DataType.Boolean: - sb.Append(value.Boolean ? "true" : "false"); - break; - case DataType.Number: - sb.Append(value.Number.ToString("r")); - break; - case DataType.String: - sb.Append(EscapeString(value.String ?? "")); - break; - case DataType.Table: - TableToJson(sb, value.Table); - break; - case DataType.Nil: - case DataType.Void: - case DataType.UserData: - default: - sb.Append("null"); - break; - } - } - - private static string EscapeString(string s) - { - s = s.Replace(@"\", @"\\"); - s = s.Replace(@"/", @"\/"); - s = s.Replace("\"", "\\\""); - s = s.Replace("\f", @"\f"); - s = s.Replace("\b", @"\b"); - s = s.Replace("\n", @"\n"); - s = s.Replace("\r", @"\r"); - s = s.Replace("\t", @"\t"); - return "\"" + s + "\""; - } - - private static bool IsValueJsonCompatible(DynValue value) - { - return value.Type == DataType.Boolean || value.IsNil() || - value.Type == DataType.Number || value.Type == DataType.String || - value.Type == DataType.Table || - (JsonNull.IsJsonNull(value)); - } - - /// - /// Converts a json string to a table - /// - /// The json. - /// The script to which the table is assigned (null for prime tables). - /// A table containing the representation of the given json. - public static Table JsonToTable(string json, Script script = null) - { - Lexer L = new Lexer(0, json, false); - - if (L.Current.Type == TokenType.Brk_Open_Curly) - return ParseJsonObject(L, script); - else if (L.Current.Type == TokenType.Brk_Open_Square) - return ParseJsonArray(L, script); - else - throw new SyntaxErrorException(L.Current, "Unexpected token : '{0}'", L.Current.Text); - } - - private static void AssertToken(Lexer L, TokenType type) - { - if (L.Current.Type != type) - throw new SyntaxErrorException(L.Current, "Unexpected token : '{0}'", L.Current.Text); - } - private static Table ParseJsonArray(Lexer L, Script script) - { - Table t = new Table(script); - - L.Next(); - - while (L.Current.Type != TokenType.Brk_Close_Square) - { - DynValue v = ParseJsonValue(L, script); - t.Append(v); - L.Next(); - - if (L.Current.Type == TokenType.Comma) - L.Next(); - } - - return t; - } - - private static Table ParseJsonObject(Lexer L, Script script) - { - Table t = new Table(script); - - L.Next(); - - while (L.Current.Type != TokenType.Brk_Close_Curly) - { - AssertToken(L, TokenType.String); - string key = L.Current.Text; - L.Next(); - AssertToken(L, TokenType.Colon); - L.Next(); - DynValue v = ParseJsonValue(L, script); - t.Set(key, v); - L.Next(); - - if (L.Current.Type == TokenType.Comma) - L.Next(); - } - - return t; - } - - private static DynValue ParseJsonValue(Lexer L, Script script) - { - if (L.Current.Type == TokenType.Brk_Open_Curly) - { - Table t = ParseJsonObject(L, script); - return DynValue.NewTable(t); - } - else if (L.Current.Type == TokenType.Brk_Open_Square) - { - Table t = ParseJsonArray(L, script); - return DynValue.NewTable(t); - } - else if (L.Current.Type == TokenType.String) - { - return DynValue.NewString(L.Current.Text); - } - else if (L.Current.Type == TokenType.Number || L.Current.Type == TokenType.Op_MinusOrSub) - { - return ParseJsonNumberValue(L, script); - } - else if (L.Current.Type == TokenType.True) - { - return DynValue.True; - } - else if (L.Current.Type == TokenType.False) - { - return DynValue.False; - } - else if (L.Current.Type == TokenType.Name && L.Current.Text == "null") - { - return JsonNull.Create(); - } - else - { - throw new SyntaxErrorException(L.Current, "Unexpected token : '{0}'", L.Current.Text); - } - } - - private static DynValue ParseJsonNumberValue(Lexer L, Script script) - { - bool negative; - if (L.Current.Type == TokenType.Op_MinusOrSub) - { - // Negative number consists of 2 tokens. - L.Next(); - negative = true; - } - else - { - negative = false; - } - if (L.Current.Type != TokenType.Number) - { - throw new SyntaxErrorException(L.Current, "Unexpected token : '{0}'", L.Current.Text); - } - var numberValue = L.Current.GetNumberValue(); - if (negative) - { - numberValue = -numberValue; - } - return DynValue.NewNumber(numberValue).AsReadOnly(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/ObjectValueConverter.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/ObjectValueConverter.cs deleted file mode 100755 index 62263403..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/ObjectValueConverter.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility; -using MoonSharp.Interpreter.Interop.Converters; - -namespace MoonSharp.Interpreter.Serialization -{ - public static class ObjectValueConverter - { - public static DynValue SerializeObjectToDynValue(Script script, object o, DynValue valueForNulls = null) - { - if (o == null) - return valueForNulls ?? DynValue.Nil; - - DynValue v = ClrToScriptConversions.TryObjectToTrivialDynValue(script, o); - - if (v != null) - return v; - - if (o is Enum) - return DynValue.NewNumber(NumericConversions.TypeToDouble(Enum.GetUnderlyingType(o.GetType()), o)); - - Table t = new Table(script); - - System.Collections.IEnumerable ienum = o as System.Collections.IEnumerable; - - if (ienum != null) - { - foreach (object obj in ienum) - { - t.Append(SerializeObjectToDynValue(script, obj, valueForNulls)); - } - } - else - { - Type type = o.GetType(); - - foreach (PropertyInfo pi in Framework.Do.GetProperties(type)) - { - var getter = Framework.Do.GetGetMethod(pi); - var isStatic = getter.IsStatic; - var obj = getter.Invoke(isStatic ? null : o, null); // convoluted workaround for --full-aot Mono execution - - t.Set(pi.Name, SerializeObjectToDynValue(script, obj, valueForNulls)); - } - } - - return DynValue.NewTable(t); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/SerializationExtensions.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/SerializationExtensions.cs deleted file mode 100755 index af2db8c3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Serialization/SerializationExtensions.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Serialization -{ - /// - /// - /// - public static class SerializationExtensions - { - static HashSet LUAKEYWORDS = new HashSet() - { - "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while" - }; - - - public static string Serialize(this Table table, bool prefixReturn = false, int tabs = 0) - { - if (table.OwnerScript != null) - throw new ScriptRuntimeException("Table is not a prime table."); - - string tabstr = new string('\t', tabs); - StringBuilder sb = new StringBuilder(); - - //sb.Append(tabstr); - - if (prefixReturn) - sb.Append("return "); - - if (!table.Values.Any()) - { - sb.Append("${ }"); - return sb.ToString(); - } - - sb.AppendLine("${"); - - foreach (TablePair tp in table.Pairs) - { - sb.Append(tabstr); - - string key = - IsStringIdentifierValid(tp.Key) ? - tp.Key.String : "[" + SerializeValue(tp.Key, tabs + 1) +"]"; - - sb.AppendFormat("\t{0} = {1},\n", - key, SerializeValue(tp.Value, tabs + 1)); - } - - sb.Append(tabstr); - sb.Append("}"); - - if (tabs == 0) - sb.AppendLine(); - - return sb.ToString(); - } - - private static bool IsStringIdentifierValid(DynValue dynValue) - { - if (dynValue.Type != DataType.String) - return false; - - if (dynValue.String.Length == 0) - return false; - - if (LUAKEYWORDS.Contains(dynValue.String)) - return false; - - if (!char.IsLetter(dynValue.String[0]) && (dynValue.String[0] != '_')) - return false; - - foreach (char c in dynValue.String) - { - if (!char.IsLetterOrDigit(c) && c != '_') - return false; - } - - return true; - } - - public static string SerializeValue(this DynValue dynValue, int tabs = 0) - { - if (dynValue.Type == DataType.Nil || dynValue.Type == DataType.Void) - return "nil"; - else if (dynValue.Type == DataType.Tuple) - return (dynValue.Tuple.Any() ? SerializeValue(dynValue.Tuple[0], tabs) : "nil"); - else if (dynValue.Type == DataType.Number) - return dynValue.Number.ToString("r"); - else if (dynValue.Type == DataType.Boolean) - return dynValue.Boolean ? "true" : "false"; - else if (dynValue.Type == DataType.String) - return EscapeString(dynValue.String ?? ""); - else if (dynValue.Type == DataType.Table && dynValue.Table.OwnerScript == null) - return Serialize(dynValue.Table, false, tabs); - else - throw new ScriptRuntimeException("Value is not a primitive value or a prime table."); - } - - private static string EscapeString(string s) - { - s = s.Replace(@"\", @"\\"); - s = s.Replace("\n", @"\n"); - s = s.Replace("\r", @"\r"); - s = s.Replace("\t", @"\t"); - s = s.Replace("\a", @"\a"); - s = s.Replace("\f", @"\f"); - s = s.Replace("\b", @"\b"); - s = s.Replace("\v", @"\v"); - s = s.Replace("\"", "\\\""); - s = s.Replace("\'", @"\'"); - return "\"" + s + "\""; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expression_.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expression_.cs deleted file mode 100644 index d0235bbb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expression_.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree -{ - abstract class Expression : NodeBase - { - public Expression(ScriptLoadingContext lcontext) - : base(lcontext) - { } - - public virtual string GetFriendlyDebugName() - { - return null; - } - - public abstract DynValue Eval(ScriptExecutionContext context); - - public virtual SymbolRef FindDynamic(ScriptExecutionContext context) - { - return null; - } - - internal static List ExprListAfterFirstExpr(ScriptLoadingContext lcontext, Expression expr1) - { - List exps = new List(); - - exps.Add(expr1); - - while ((lcontext.Lexer.Current.Type == TokenType.Comma)) - { - lcontext.Lexer.Next(); - exps.Add(Expr(lcontext)); - } - - return exps; - } - - - internal static List ExprList(ScriptLoadingContext lcontext) - { - List exps = new List(); - - while (true) - { - exps.Add(Expr(lcontext)); - - if (lcontext.Lexer.Current.Type != TokenType.Comma) - break; - - lcontext.Lexer.Next(); - } - - return exps; - } - - internal static Expression Expr(ScriptLoadingContext lcontext) - { - return SubExpr(lcontext, true); - } - - internal static Expression SubExpr(ScriptLoadingContext lcontext, bool isPrimary) - { - Expression e = null; - - Token T = lcontext.Lexer.Current; - - if (T.IsUnaryOperator()) - { - lcontext.Lexer.Next(); - e = SubExpr(lcontext, false); - - // check for power operator -- it be damned forever and ever for being higher priority than unary ops - Token unaryOp = T; - T = lcontext.Lexer.Current; - - if (isPrimary && T.Type == TokenType.Op_Pwr) - { - List powerChain = new List(); - powerChain.Add(e); - - while (isPrimary && T.Type == TokenType.Op_Pwr) - { - lcontext.Lexer.Next(); - powerChain.Add(SubExpr(lcontext, false)); - T = lcontext.Lexer.Current; - } - - e = powerChain[powerChain.Count - 1]; - - for (int i = powerChain.Count - 2; i >= 0; i--) - { - e = BinaryOperatorExpression.CreatePowerExpression(powerChain[i], e, lcontext); - } - } - - e = new UnaryOperatorExpression(lcontext, e, unaryOp); - } - else - { - e = SimpleExp(lcontext); - } - - T = lcontext.Lexer.Current; - - if (isPrimary && T.IsBinaryOperator()) - { - object chain = BinaryOperatorExpression.BeginOperatorChain(); - - BinaryOperatorExpression.AddExpressionToChain(chain, e); - - while (T.IsBinaryOperator()) - { - BinaryOperatorExpression.AddOperatorToChain(chain, T); - lcontext.Lexer.Next(); - Expression right = SubExpr(lcontext, false); - BinaryOperatorExpression.AddExpressionToChain(chain, right); - T = lcontext.Lexer.Current; - } - - e = BinaryOperatorExpression.CommitOperatorChain(chain, lcontext); - } - - return e; - } - - internal static Expression SimpleExp(ScriptLoadingContext lcontext) - { - Token t = lcontext.Lexer.Current; - - switch (t.Type) - { - case TokenType.Number: - case TokenType.Number_Hex: - case TokenType.Number_HexFloat: - case TokenType.String: - case TokenType.String_Long: - case TokenType.Nil: - case TokenType.True: - case TokenType.False: - return new LiteralExpression(lcontext, t); - case TokenType.VarArgs: - return new SymbolRefExpression(t, lcontext); - case TokenType.Brk_Open_Curly: - case TokenType.Brk_Open_Curly_Shared: - return new TableConstructor(lcontext, t.Type == TokenType.Brk_Open_Curly_Shared); - case TokenType.Function: - lcontext.Lexer.Next(); - return new FunctionDefinitionExpression(lcontext, false, false); - case TokenType.Lambda: - return new FunctionDefinitionExpression(lcontext, false, true); - default: - return PrimaryExp(lcontext); - } - - } - - /// - /// Primaries the exp. - /// - /// The lcontext. - /// - internal static Expression PrimaryExp(ScriptLoadingContext lcontext) - { - Expression e = PrefixExp(lcontext); - - while (true) - { - Token T = lcontext.Lexer.Current; - Token thisCallName = null; - - switch (T.Type) - { - case TokenType.Dot: - { - lcontext.Lexer.Next(); - Token name = CheckTokenType(lcontext, TokenType.Name); - e = new IndexExpression(e, name.Text, lcontext); - } - break; - case TokenType.Brk_Open_Square: - { - Token openBrk = lcontext.Lexer.Current; - lcontext.Lexer.Next(); // skip bracket - Expression index = Expr(lcontext); - - // support moonsharp multiple indexers for userdata - if (lcontext.Lexer.Current.Type == TokenType.Comma) - { - var explist = ExprListAfterFirstExpr(lcontext, index); - index = new ExprListExpression(explist, lcontext); - } - - CheckMatch(lcontext, openBrk, TokenType.Brk_Close_Square, "]"); - e = new IndexExpression(e, index, lcontext); - } - break; - case TokenType.Colon: - lcontext.Lexer.Next(); - thisCallName = CheckTokenType(lcontext, TokenType.Name); - goto case TokenType.Brk_Open_Round; - case TokenType.Brk_Open_Round: - case TokenType.String: - case TokenType.String_Long: - case TokenType.Brk_Open_Curly: - case TokenType.Brk_Open_Curly_Shared: - e = new FunctionCallExpression(lcontext, e, thisCallName); - break; - default: - return e; - } - } - } - - - - private static Expression PrefixExp(ScriptLoadingContext lcontext) - { - Token T = lcontext.Lexer.Current; - switch (T.Type) - { - case TokenType.Brk_Open_Round: - lcontext.Lexer.Next(); - Expression e = Expr(lcontext); - e = new AdjustmentExpression(lcontext, e); - CheckMatch(lcontext, T, TokenType.Brk_Close_Round, ")"); - return e; - case TokenType.Name: - return new SymbolRefExpression(T, lcontext); - default: - throw new SyntaxErrorException(T, "unexpected symbol near '{0}'", T.Text) - { - IsPrematureStreamTermination = (T.Type == TokenType.Eof) - }; - - } - } - - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/AdjustmentExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/AdjustmentExpression.cs deleted file mode 100644 index 26489201..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/AdjustmentExpression.cs +++ /dev/null @@ -1,27 +0,0 @@ -using MoonSharp.Interpreter.Execution; - - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class AdjustmentExpression : Expression - { - private Expression expression; - - public AdjustmentExpression(ScriptLoadingContext lcontext, Expression exp) - : base(lcontext) - { - expression = exp; - } - - public override void Compile(Execution.VM.ByteCode bc) - { - expression.Compile(bc); - bc.Emit_Scalar(); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - return expression.Eval(context).ToScalar(); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/BinaryOperatorExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/BinaryOperatorExpression.cs deleted file mode 100755 index 255039f5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/BinaryOperatorExpression.cs +++ /dev/null @@ -1,464 +0,0 @@ -using System; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - /// - /// - /// - class BinaryOperatorExpression : Expression - { - [Flags] - private enum Operator - { - NotAnOperator = 0, - - Or = 0x1, - And = 0x2, - Less = 0x4, - Greater = 0x8, - LessOrEqual = 0x10, - - GreaterOrEqual = 0x20, - NotEqual = 0x40, - Equal = 0x80, - StrConcat = 0x100, - Add = 0x200, - Sub = 0x400, - Mul = 0x1000, - Div = 0x2000, - Mod = 0x4000, - Power = 0x8000, - } - - - class Node - { - public Expression Expr; - public Operator Op; - public Node Prev; - public Node Next; - } - - class LinkedList - { - public Node Nodes; - public Node Last; - public Operator OperatorMask; - } - - const Operator POWER = Operator.Power; - const Operator MUL_DIV_MOD = Operator.Mul | Operator.Div | Operator.Mod; - const Operator ADD_SUB = Operator.Add | Operator.Sub; - const Operator STRCAT = Operator.StrConcat; - const Operator COMPARES = Operator.Less | Operator.Greater | Operator.GreaterOrEqual | Operator.LessOrEqual | Operator.Equal | Operator.NotEqual; - const Operator LOGIC_AND = Operator.And; - const Operator LOGIC_OR = Operator.Or; - - - public static object BeginOperatorChain() - { - return new LinkedList(); - } - - public static void AddExpressionToChain(object chain, Expression exp) - { - LinkedList list = (LinkedList)chain; - Node node = new Node() { Expr = exp }; - AddNode(list, node); - } - - - public static void AddOperatorToChain(object chain, Token op) - { - LinkedList list = (LinkedList)chain; - Node node = new Node() { Op = ParseBinaryOperator(op) }; - AddNode(list, node); - } - - public static Expression CommitOperatorChain(object chain, ScriptLoadingContext lcontext) - { - return CreateSubTree((LinkedList)chain, lcontext); - } - - public static Expression CreatePowerExpression(Expression op1, Expression op2, ScriptLoadingContext lcontext) - { - return new BinaryOperatorExpression(op1, op2, Operator.Power, lcontext); - } - - - private static void AddNode(LinkedList list, Node node) - { - list.OperatorMask |= node.Op; - - if (list.Nodes == null) - { - list.Nodes = list.Last = node; - } - else - { - list.Last.Next = node; - node.Prev = list.Last; - list.Last = node; - } - } - - - /// - /// Creates a sub tree of binary expressions - /// - private static Expression CreateSubTree(LinkedList list, ScriptLoadingContext lcontext) - { - Operator opfound = list.OperatorMask; - - Node nodes = list.Nodes; - - if ((opfound & POWER) != 0) - nodes = PrioritizeRightAssociative(nodes, lcontext, POWER); - - if ((opfound & MUL_DIV_MOD) != 0) - nodes = PrioritizeLeftAssociative(nodes, lcontext, MUL_DIV_MOD); - - if ((opfound & ADD_SUB) != 0) - nodes = PrioritizeLeftAssociative(nodes, lcontext, ADD_SUB); - - if ((opfound & STRCAT) != 0) - nodes = PrioritizeRightAssociative(nodes, lcontext, STRCAT); - - if ((opfound & COMPARES) != 0) - nodes = PrioritizeLeftAssociative(nodes, lcontext, COMPARES); - - if ((opfound & LOGIC_AND) != 0) - nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_AND); - - if ((opfound & LOGIC_OR) != 0) - nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_OR); - - - if (nodes.Next != null || nodes.Prev != null) - throw new InternalErrorException("Expression reduction didn't work! - 1"); - if (nodes.Expr == null) - throw new InternalErrorException("Expression reduction didn't work! - 2"); - - return nodes.Expr; - } - - private static Node PrioritizeLeftAssociative(Node nodes, ScriptLoadingContext lcontext, Operator operatorsToFind) - { - for (Node N = nodes; N != null; N = N.Next) - { - Operator o = N.Op; - - if ((o & operatorsToFind) != 0) - { - N.Op = Operator.NotAnOperator; - N.Expr = new BinaryOperatorExpression(N.Prev.Expr, N.Next.Expr, o, lcontext); - N.Prev = N.Prev.Prev; - N.Next = N.Next.Next; - - if (N.Next != null) - N.Next.Prev = N; - - if (N.Prev != null) - N.Prev.Next = N; - else - nodes = N; - } - } - - return nodes; - } - - private static Node PrioritizeRightAssociative(Node nodes, ScriptLoadingContext lcontext, Operator operatorsToFind) - { - Node last; - for (last = nodes; last.Next != null; last = last.Next) - { - } - - for (Node N = last; N != null; N = N.Prev) - { - Operator o = N.Op; - - if ((o & operatorsToFind) != 0) - { - N.Op = Operator.NotAnOperator; - N.Expr = new BinaryOperatorExpression(N.Prev.Expr, N.Next.Expr, o, lcontext); - N.Prev = N.Prev.Prev; - N.Next = N.Next.Next; - - if (N.Next != null) - N.Next.Prev = N; - - if (N.Prev != null) - N.Prev.Next = N; - else - nodes = N; - } - } - - return nodes; - } - - - private static Operator ParseBinaryOperator(Token token) - { - switch (token.Type) - { - case TokenType.Or: - return Operator.Or; - case TokenType.And: - return Operator.And; - case TokenType.Op_LessThan: - return Operator.Less; - case TokenType.Op_GreaterThan: - return Operator.Greater; - case TokenType.Op_LessThanEqual: - return Operator.LessOrEqual; - case TokenType.Op_GreaterThanEqual: - return Operator.GreaterOrEqual; - case TokenType.Op_NotEqual: - return Operator.NotEqual; - case TokenType.Op_Equal: - return Operator.Equal; - case TokenType.Op_Concat: - return Operator.StrConcat; - case TokenType.Op_Add: - return Operator.Add; - case TokenType.Op_MinusOrSub: - return Operator.Sub; - case TokenType.Op_Mul: - return Operator.Mul; - case TokenType.Op_Div: - return Operator.Div; - case TokenType.Op_Mod: - return Operator.Mod; - case TokenType.Op_Pwr: - return Operator.Power; - default: - throw new InternalErrorException("Unexpected binary operator '{0}'", token.Text); - } - } - - - - - Expression m_Exp1, m_Exp2; - Operator m_Operator; - - - - private BinaryOperatorExpression(Expression exp1, Expression exp2, Operator op, ScriptLoadingContext lcontext) - : base (lcontext) - { - m_Exp1 = exp1; - m_Exp2 = exp2; - m_Operator = op; - } - - private static bool ShouldInvertBoolean(Operator op) - { - return (op == Operator.NotEqual) - || (op == Operator.GreaterOrEqual) - || (op == Operator.Greater); - } - - private static OpCode OperatorToOpCode(Operator op) - { - switch (op) - { - case Operator.Less: - case Operator.GreaterOrEqual: - return OpCode.Less; - case Operator.LessOrEqual: - case Operator.Greater: - return OpCode.LessEq; - case Operator.Equal: - case Operator.NotEqual: - return OpCode.Eq; - case Operator.StrConcat: - return OpCode.Concat; - case Operator.Add: - return OpCode.Add; - case Operator.Sub: - return OpCode.Sub; - case Operator.Mul: - return OpCode.Mul; - case Operator.Div: - return OpCode.Div; - case Operator.Mod: - return OpCode.Mod; - case Operator.Power: - return OpCode.Power; - default: - throw new InternalErrorException("Unsupported operator {0}", op); - } - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - m_Exp1.Compile(bc); - - if (m_Operator == Operator.Or) - { - Instruction i = bc.Emit_Jump(OpCode.JtOrPop, -1); - m_Exp2.Compile(bc); - i.NumVal = bc.GetJumpPointForNextInstruction(); - return; - } - - if (m_Operator == Operator.And) - { - Instruction i = bc.Emit_Jump(OpCode.JfOrPop, -1); - m_Exp2.Compile(bc); - i.NumVal = bc.GetJumpPointForNextInstruction(); - return; - } - - - if (m_Exp2 != null) - { - m_Exp2.Compile(bc); - } - - bc.Emit_Operator(OperatorToOpCode(m_Operator)); - - if (ShouldInvertBoolean(m_Operator)) - bc.Emit_Operator(OpCode.Not); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - DynValue v1 = m_Exp1.Eval(context).ToScalar(); - - if (m_Operator == Operator.Or) - { - if (v1.CastToBool()) - return v1; - else - return m_Exp2.Eval(context).ToScalar(); - } - - if (m_Operator == Operator.And) - { - if (!v1.CastToBool()) - return v1; - else - return m_Exp2.Eval(context).ToScalar(); - } - - DynValue v2 = m_Exp2.Eval(context).ToScalar(); - - if ((m_Operator & COMPARES) != 0) - { - return DynValue.NewBoolean(EvalComparison(v1, v2, m_Operator)); - } - else if (m_Operator == Operator.StrConcat) - { - string s1 = v1.CastToString(); - string s2 = v2.CastToString(); - - if (s1 == null || s2 == null) - throw new DynamicExpressionException("Attempt to perform concatenation on non-strings."); - - return DynValue.NewString(s1 + s2); - } - else - { - return DynValue.NewNumber(EvalArithmetic(v1, v2)); - } - } - - private double EvalArithmetic(DynValue v1, DynValue v2) - { - double? nd1 = v1.CastToNumber(); - double? nd2 = v2.CastToNumber(); - - if (nd1 == null || nd2 == null) - throw new DynamicExpressionException("Attempt to perform arithmetic on non-numbers."); - - double d1 = nd1.Value; - double d2 = nd2.Value; - - switch (m_Operator) - { - case Operator.Add: - return d1 + d2; - case Operator.Sub: - return d1 - d2; - case Operator.Mul: - return d1 * d2; - case Operator.Div: - return d1 / d2; - case Operator.Mod: - { - double mod = Math.IEEERemainder(d1, d2); - if (mod < 0) mod += d2; - return mod; - } - default: - throw new DynamicExpressionException("Unsupported operator {0}", m_Operator); - } - } - - private bool EvalComparison(DynValue l, DynValue r, Operator op) - { - switch (op) - { - case Operator.Less: - if (l.Type == DataType.Number && r.Type == DataType.Number) - { - return (l.Number < r.Number); - } - else if (l.Type == DataType.String && r.Type == DataType.String) - { - return (l.String.CompareTo(r.String) < 0); - } - else - { - throw new DynamicExpressionException("Attempt to compare non-numbers, non-strings."); - } - case Operator.LessOrEqual: - if (l.Type == DataType.Number && r.Type == DataType.Number) - { - return (l.Number <= r.Number); - } - else if (l.Type == DataType.String && r.Type == DataType.String) - { - return (l.String.CompareTo(r.String) <= 0); - } - else - { - throw new DynamicExpressionException("Attempt to compare non-numbers, non-strings."); - } - case Operator.Equal: - if (object.ReferenceEquals(r, l)) - { - return true; - } - else if (r.Type != l.Type) - { - if ((l.Type == DataType.Nil && r.Type == DataType.Void) - || (l.Type == DataType.Void && r.Type == DataType.Nil)) - return true; - else - return false; - } - else - { - return r.Equals(l); - } - case Operator.Greater: - return !EvalComparison(l, r, Operator.LessOrEqual); - case Operator.GreaterOrEqual: - return !EvalComparison(l, r, Operator.Less); - case Operator.NotEqual: - return !EvalComparison(l, r, Operator.Equal); - default: - throw new DynamicExpressionException("Unsupported operator {0}", op); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/DynamicExprExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/DynamicExprExpression.cs deleted file mode 100644 index 80a5491a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/DynamicExprExpression.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class DynamicExprExpression : Expression - { - Expression m_Exp; - - public DynamicExprExpression(Expression exp, ScriptLoadingContext lcontext) - : base(lcontext) - { - lcontext.Anonymous = true; - m_Exp = exp; - } - - - public override DynValue Eval(ScriptExecutionContext context) - { - return m_Exp.Eval(context); - } - - public override void Compile(Execution.VM.ByteCode bc) - { - throw new InvalidOperationException(); - } - - public override SymbolRef FindDynamic(ScriptExecutionContext context) - { - return m_Exp.FindDynamic(context); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/ExprListExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/ExprListExpression.cs deleted file mode 100644 index c300a618..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/ExprListExpression.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class ExprListExpression : Expression - { - List expressions; - - public ExprListExpression(List exps, ScriptLoadingContext lcontext) - : base(lcontext) - { - expressions = exps; - } - - - public Expression[] GetExpressions() - { - return expressions.ToArray(); - } - - public override void Compile(Execution.VM.ByteCode bc) - { - foreach (var exp in expressions) - exp.Compile(bc); - - if (expressions.Count > 1) - bc.Emit_MkTuple(expressions.Count); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - if (expressions.Count >= 1) - return expressions[0].Eval(context); - - return DynValue.Void; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionCallExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionCallExpression.cs deleted file mode 100644 index e0e8018f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionCallExpression.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class FunctionCallExpression : Expression - { - List m_Arguments; - Expression m_Function; - string m_Name; - string m_DebugErr; - - internal SourceRef SourceRef { get; private set; } - - - public FunctionCallExpression(ScriptLoadingContext lcontext, Expression function, Token thisCallName) - : base(lcontext) - { - Token callToken = thisCallName ?? lcontext.Lexer.Current; - - m_Name = thisCallName != null ? thisCallName.Text : null; - m_DebugErr = function.GetFriendlyDebugName(); - m_Function = function; - - switch (lcontext.Lexer.Current.Type) - { - case TokenType.Brk_Open_Round: - Token openBrk = lcontext.Lexer.Current; - lcontext.Lexer.Next(); - Token t = lcontext.Lexer.Current; - if (t.Type == TokenType.Brk_Close_Round) - { - m_Arguments = new List(); - SourceRef = callToken.GetSourceRef(t); - lcontext.Lexer.Next(); - } - else - { - m_Arguments = ExprList(lcontext); - SourceRef = callToken.GetSourceRef(CheckMatch(lcontext, openBrk, TokenType.Brk_Close_Round, ")")); - } - break; - case TokenType.String: - case TokenType.String_Long: - { - m_Arguments = new List(); - Expression le = new LiteralExpression(lcontext, lcontext.Lexer.Current); - m_Arguments.Add(le); - SourceRef = callToken.GetSourceRef(lcontext.Lexer.Current); - } - break; - case TokenType.Brk_Open_Curly: - case TokenType.Brk_Open_Curly_Shared: - { - m_Arguments = new List(); - m_Arguments.Add(new TableConstructor(lcontext, lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly_Shared)); - SourceRef = callToken.GetSourceRefUpTo(lcontext.Lexer.Current); - } - break; - default: - throw new SyntaxErrorException(lcontext.Lexer.Current, "function arguments expected") - { - IsPrematureStreamTermination = (lcontext.Lexer.Current.Type == TokenType.Eof) - }; - } - } - - public override void Compile(Execution.VM.ByteCode bc) - { - m_Function.Compile(bc); - - int argslen = m_Arguments.Count; - - if (!string.IsNullOrEmpty(m_Name)) - { - bc.Emit_Copy(0); - bc.Emit_Index(DynValue.NewString(m_Name), true); - bc.Emit_Swap(0, 1); - ++argslen; - } - - for (int i = 0; i < m_Arguments.Count; i++) - m_Arguments[i].Compile(bc); - - if (!string.IsNullOrEmpty(m_Name)) - { - bc.Emit_ThisCall(argslen, m_DebugErr); - } - else - { - bc.Emit_Call(argslen, m_DebugErr); - } - } - - public override DynValue Eval(ScriptExecutionContext context) - { - throw new DynamicExpressionException("Dynamic Expressions cannot call functions."); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionDefinitionExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionDefinitionExpression.cs deleted file mode 100644 index 3146cedb..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/FunctionDefinitionExpression.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class FunctionDefinitionExpression : Expression, IClosureBuilder - { - SymbolRef[] m_ParamNames = null; - Statement m_Statement; - RuntimeScopeFrame m_StackFrame; - List m_Closure = new List(); - bool m_HasVarArgs = false; - Instruction m_ClosureInstruction = null; - - bool m_UsesGlobalEnv; - SymbolRef m_Env; - - SourceRef m_Begin, m_End; - - - public FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool usesGlobalEnv) - : this(lcontext, false, usesGlobalEnv, false) - { } - - public FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSelfParam, bool isLambda) - : this(lcontext, pushSelfParam, false, isLambda) - { } - - - private FunctionDefinitionExpression(ScriptLoadingContext lcontext, bool pushSelfParam, bool usesGlobalEnv, bool isLambda) - : base(lcontext) - { - if (m_UsesGlobalEnv = usesGlobalEnv) - CheckTokenType(lcontext, TokenType.Function); - - // here lexer should be at the '(' or at the '|' - Token openRound = CheckTokenType(lcontext, isLambda ? TokenType.Lambda : TokenType.Brk_Open_Round); - - List paramnames = BuildParamList(lcontext, pushSelfParam, openRound, isLambda); - // here lexer is at first token of body - - m_Begin = openRound.GetSourceRefUpTo(lcontext.Lexer.Current); - - // create scope - lcontext.Scope.PushFunction(this, m_HasVarArgs); - - if (m_UsesGlobalEnv) - { - m_Env = lcontext.Scope.DefineLocal(WellKnownSymbols.ENV); - } - else - { - lcontext.Scope.ForceEnvUpValue(); - } - - m_ParamNames = DefineArguments(paramnames, lcontext); - - if(isLambda) - m_Statement = CreateLambdaBody(lcontext); - else - m_Statement = CreateBody(lcontext); - - m_StackFrame = lcontext.Scope.PopFunction(); - - lcontext.Source.Refs.Add(m_Begin); - lcontext.Source.Refs.Add(m_End); - - } - - - private Statement CreateLambdaBody(ScriptLoadingContext lcontext) - { - Token start = lcontext.Lexer.Current; - Expression e = Expression.Expr(lcontext); - Token end = lcontext.Lexer.Current; - SourceRef sref = start.GetSourceRefUpTo(end); - Statement s = new ReturnStatement(lcontext, e, sref); - return s; - } - - - private Statement CreateBody(ScriptLoadingContext lcontext) - { - Statement s = new CompositeStatement(lcontext); - - if (lcontext.Lexer.Current.Type != TokenType.End) - throw new SyntaxErrorException(lcontext.Lexer.Current, "'end' expected near '{0}'", lcontext.Lexer.Current.Text) - { - IsPrematureStreamTermination = (lcontext.Lexer.Current.Type == TokenType.Eof) - }; - - m_End = lcontext.Lexer.Current.GetSourceRef(); - - lcontext.Lexer.Next(); - return s; - } - - private List BuildParamList(ScriptLoadingContext lcontext, bool pushSelfParam, Token openBracketToken, bool isLambda) - { - TokenType closeToken = isLambda ? TokenType.Lambda : TokenType.Brk_Close_Round; - - List paramnames = new List(); - - // method decls with ':' must push an implicit 'self' param - if (pushSelfParam) - paramnames.Add("self"); - - while (lcontext.Lexer.Current.Type != closeToken) - { - Token t = lcontext.Lexer.Current; - - if (t.Type == TokenType.Name) - { - paramnames.Add(t.Text); - } - else if (t.Type == TokenType.VarArgs) - { - m_HasVarArgs = true; - paramnames.Add(WellKnownSymbols.VARARGS); - } - else - UnexpectedTokenType(t); - - lcontext.Lexer.Next(); - - t = lcontext.Lexer.Current; - - if (t.Type == TokenType.Comma) - { - lcontext.Lexer.Next(); - } - else - { - CheckMatch(lcontext, openBracketToken, closeToken, isLambda ? "|" : ")"); - break; - } - } - - if (lcontext.Lexer.Current.Type == closeToken) - lcontext.Lexer.Next(); - - return paramnames; - } - - private SymbolRef[] DefineArguments(List paramnames, ScriptLoadingContext lcontext) - { - HashSet names = new HashSet(); - - SymbolRef[] ret = new SymbolRef[paramnames.Count]; - - for (int i = paramnames.Count - 1; i >= 0; i--) - { - if (!names.Add(paramnames[i])) - paramnames[i] = paramnames[i] + "@" + i.ToString(); - - ret[i] = lcontext.Scope.DefineLocal(paramnames[i]); - } - - return ret; - } - - public SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol) - { - for (int i = 0; i < m_Closure.Count; i++) - { - if (m_Closure[i].i_Name == symbol.i_Name) - { - return SymbolRef.Upvalue(symbol.i_Name, i); - } - } - - m_Closure.Add(symbol); - - if (m_ClosureInstruction != null) - { - m_ClosureInstruction.SymbolList = m_Closure.ToArray(); - } - - return SymbolRef.Upvalue(symbol.i_Name, m_Closure.Count - 1); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - throw new DynamicExpressionException("Dynamic Expressions cannot define new functions."); - } - - public int CompileBody(ByteCode bc, string friendlyName) - { - string funcName = friendlyName ?? ("<" + this.m_Begin.FormatLocation(bc.Script, true) + ">"); - - bc.PushSourceRef(m_Begin); - - Instruction I = bc.Emit_Jump(OpCode.Jump, -1); - - Instruction meta = bc.Emit_Meta(funcName, OpCodeMetadataType.FunctionEntrypoint); - int metaip = bc.GetJumpPointForLastInstruction(); - - bc.Emit_BeginFn(m_StackFrame); - - bc.LoopTracker.Loops.Push(new LoopBoundary()); - - int entryPoint = bc.GetJumpPointForLastInstruction(); - - if (m_UsesGlobalEnv) - { - bc.Emit_Load(SymbolRef.Upvalue(WellKnownSymbols.ENV, 0)); - bc.Emit_Store(m_Env, 0, 0); - bc.Emit_Pop(); - } - - if (m_ParamNames.Length > 0) - bc.Emit_Args(m_ParamNames); - - m_Statement.Compile(bc); - - bc.PopSourceRef(); - bc.PushSourceRef(m_End); - - bc.Emit_Ret(0); - - bc.LoopTracker.Loops.Pop(); - - I.NumVal = bc.GetJumpPointForNextInstruction(); - meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; - - bc.PopSourceRef(); - - return entryPoint; - } - - public int Compile(ByteCode bc, Func afterDecl, string friendlyName) - { - using (bc.EnterSource(m_Begin)) - { - SymbolRef[] symbs = m_Closure - //.Select((s, idx) => s.CloneLocalAndSetFrame(m_ClosureFrames[idx])) - .ToArray(); - - m_ClosureInstruction = bc.Emit_Closure(symbs, bc.GetJumpPointForNextInstruction()); - int ops = afterDecl(); - - m_ClosureInstruction.NumVal += 2 + ops; - } - - return CompileBody(bc, friendlyName); - } - - - public override void Compile(ByteCode bc) - { - Compile(bc, () => 0, null); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/IndexExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/IndexExpression.cs deleted file mode 100644 index 1e81aeaf..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/IndexExpression.cs +++ /dev/null @@ -1,78 +0,0 @@ -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class IndexExpression : Expression, IVariable - { - Expression m_BaseExp; - Expression m_IndexExp; - string m_Name; - - - public IndexExpression(Expression baseExp, Expression indexExp, ScriptLoadingContext lcontext) - : base(lcontext) - { - m_BaseExp = baseExp; - m_IndexExp = indexExp; - } - - public IndexExpression(Expression baseExp, string name, ScriptLoadingContext lcontext) - : base(lcontext) - { - m_BaseExp = baseExp; - m_Name = name; - } - - - public override void Compile(ByteCode bc) - { - m_BaseExp.Compile(bc); - - if (m_Name != null) - { - bc.Emit_Index(DynValue.NewString(m_Name), true); - } - else if (m_IndexExp is LiteralExpression) - { - LiteralExpression lit = (LiteralExpression)m_IndexExp; - bc.Emit_Index(lit.Value); - } - else - { - m_IndexExp.Compile(bc); - bc.Emit_Index(isExpList: (m_IndexExp is ExprListExpression)); - } - } - - public void CompileAssignment(ByteCode bc, int stackofs, int tupleidx) - { - m_BaseExp.Compile(bc); - - if (m_Name != null) - { - bc.Emit_IndexSet(stackofs, tupleidx, DynValue.NewString(m_Name), isNameIndex: true); - } - else if (m_IndexExp is LiteralExpression) - { - LiteralExpression lit = (LiteralExpression)m_IndexExp; - bc.Emit_IndexSet(stackofs, tupleidx, lit.Value); - } - else - { - m_IndexExp.Compile(bc); - bc.Emit_IndexSet(stackofs, tupleidx, isExpList: (m_IndexExp is ExprListExpression)); - } - } - - public override DynValue Eval(ScriptExecutionContext context) - { - DynValue b = m_BaseExp.Eval(context).ToScalar(); - DynValue i = m_IndexExp != null ? m_IndexExp.Eval(context).ToScalar() : DynValue.NewString(m_Name); - - if (b.Type != DataType.Table) throw new DynamicExpressionException("Attempt to index non-table."); - else if (i.IsNilOrNan()) throw new DynamicExpressionException("Attempt to index with nil or nan key."); - return b.Table.Get(i) ?? DynValue.Nil; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/LiteralExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/LiteralExpression.cs deleted file mode 100644 index 9580c60c..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/LiteralExpression.cs +++ /dev/null @@ -1,65 +0,0 @@ -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class LiteralExpression : Expression - { - DynValue m_Value; - - public DynValue Value - { - get { return m_Value; } - } - - - public LiteralExpression(ScriptLoadingContext lcontext, DynValue value) - : base(lcontext) - { - m_Value = value; - } - - - public LiteralExpression(ScriptLoadingContext lcontext, Token t) - : base(lcontext) - { - switch (t.Type) - { - case TokenType.Number: - case TokenType.Number_Hex: - case TokenType.Number_HexFloat: - m_Value = DynValue.NewNumber(t.GetNumberValue()).AsReadOnly(); - break; - case TokenType.String: - case TokenType.String_Long: - m_Value = DynValue.NewString(t.Text).AsReadOnly(); - break; - case TokenType.True: - m_Value = DynValue.True; - break; - case TokenType.False: - m_Value = DynValue.False; - break; - case TokenType.Nil: - m_Value = DynValue.Nil; - break; - default: - throw new InternalErrorException("type mismatch"); - } - - if (m_Value == null) - throw new SyntaxErrorException(t, "unknown literal format near '{0}'", t.Text); - - lcontext.Lexer.Next(); - } - - public override void Compile(Execution.VM.ByteCode bc) - { - bc.Emit_Literal(m_Value); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - return m_Value; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/SymbolRefExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/SymbolRefExpression.cs deleted file mode 100644 index 722c1d60..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/SymbolRefExpression.cs +++ /dev/null @@ -1,66 +0,0 @@ -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class SymbolRefExpression : Expression, IVariable - { - SymbolRef m_Ref; - string m_VarName; - - public SymbolRefExpression(Token T, ScriptLoadingContext lcontext) - : base(lcontext) - { - m_VarName = T.Text; - - if (T.Type == TokenType.VarArgs) - { - m_Ref = lcontext.Scope.Find(WellKnownSymbols.VARARGS); - - if (!lcontext.Scope.CurrentFunctionHasVarArgs()) - throw new SyntaxErrorException(T, "cannot use '...' outside a vararg function"); - - if (lcontext.IsDynamicExpression) - throw new DynamicExpressionException("cannot use '...' in a dynamic expression."); - } - else - { - if (!lcontext.IsDynamicExpression) - m_Ref = lcontext.Scope.Find(m_VarName); - } - - lcontext.Lexer.Next(); - } - - public SymbolRefExpression(ScriptLoadingContext lcontext, SymbolRef refr) - : base(lcontext) - { - m_Ref = refr; - - if (lcontext.IsDynamicExpression) - { - throw new DynamicExpressionException("Unsupported symbol reference expression detected."); - } - } - - public override void Compile(Execution.VM.ByteCode bc) - { - bc.Emit_Load(m_Ref); - } - - - public void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx) - { - bc.Emit_Store(m_Ref, stackofs, tupleidx); - } - - public override DynValue Eval(ScriptExecutionContext context) - { - return context.EvaluateSymbolByName(m_VarName); - } - - public override SymbolRef FindDynamic(ScriptExecutionContext context) - { - return context.FindSymbolByName(m_VarName); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/TableConstructor.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/TableConstructor.cs deleted file mode 100644 index be4093ca..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/TableConstructor.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class TableConstructor : Expression - { - bool m_Shared = false; - List m_PositionalValues = new List(); - List> m_CtorArgs = new List>(); - - public TableConstructor(ScriptLoadingContext lcontext, bool shared) - : base(lcontext) - { - m_Shared = shared; - - // here lexer is at the '{', go on - CheckTokenType(lcontext, TokenType.Brk_Open_Curly, TokenType.Brk_Open_Curly_Shared); - - while (lcontext.Lexer.Current.Type != TokenType.Brk_Close_Curly) - { - switch (lcontext.Lexer.Current.Type) - { - case TokenType.Name: - { - Token assign = lcontext.Lexer.PeekNext(); - - if (assign.Type == TokenType.Op_Assignment) - StructField(lcontext); - else - ArrayField(lcontext); - } - break; - case TokenType.Brk_Open_Square: - MapField(lcontext); - break; - default: - ArrayField(lcontext); - break; - } - - Token curr = lcontext.Lexer.Current; - - if (curr.Type == TokenType.Comma || curr.Type == TokenType.SemiColon) - { - lcontext.Lexer.Next(); - } - else - { - break; - } - } - - CheckTokenType(lcontext, TokenType.Brk_Close_Curly); - } - - private void MapField(ScriptLoadingContext lcontext) - { - lcontext.Lexer.Next(); // skip '[' - - Expression key = Expr(lcontext); - - CheckTokenType(lcontext, TokenType.Brk_Close_Square); - - CheckTokenType(lcontext, TokenType.Op_Assignment); - - Expression value = Expr(lcontext); - - m_CtorArgs.Add(new KeyValuePair(key, value)); - } - - private void StructField(ScriptLoadingContext lcontext) - { - Expression key = new LiteralExpression(lcontext, DynValue.NewString(lcontext.Lexer.Current.Text)); - lcontext.Lexer.Next(); - - CheckTokenType(lcontext, TokenType.Op_Assignment); - - Expression value = Expr(lcontext); - - m_CtorArgs.Add(new KeyValuePair(key, value)); - } - - - private void ArrayField(ScriptLoadingContext lcontext) - { - Expression e = Expr(lcontext); - m_PositionalValues.Add(e); - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - bc.Emit_NewTable(m_Shared); - - foreach (var kvp in m_CtorArgs) - { - kvp.Key.Compile(bc); - kvp.Value.Compile(bc); - bc.Emit_TblInitN(); - } - - for (int i = 0; i < m_PositionalValues.Count; i++ ) - { - m_PositionalValues[i].Compile(bc); - bc.Emit_TblInitI(i == m_PositionalValues.Count - 1); - } - } - - - public override DynValue Eval(ScriptExecutionContext context) - { - if (!this.m_Shared) - { - throw new DynamicExpressionException("Dynamic Expressions cannot define new non-prime tables."); - } - - DynValue tval = DynValue.NewPrimeTable(); - Table t = tval.Table; - - int idx = 0; - foreach (Expression e in m_PositionalValues) - { - t.Set(++idx, e.Eval(context)); - } - - foreach (KeyValuePair kvp in this.m_CtorArgs) - { - t.Set(kvp.Key.Eval(context), kvp.Value.Eval(context)); - } - - return tval; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/UnaryOperatorExpression.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/UnaryOperatorExpression.cs deleted file mode 100644 index ec763585..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Expressions/UnaryOperatorExpression.cs +++ /dev/null @@ -1,66 +0,0 @@ -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree.Expressions -{ - class UnaryOperatorExpression : Expression - { - Expression m_Exp; - string m_OpText; - - public UnaryOperatorExpression(ScriptLoadingContext lcontext, Expression subExpression, Token unaryOpToken) - : base(lcontext) - { - m_OpText = unaryOpToken.Text; - m_Exp = subExpression; - } - - - - public override void Compile(ByteCode bc) - { - m_Exp.Compile(bc); - - switch (m_OpText) - { - case "not": - bc.Emit_Operator(OpCode.Not); - break; - case "#": - bc.Emit_Operator(OpCode.Len); - break; - case "-": - bc.Emit_Operator(OpCode.Neg); - break; - default: - throw new InternalErrorException("Unexpected unary operator '{0}'", m_OpText); - } - - - } - - public override DynValue Eval(ScriptExecutionContext context) - { - DynValue v = m_Exp.Eval(context).ToScalar(); - - switch (m_OpText) - { - case "not": - return DynValue.NewBoolean(!v.CastToBool()); - case "#": - return v.GetLength(); - case "-": - { - double? d = v.CastToNumber(); - - if (d.HasValue) - return DynValue.NewNumber(-d.Value); - - throw new DynamicExpressionException("Attempt to perform arithmetic on non-numbers."); - } - default: - throw new DynamicExpressionException("Unexpected unary operator '{0}'", m_OpText); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Fast_Interface/Loader_Fast.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Fast_Interface/Loader_Fast.cs deleted file mode 100644 index e3775921..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Fast_Interface/Loader_Fast.cs +++ /dev/null @@ -1,116 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; -using MoonSharp.Interpreter.Tree.Expressions; -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Tree.Fast_Interface -{ - internal static class Loader_Fast - { - internal static DynamicExprExpression LoadDynamicExpr(Script script, SourceCode source) - { - ScriptLoadingContext lcontext = CreateLoadingContext(script, source); - - try - { - lcontext.IsDynamicExpression = true; - lcontext.Anonymous = true; - - Expression exp; - using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) - exp = Expression.Expr(lcontext); - - return new DynamicExprExpression(exp, lcontext); - } - catch (SyntaxErrorException ex) - { - ex.DecorateMessage(script); - ex.Rethrow(); - throw; - } - } - - private static ScriptLoadingContext CreateLoadingContext(Script script, SourceCode source) - { - return new ScriptLoadingContext(script) - { - Scope = new BuildTimeScope(), - Source = source, - Lexer = new Lexer(source.SourceID, source.Code, true) - }; - } - - internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecode) - { - ScriptLoadingContext lcontext = CreateLoadingContext(script, source); - try - { - Statement stat; - - using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) - stat = new ChunkStatement(lcontext); - - int beginIp = -1; - - //var srcref = new SourceRef(source.SourceID); - - using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Compilation)) - using (bytecode.EnterSource(null)) - { - bytecode.Emit_Nop(string.Format("Begin chunk {0}", source.Name)); - beginIp = bytecode.GetJumpPointForLastInstruction(); - stat.Compile(bytecode); - bytecode.Emit_Nop(string.Format("End chunk {0}", source.Name)); - } - - //Debug_DumpByteCode(bytecode, source.SourceID); - - return beginIp; - } - catch (SyntaxErrorException ex) - { - ex.DecorateMessage(script); - ex.Rethrow(); - throw; - } - } - - internal static int LoadFunction(Script script, SourceCode source, ByteCode bytecode, bool usesGlobalEnv) - { - ScriptLoadingContext lcontext = CreateLoadingContext(script, source); - - try - { - FunctionDefinitionExpression fnx; - - using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.AstCreation)) - fnx = new FunctionDefinitionExpression(lcontext, usesGlobalEnv); - - int beginIp = -1; - - //var srcref = new SourceRef(source.SourceID); - - using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Compilation)) - using (bytecode.EnterSource(null)) - { - bytecode.Emit_Nop(string.Format("Begin function {0}", source.Name)); - beginIp = fnx.CompileBody(bytecode, source.Name); - bytecode.Emit_Nop(string.Format("End function {0}", source.Name)); - } - - //Debug_DumpByteCode(bytecode, source.SourceID); - - return beginIp; - } - catch (SyntaxErrorException ex) - { - ex.DecorateMessage(script); - ex.Rethrow(); - throw; - } - - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/IVariable.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/IVariable.cs deleted file mode 100644 index 1130a5a0..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/IVariable.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace MoonSharp.Interpreter.Tree -{ - interface IVariable - { - void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx); - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Lexer.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Lexer.cs deleted file mode 100755 index de47d322..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Lexer.cs +++ /dev/null @@ -1,591 +0,0 @@ -using System.Text; - -namespace MoonSharp.Interpreter.Tree -{ - class Lexer - { - Token m_Current = null; - string m_Code; - int m_PrevLineTo = 0; - int m_PrevColTo = 1; - int m_Cursor = 0; - int m_Line = 1; - int m_Col = 0; - int m_SourceId; - bool m_AutoSkipComments = false; - - public Lexer(int sourceID, string scriptContent, bool autoSkipComments) - { - m_Code = scriptContent; - m_SourceId = sourceID; - - // remove unicode BOM if any - if (m_Code.Length > 0 && m_Code[0] == 0xFEFF) - m_Code = m_Code.Substring(1); - - m_AutoSkipComments = autoSkipComments; - } - - public Token Current - { - get - { - if (m_Current == null) - Next(); - - return m_Current; - } - } - - private Token FetchNewToken() - { - while (true) - { - Token T = ReadToken(); - - //System.Diagnostics.Debug.WriteLine("LEXER : " + T.ToString()); - - if ((T.Type != TokenType.Comment && T.Type != TokenType.HashBang) || (!m_AutoSkipComments)) - return T; - } - } - - public void Next() - { - m_Current = FetchNewToken(); - } - - public Token PeekNext() - { - int snapshot = m_Cursor; - Token current = m_Current; - int line = m_Line; - int col = m_Col; - - Next(); - Token t = Current; - - m_Cursor = snapshot; - m_Current = current; - m_Line = line; - m_Col = col; - - return t; - } - - - private void CursorNext() - { - if (CursorNotEof()) - { - if (CursorChar() == '\n') - { - m_Col = 0; - m_Line += 1; - } - else - { - m_Col += 1; - } - - m_Cursor += 1; - } - } - - private char CursorChar() - { - if (m_Cursor < m_Code.Length) - return m_Code[m_Cursor]; - else - return '\0'; // sentinel - } - - private char CursorCharNext() - { - CursorNext(); - return CursorChar(); - } - - private bool CursorMatches(string pattern) - { - for (int i = 0; i < pattern.Length; i++) - { - int j = m_Cursor + i; - - if (j >= m_Code.Length) - return false; - if (m_Code[j] != pattern[i]) - return false; - } - return true; - } - - private bool CursorNotEof() - { - return m_Cursor < m_Code.Length; - } - - private bool IsWhiteSpace(char c) - { - return char.IsWhiteSpace(c); - } - - private void SkipWhiteSpace() - { - for (; CursorNotEof() && IsWhiteSpace(CursorChar()); CursorNext()) - { - } - } - - - private Token ReadToken() - { - SkipWhiteSpace(); - - int fromLine = m_Line; - int fromCol = m_Col; - - if (!CursorNotEof()) - return CreateToken(TokenType.Eof, fromLine, fromCol, ""); - - char c = CursorChar(); - - switch (c) - { - case '|': - CursorCharNext(); - return CreateToken(TokenType.Lambda, fromLine, fromCol, "|"); - case ';': - CursorCharNext(); - return CreateToken(TokenType.SemiColon, fromLine, fromCol, ";"); - case '=': - return PotentiallyDoubleCharOperator('=', TokenType.Op_Assignment, TokenType.Op_Equal, fromLine, fromCol); - case '<': - return PotentiallyDoubleCharOperator('=', TokenType.Op_LessThan, TokenType.Op_LessThanEqual, fromLine, fromCol); - case '>': - return PotentiallyDoubleCharOperator('=', TokenType.Op_GreaterThan, TokenType.Op_GreaterThanEqual, fromLine, fromCol); - case '~': - case '!': - if (CursorCharNext() != '=') - throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", c); - - CursorCharNext(); - return CreateToken(TokenType.Op_NotEqual, fromLine, fromCol, "~="); - case '.': - { - char next = CursorCharNext(); - if (next == '.') - return PotentiallyDoubleCharOperator('.', TokenType.Op_Concat, TokenType.VarArgs, fromLine, fromCol); - else if (LexerUtils.CharIsDigit(next)) - return ReadNumberToken(fromLine, fromCol, true); - else - return CreateToken(TokenType.Dot, fromLine, fromCol, "."); - } - case '+': - return CreateSingleCharToken(TokenType.Op_Add, fromLine, fromCol); - case '-': - { - char next = CursorCharNext(); - if (next == '-') - { - return ReadComment(fromLine, fromCol); - } - else - { - return CreateToken(TokenType.Op_MinusOrSub, fromLine, fromCol, "-"); - } - } - case '*': - return CreateSingleCharToken(TokenType.Op_Mul, fromLine, fromCol); - case '/': - return CreateSingleCharToken(TokenType.Op_Div, fromLine, fromCol); - case '%': - return CreateSingleCharToken(TokenType.Op_Mod, fromLine, fromCol); - case '^': - return CreateSingleCharToken(TokenType.Op_Pwr, fromLine, fromCol); - case '$': - return PotentiallyDoubleCharOperator('{', TokenType.Op_Dollar, TokenType.Brk_Open_Curly_Shared, fromLine, fromCol); - case '#': - if (m_Cursor == 0 && m_Code.Length > 1 && m_Code[1] == '!') - return ReadHashBang(fromLine, fromCol); - - return CreateSingleCharToken(TokenType.Op_Len, fromLine, fromCol); - case '[': - { - char next = CursorCharNext(); - if (next == '=' || next == '[') - { - string str = ReadLongString(fromLine, fromCol, null, "string"); - return CreateToken(TokenType.String_Long, fromLine, fromCol, str); - } - return CreateToken(TokenType.Brk_Open_Square, fromLine, fromCol, "["); - } - case ']': - return CreateSingleCharToken(TokenType.Brk_Close_Square, fromLine, fromCol); - case '(': - return CreateSingleCharToken(TokenType.Brk_Open_Round, fromLine, fromCol); - case ')': - return CreateSingleCharToken(TokenType.Brk_Close_Round, fromLine, fromCol); - case '{': - return CreateSingleCharToken(TokenType.Brk_Open_Curly, fromLine, fromCol); - case '}': - return CreateSingleCharToken(TokenType.Brk_Close_Curly, fromLine, fromCol); - case ',': - return CreateSingleCharToken(TokenType.Comma, fromLine, fromCol); - case ':': - return PotentiallyDoubleCharOperator(':', TokenType.Colon, TokenType.DoubleColon, fromLine, fromCol); - case '"': - case '\'': - return ReadSimpleStringToken(fromLine, fromCol); - case '\0': - throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", CursorChar()) - { - IsPrematureStreamTermination = true - }; - default: - { - if (char.IsLetter(c) || c == '_') - { - string name = ReadNameToken(); - return CreateNameToken(name, fromLine, fromCol); - } - else if (LexerUtils.CharIsDigit(c)) - { - return ReadNumberToken(fromLine, fromCol, false); - } - } - - throw new SyntaxErrorException(CreateToken(TokenType.Invalid, fromLine, fromCol), "unexpected symbol near '{0}'", CursorChar()); - } - } - - private string ReadLongString(int fromLine, int fromCol, string startpattern, string subtypeforerrors) - { - // here we are at the first '=' or second '[' - StringBuilder text = new StringBuilder(1024); - string end_pattern = "]"; - - if (startpattern == null) - { - for (char c = CursorChar(); ; c = CursorCharNext()) - { - if (c == '\0' || !CursorNotEof()) - { - throw new SyntaxErrorException( - CreateToken(TokenType.Invalid, fromLine, fromCol), - "unfinished long {0} near ''", subtypeforerrors) { IsPrematureStreamTermination = true }; - } - else if (c == '=') - { - end_pattern += "="; - } - else if (c == '[') - { - end_pattern += "]"; - break; - } - else - { - throw new SyntaxErrorException( - CreateToken(TokenType.Invalid, fromLine, fromCol), - "invalid long {0} delimiter near '{1}'", subtypeforerrors, c) { IsPrematureStreamTermination = true }; - } - } - } - else - { - end_pattern = startpattern.Replace('[', ']'); - } - - - for (char c = CursorCharNext(); ; c = CursorCharNext()) - { - if (c == '\r') // XXI century and we still debate on how a newline is made. throw new DeveloperExtremelyAngryException. - continue; - - if (c == '\0' || !CursorNotEof()) - { - throw new SyntaxErrorException( - CreateToken(TokenType.Invalid, fromLine, fromCol), - "unfinished long {0} near '{1}'", subtypeforerrors, text.ToString()) { IsPrematureStreamTermination = true }; - } - else if (c == ']' && CursorMatches(end_pattern)) - { - for (int i = 0; i < end_pattern.Length; i++) - CursorCharNext(); - - return LexerUtils.AdjustLuaLongString(text.ToString()); - } - else - { - text.Append(c); - } - } - } - - private Token ReadNumberToken(int fromLine, int fromCol, bool leadingDot) - { - StringBuilder text = new StringBuilder(32); - - //INT : Digit+ - //HEX : '0' [xX] HexDigit+ - //FLOAT : Digit+ '.' Digit* ExponentPart? - // | '.' Digit+ ExponentPart? - // | Digit+ ExponentPart - //HEX_FLOAT : '0' [xX] HexDigit+ '.' HexDigit* HexExponentPart? - // | '0' [xX] '.' HexDigit+ HexExponentPart? - // | '0' [xX] HexDigit+ HexExponentPart - // - // ExponentPart : [eE] [+-]? Digit+ - // HexExponentPart : [pP] [+-]? Digit+ - - bool isHex = false; - bool dotAdded = false; - bool exponentPart = false; - bool exponentSignAllowed = false; - - if (leadingDot) - { - text.Append("0."); - } - else if (CursorChar() == '0') - { - text.Append(CursorChar()); - char secondChar = CursorCharNext(); - - if (secondChar == 'x' || secondChar == 'X') - { - isHex = true; - text.Append(CursorChar()); - CursorCharNext(); - } - } - - for (char c = CursorChar(); CursorNotEof(); c = CursorCharNext()) - { - if (exponentSignAllowed && (c == '+' || c == '-')) - { - exponentSignAllowed = false; - text.Append(c); - } - else if (LexerUtils.CharIsDigit(c)) - { - text.Append(c); - } - else if (c == '.' && !dotAdded) - { - dotAdded = true; - text.Append(c); - } - else if (LexerUtils.CharIsHexDigit(c) && isHex && !exponentPart) - { - text.Append(c); - } - else if (c == 'e' || c == 'E' || (isHex && (c == 'p' || c == 'P'))) - { - text.Append(c); - exponentPart = true; - exponentSignAllowed = true; - dotAdded = true; - } - else - { - break; - } - } - - TokenType numberType = TokenType.Number; - - if (isHex && (dotAdded || exponentPart)) - numberType = TokenType.Number_HexFloat; - else if (isHex) - numberType = TokenType.Number_Hex; - - string tokenStr = text.ToString(); - return CreateToken(numberType, fromLine, fromCol, tokenStr); - } - - private Token CreateSingleCharToken(TokenType tokenType, int fromLine, int fromCol) - { - char c = CursorChar(); - CursorCharNext(); - return CreateToken(tokenType, fromLine, fromCol, c.ToString()); - } - - private Token ReadHashBang(int fromLine, int fromCol) - { - StringBuilder text = new StringBuilder(32); - - for (char c = CursorChar(); CursorNotEof(); c = CursorCharNext()) - { - if (c == '\n') - { - CursorCharNext(); - return CreateToken(TokenType.HashBang, fromLine, fromCol, text.ToString()); - } - else if (c != '\r') - { - text.Append(c); - } - } - - return CreateToken(TokenType.HashBang, fromLine, fromCol, text.ToString()); - } - - - private Token ReadComment(int fromLine, int fromCol) - { - StringBuilder text = new StringBuilder(32); - - bool extraneousFound = false; - - for (char c = CursorCharNext(); CursorNotEof(); c = CursorCharNext()) - { - if (c == '[' && !extraneousFound && text.Length > 0) - { - text.Append('['); - //CursorCharNext(); - string comment = ReadLongString(fromLine, fromCol, text.ToString(), "comment"); - return CreateToken(TokenType.Comment, fromLine, fromCol, comment); - } - else if (c == '\n') - { - extraneousFound = true; - CursorCharNext(); - return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString()); - } - else if (c != '\r') - { - if (c != '[' && c != '=') - extraneousFound = true; - - text.Append(c); - } - } - - return CreateToken(TokenType.Comment, fromLine, fromCol, text.ToString()); - } - - private Token ReadSimpleStringToken(int fromLine, int fromCol) - { - StringBuilder text = new StringBuilder(32); - char separator = CursorChar(); - - for (char c = CursorCharNext(); CursorNotEof(); c = CursorCharNext()) - { - redo_Loop: - - if (c == '\\') - { - text.Append(c); - c = CursorCharNext(); - text.Append(c); - - if (c == '\r') - { - c = CursorCharNext(); - if (c == '\n') - text.Append(c); - else - goto redo_Loop; - } - else if (c == 'z') - { - c = CursorCharNext(); - - if (char.IsWhiteSpace(c)) - SkipWhiteSpace(); - - c = CursorChar(); - - goto redo_Loop; - } - } - else if (c == '\n' || c == '\r') - { - throw new SyntaxErrorException( - CreateToken(TokenType.Invalid, fromLine, fromCol), - "unfinished string near '{0}'", text.ToString()); - } - else if (c == separator) - { - CursorCharNext(); - Token t = CreateToken(TokenType.String, fromLine, fromCol); - t.Text = LexerUtils.UnescapeLuaString(t, text.ToString()); - return t; - } - else - { - text.Append(c); - } - } - - throw new SyntaxErrorException( - CreateToken(TokenType.Invalid, fromLine, fromCol), - "unfinished string near '{0}'", text.ToString()) { IsPrematureStreamTermination = true }; - } - - - private Token PotentiallyDoubleCharOperator(char expectedSecondChar, TokenType singleCharToken, TokenType doubleCharToken, int fromLine, int fromCol) - { - string op = CursorChar().ToString(); - - CursorCharNext(); - - if (CursorChar() == expectedSecondChar) - { - CursorCharNext(); - return CreateToken(doubleCharToken, fromLine, fromCol, op + expectedSecondChar); - } - else - return CreateToken(singleCharToken, fromLine, fromCol, op); - } - - - - private Token CreateNameToken(string name, int fromLine, int fromCol) - { - TokenType? reservedType = Token.GetReservedTokenType(name); - - if (reservedType.HasValue) - { - return CreateToken(reservedType.Value, fromLine, fromCol, name); - } - else - { - return CreateToken(TokenType.Name, fromLine, fromCol, name); - } - } - - - private Token CreateToken(TokenType tokenType, int fromLine, int fromCol, string text = null) - { - Token t = new Token(tokenType, m_SourceId, fromLine, fromCol, m_Line, m_Col, m_PrevLineTo, m_PrevColTo) - { - Text = text - }; - m_PrevLineTo = m_Line; - m_PrevColTo = m_Col; - return t; - } - - private string ReadNameToken() - { - StringBuilder name = new StringBuilder(32); - - for (char c = CursorChar(); CursorNotEof(); c = CursorCharNext()) - { - if (char.IsLetterOrDigit(c) || c == '_') - name.Append(c); - else - break; - } - - return name.ToString(); - } - - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/LexerUtils.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/LexerUtils.cs deleted file mode 100755 index ea7e18fa..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/LexerUtils.cs +++ /dev/null @@ -1,295 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Tree -{ - internal static class LexerUtils - { - public static double ParseNumber(Token T) - { - string txt = T.Text; - double res; - if (!double.TryParse(txt, NumberStyles.Float, CultureInfo.InvariantCulture, out res)) - throw new SyntaxErrorException(T, "malformed number near '{0}'", txt); - - return res; - } - - public static double ParseHexInteger(Token T) - { - string txt = T.Text; - if ((txt.Length < 2) || (txt[0] != '0' && (char.ToUpper(txt[1]) != 'X'))) - throw new InternalErrorException("hex numbers must start with '0x' near '{0}'.", txt); - - ulong res; - - if (!ulong.TryParse(txt.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out res)) - throw new SyntaxErrorException(T, "malformed number near '{0}'", txt); - - return (double)res; - } - - public static string ReadHexProgressive(string s, ref double d, out int digits) - { - digits = 0; - - for (int i = 0; i < s.Length; i++) - { - char c = s[i]; - - if (LexerUtils.CharIsHexDigit(c)) - { - int v = LexerUtils.HexDigit2Value(c); - d *= 16.0; - d += v; - ++digits; - } - else - { - return s.Substring(i); - } - } - - return string.Empty; - } - - public static double ParseHexFloat(Token T) - { - string s = T.Text; - - try - { - if ((s.Length < 2) || (s[0] != '0' && (char.ToUpper(s[1]) != 'X'))) - throw new InternalErrorException("hex float must start with '0x' near '{0}'", s); - - s = s.Substring(2); - - double value = 0.0; - int dummy, exp = 0; - - s = ReadHexProgressive(s, ref value, out dummy); - - if (s.Length > 0 && s[0] == '.') - { - s = s.Substring(1); - s = ReadHexProgressive(s, ref value, out exp); - } - - exp *= -4; - - if (s.Length > 0 && char.ToUpper(s[0]) == 'P') - { - if (s.Length == 1) - throw new SyntaxErrorException(T, "invalid hex float format near '{0}'", s); - - s = s.Substring(s[1] == '+' ? 2 : 1); - - int exp1 = int.Parse(s, CultureInfo.InvariantCulture); - - exp += exp1; - } - - double result = value * Math.Pow(2, exp); - return result; - } - catch (FormatException) - { - throw new SyntaxErrorException(T, "malformed number near '{0}'", s); - } - } - - - public static int HexDigit2Value(char c) - { - if (c >= '0' && c <= '9') - return c - '0'; - else if (c >= 'A' && c <= 'F') - return 10 + (c - 'A'); - else if (c >= 'a' && c <= 'f') - return 10 + (c - 'a'); - else - throw new InternalErrorException("invalid hex digit near '{0}'", c); - } - - public static bool CharIsDigit(char c) - { - return c >= '0' && c <= '9'; - } - - public static bool CharIsHexDigit(char c) - { - return CharIsDigit(c) || - c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || - c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F'; - } - - public static string AdjustLuaLongString(string str) - { - if (str.StartsWith("\r\n")) - str = str.Substring(2); - else if (str.StartsWith("\n")) - str = str.Substring(1); - - return str; - } - - public static string UnescapeLuaString(Token token, string str) - { - if (!Framework.Do.StringContainsChar(str, '\\')) - return str; - - StringBuilder sb = new StringBuilder(); - - bool escape = false; - bool hex = false; - int unicode_state = 0; - string hexprefix = ""; - string val = ""; - bool zmode = false; - - foreach (char c in str) - { - redo: - if (escape) - { - if (val.Length == 0 && !hex && unicode_state == 0) - { - if (c == 'a') { sb.Append('\a'); escape = false; zmode = false; } - else if (c == '\r') { } // this makes \\r\n -> \\n - else if (c == '\n') { sb.Append('\n'); escape = false; } - else if (c == 'b') { sb.Append('\b'); escape = false; } - else if (c == 'f') { sb.Append('\f'); escape = false; } - else if (c == 'n') { sb.Append('\n'); escape = false; } - else if (c == 'r') { sb.Append('\r'); escape = false; } - else if (c == 't') { sb.Append('\t'); escape = false; } - else if (c == 'v') { sb.Append('\v'); escape = false; } - else if (c == '\\') { sb.Append('\\'); escape = false; zmode = false; } - else if (c == '"') { sb.Append('\"'); escape = false; zmode = false; } - else if (c == '\'') { sb.Append('\''); escape = false; zmode = false; } - else if (c == '[') { sb.Append('['); escape = false; zmode = false; } - else if (c == ']') { sb.Append(']'); escape = false; zmode = false; } - else if (c == 'x') { hex = true; } - else if (c == 'u') { unicode_state = 1; } - else if (c == 'z') { zmode = true; escape = false; } - else if (CharIsDigit(c)) { val = val + c; } - else throw new SyntaxErrorException(token, "invalid escape sequence near '\\{0}'", c); - } - else - { - if (unicode_state == 1) - { - if (c != '{') - throw new SyntaxErrorException(token, "'{' expected near '\\u'"); - - unicode_state = 2; - } - else if (unicode_state == 2) - { - if (c == '}') - { - int i = int.Parse(val, NumberStyles.HexNumber, CultureInfo.InvariantCulture); - sb.Append(ConvertUtf32ToChar(i)); - unicode_state = 0; - val = string.Empty; - escape = false; - } - else if (val.Length >= 8) - { - throw new SyntaxErrorException(token, "'}' missing, or unicode code point too large after '\\u'"); - } - else - { - val += c; - } - } - else if (hex) - { - if (CharIsHexDigit(c)) - { - val += c; - if (val.Length == 2) - { - int i = int.Parse(val, NumberStyles.HexNumber, CultureInfo.InvariantCulture); - sb.Append(ConvertUtf32ToChar(i)); - zmode = false; - escape = false; - } - } - else - { - throw new SyntaxErrorException(token, "hexadecimal digit expected near '\\{0}{1}{2}'", hexprefix, val, c); - } - } - else if (val.Length > 0) - { - if (CharIsDigit(c)) - { - val = val + c; - } - - if (val.Length == 3 || !CharIsDigit(c)) - { - int i = int.Parse(val, CultureInfo.InvariantCulture); - - if (i > 255) - throw new SyntaxErrorException(token, "decimal escape too large near '\\{0}'", val); - - sb.Append(ConvertUtf32ToChar(i)); - - zmode = false; - escape = false; - - if (!CharIsDigit(c)) - goto redo; - } - } - } - } - else - { - if (c == '\\') - { - escape = true; - hex = false; - val = ""; - } - else - { - if (!zmode || !char.IsWhiteSpace(c)) - { - sb.Append(c); - zmode = false; - } - } - } - } - - if (escape && !hex && val.Length > 0) - { - int i = int.Parse(val, CultureInfo.InvariantCulture); - sb.Append(ConvertUtf32ToChar(i)); - escape = false; - } - - if (escape) - { - throw new SyntaxErrorException(token, "unfinished string near '\"{0}\"'", sb.ToString()); - } - - return sb.ToString(); - } - - private static string ConvertUtf32ToChar(int i) - { -#if PCL || ENABLE_DOTNET - return ((char)i).ToString(); -#else - return char.ConvertFromUtf32(i); -#endif - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Token.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Token.cs deleted file mode 100644 index 287fedc9..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/Token.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; - -namespace MoonSharp.Interpreter.Tree -{ - class Token - { - public readonly int SourceId; - public readonly int FromCol, ToCol, FromLine, ToLine, PrevCol, PrevLine; - public readonly TokenType Type; - - public string Text { get; set; } - - public Token(TokenType type, int sourceId, int fromLine, int fromCol, int toLine, int toCol, int prevLine, int prevCol) - { - Type = type; - - SourceId = sourceId; - FromLine = fromLine; - FromCol = fromCol; - ToCol = toCol; - ToLine = toLine; - PrevCol = prevCol; - PrevLine = prevLine; - } - - - public override string ToString() - { - string tokenTypeString = (Type.ToString() + " ").Substring(0, 16); - - string location = string.Format("{0}:{1}-{2}:{3}", FromLine, FromCol, ToLine, ToCol); - - location = (location + " ").Substring(0, 10); - - return string.Format("{0} - {1} - '{2}'", tokenTypeString, location, this.Text ?? ""); - } - - public static TokenType? GetReservedTokenType(string reservedWord) - { - switch (reservedWord) - { - case "and": - return TokenType.And; - case "break": - return TokenType.Break; - case "do": - return TokenType.Do; - case "else": - return TokenType.Else; - case "elseif": - return TokenType.ElseIf; - case "end": - return TokenType.End; - case "false": - return TokenType.False; - case "for": - return TokenType.For; - case "function": - return TokenType.Function; - case "goto": - return TokenType.Goto; - case "if": - return TokenType.If; - case "in": - return TokenType.In; - case "local": - return TokenType.Local; - case "nil": - return TokenType.Nil; - case "not": - return TokenType.Not; - case "or": - return TokenType.Or; - case "repeat": - return TokenType.Repeat; - case "return": - return TokenType.Return; - case "then": - return TokenType.Then; - case "true": - return TokenType.True; - case "until": - return TokenType.Until; - case "while": - return TokenType.While; - default: - return null; - } - } - - public double GetNumberValue() - { - if (this.Type == TokenType.Number) - return LexerUtils.ParseNumber(this); - else if (this.Type == TokenType.Number_Hex) - return LexerUtils.ParseHexInteger(this); - else if (this.Type == TokenType.Number_HexFloat) - return LexerUtils.ParseHexFloat(this); - else - throw new NotSupportedException("GetNumberValue is supported only on numeric tokens"); - } - - - public bool IsEndOfBlock() - { - switch (Type) - { - case TokenType.Else: - case TokenType.ElseIf: - case TokenType.End: - case TokenType.Until: - case TokenType.Eof: - return true; - default: - return false; - } - } - - public bool IsUnaryOperator() - { - return Type == TokenType.Op_MinusOrSub || Type == TokenType.Not || Type == TokenType.Op_Len; - } - - public bool IsBinaryOperator() - { - switch (Type) - { - case TokenType.And: - case TokenType.Or: - case TokenType.Op_Equal: - case TokenType.Op_LessThan: - case TokenType.Op_LessThanEqual: - case TokenType.Op_GreaterThanEqual: - case TokenType.Op_GreaterThan: - case TokenType.Op_NotEqual: - case TokenType.Op_Concat: - case TokenType.Op_Pwr: - case TokenType.Op_Mod: - case TokenType.Op_Div: - case TokenType.Op_Mul: - case TokenType.Op_MinusOrSub: - case TokenType.Op_Add: - return true; - default: - return false; - } - } - - - internal Debugging.SourceRef GetSourceRef(bool isStepStop = true) - { - return new Debugging.SourceRef(this.SourceId, this.FromCol, this.ToCol, this.FromLine, this.ToLine, isStepStop); - } - - internal Debugging.SourceRef GetSourceRef(Token to, bool isStepStop = true) - { - return new Debugging.SourceRef(this.SourceId, this.FromCol, to.ToCol, this.FromLine, to.ToLine, isStepStop); - } - - internal Debugging.SourceRef GetSourceRefUpTo(Token to, bool isStepStop = true) - { - return new Debugging.SourceRef(this.SourceId, this.FromCol, to.PrevCol, this.FromLine, to.PrevLine, isStepStop); - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/TokenType.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/TokenType.cs deleted file mode 100644 index e020ca4f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Lexer/TokenType.cs +++ /dev/null @@ -1,75 +0,0 @@ - -namespace MoonSharp.Interpreter.Tree -{ - enum TokenType - { - Eof, - HashBang, - Name, - And, - Break, - Do, - Else, - ElseIf, - End, - False, - For, - Function, - Lambda, - Goto, - If, - In, - Local, - Nil, - Not, - Or, - Repeat, - Return, - Then, - True, - Until, - While, - Op_Equal, - Op_Assignment, - Op_LessThan, - Op_LessThanEqual, - Op_GreaterThanEqual, - Op_GreaterThan, - Op_NotEqual, - Op_Concat, - VarArgs, - Dot, - Colon, - DoubleColon, - Comma, - Brk_Close_Curly, - Brk_Open_Curly, - Brk_Close_Round, - Brk_Open_Round, - Brk_Close_Square, - Brk_Open_Square, - Op_Len, - Op_Pwr, - Op_Mod, - Op_Div, - Op_Mul, - Op_MinusOrSub, - Op_Add, - Comment, - - String, - String_Long, - - Number, - Number_HexFloat, - Number_Hex, - SemiColon, - Invalid, - - Brk_Open_Curly_Shared, - Op_Dollar, - } - - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Loop.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Loop.cs deleted file mode 100644 index 2a4f1bee..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Loop.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree -{ - internal class Loop : ILoop - { - public RuntimeScopeBlock Scope; - public List BreakJumps = new List(); - - public void CompileBreak(ByteCode bc) - { - bc.Emit_Exit(Scope); - BreakJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); - } - - public bool IsBoundary() - { - return false; - } - } - - internal class LoopBoundary : ILoop - { - public void CompileBreak(ByteCode bc) - { - throw new InternalErrorException("CompileBreak called on LoopBoundary"); - } - - public bool IsBoundary() - { - return true; - } - } - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/NodeBase.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/NodeBase.cs deleted file mode 100644 index f327449a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/NodeBase.cs +++ /dev/null @@ -1,87 +0,0 @@ -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree -{ - abstract class NodeBase - { - public Script Script { get; private set; } - protected ScriptLoadingContext LoadingContext { get; private set; } - - public NodeBase(ScriptLoadingContext lcontext) - { - Script = lcontext.Script; - } - - - public abstract void Compile(ByteCode bc); - - - protected static Token UnexpectedTokenType(Token t) - { - throw new SyntaxErrorException(t, "unexpected symbol near '{0}'", t.Text) - { - IsPrematureStreamTermination = (t.Type == TokenType.Eof) - }; - } - - protected static Token CheckTokenType(ScriptLoadingContext lcontext, TokenType tokenType) - { - Token t = lcontext.Lexer.Current; - if (t.Type != tokenType) - return UnexpectedTokenType(t); - - lcontext.Lexer.Next(); - - return t; - } - - - - protected static Token CheckTokenType(ScriptLoadingContext lcontext, TokenType tokenType1, TokenType tokenType2) - { - Token t = lcontext.Lexer.Current; - if (t.Type != tokenType1 && t.Type != tokenType2) - return UnexpectedTokenType(t); - - lcontext.Lexer.Next(); - - return t; - } - protected static Token CheckTokenType(ScriptLoadingContext lcontext, TokenType tokenType1, TokenType tokenType2, TokenType tokenType3) - { - Token t = lcontext.Lexer.Current; - if (t.Type != tokenType1 && t.Type != tokenType2 && t.Type != tokenType3) - return UnexpectedTokenType(t); - - lcontext.Lexer.Next(); - - return t; - } - - protected static void CheckTokenTypeNotNext(ScriptLoadingContext lcontext, TokenType tokenType) - { - Token t = lcontext.Lexer.Current; - if (t.Type != tokenType) - UnexpectedTokenType(t); - } - - protected static Token CheckMatch(ScriptLoadingContext lcontext, Token originalToken, TokenType expectedTokenType, string expectedTokenText) - { - Token t = lcontext.Lexer.Current; - if (t.Type != expectedTokenType) - { - throw new SyntaxErrorException(lcontext.Lexer.Current, - "'{0}' expected (to close '{1}' at line {2}) near '{3}'", - expectedTokenText, originalToken.Text, originalToken.FromLine, t.Text) - { - IsPrematureStreamTermination = (t.Type == TokenType.Eof) - }; - } - - lcontext.Lexer.Next(); - - return t; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statement.cs deleted file mode 100644 index 1ccadeca..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statement.cs +++ /dev/null @@ -1,89 +0,0 @@ -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Tree.Expressions; -using MoonSharp.Interpreter.Tree.Statements; - -namespace MoonSharp.Interpreter.Tree -{ - abstract class Statement : NodeBase - { - public Statement(ScriptLoadingContext lcontext) - : base(lcontext) - { } - - - protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bool forceLast) - { - Token tkn = lcontext.Lexer.Current; - - forceLast = false; - - switch (tkn.Type) - { - case TokenType.DoubleColon: - return new LabelStatement(lcontext); - case TokenType.Goto: - return new GotoStatement(lcontext); - case TokenType.SemiColon: - lcontext.Lexer.Next(); - return new EmptyStatement(lcontext); - case TokenType.If: - return new IfStatement(lcontext); - case TokenType.While: - return new WhileStatement(lcontext); - case TokenType.Do: - return new ScopeBlockStatement(lcontext); - case TokenType.For: - return DispatchForLoopStatement(lcontext); - case TokenType.Repeat: - return new RepeatStatement(lcontext); - case TokenType.Function: - return new FunctionDefinitionStatement(lcontext, false, null); - case TokenType.Local: - Token localToken = lcontext.Lexer.Current; - lcontext.Lexer.Next(); - if (lcontext.Lexer.Current.Type == TokenType.Function) - return new FunctionDefinitionStatement(lcontext, true, localToken); - else - return new AssignmentStatement(lcontext, localToken); - case TokenType.Return: - forceLast = true; - return new ReturnStatement(lcontext); - case TokenType.Break: - return new BreakStatement(lcontext); - default: - { - Token l = lcontext.Lexer.Current; - Expression exp = Expression.PrimaryExp(lcontext); - FunctionCallExpression fnexp = exp as FunctionCallExpression; - - if (fnexp != null) - return new FunctionCallStatement(lcontext, fnexp); - else - return new AssignmentStatement(lcontext, exp, l); - } - } - } - - private static Statement DispatchForLoopStatement(ScriptLoadingContext lcontext) - { - // for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | - // for namelist in explist do block end | - - Token forTkn = CheckTokenType(lcontext, TokenType.For); - - Token name = CheckTokenType(lcontext, TokenType.Name); - - if (lcontext.Lexer.Current.Type == TokenType.Op_Assignment) - return new ForLoopStatement(lcontext, name, forTkn); - else - return new ForEachLoopStatement(lcontext, name, forTkn); - } - - - - - } - - - -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/AssignmentStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/AssignmentStatement.cs deleted file mode 100644 index a82fe67a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/AssignmentStatement.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class AssignmentStatement : Statement - { - List m_LValues = new List(); - List m_RValues; - SourceRef m_Ref; - - - public AssignmentStatement(ScriptLoadingContext lcontext, Token startToken) - : base(lcontext) - { - List names = new List(); - - Token first = startToken; - - while (true) - { - Token name = CheckTokenType(lcontext, TokenType.Name); - names.Add(name.Text); - - if (lcontext.Lexer.Current.Type != TokenType.Comma) - break; - - lcontext.Lexer.Next(); - } - - if (lcontext.Lexer.Current.Type == TokenType.Op_Assignment) - { - CheckTokenType(lcontext, TokenType.Op_Assignment); - m_RValues = Expression.ExprList(lcontext); - } - else - { - m_RValues = new List(); - } - - foreach (string name in names) - { - var localVar = lcontext.Scope.TryDefineLocal(name); - var symbol = new SymbolRefExpression(lcontext, localVar); - m_LValues.Add(symbol); - } - - Token last = lcontext.Lexer.Current; - m_Ref = first.GetSourceRefUpTo(last); - lcontext.Source.Refs.Add(m_Ref); - - } - - - public AssignmentStatement(ScriptLoadingContext lcontext, Expression firstExpression, Token first) - : base(lcontext) - { - m_LValues.Add(CheckVar(lcontext, firstExpression)); - - while (lcontext.Lexer.Current.Type == TokenType.Comma) - { - lcontext.Lexer.Next(); - Expression e = Expression.PrimaryExp(lcontext); - m_LValues.Add(CheckVar(lcontext, e)); - } - - CheckTokenType(lcontext, TokenType.Op_Assignment); - - m_RValues = Expression.ExprList(lcontext); - - Token last = lcontext.Lexer.Current; - m_Ref = first.GetSourceRefUpTo(last); - lcontext.Source.Refs.Add(m_Ref); - - } - - private IVariable CheckVar(ScriptLoadingContext lcontext, Expression firstExpression) - { - IVariable v = firstExpression as IVariable; - - if (v == null) - throw new SyntaxErrorException(lcontext.Lexer.Current, "unexpected symbol near '{0}' - not a l-value", lcontext.Lexer.Current); - - return v; - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - using (bc.EnterSource(m_Ref)) - { - foreach (var exp in m_RValues) - { - exp.Compile(bc); - } - - for (int i = 0; i < m_LValues.Count; i++) - m_LValues[i].CompileAssignment(bc, - Math.Max(m_RValues.Count - 1 - i, 0), // index of r-value - i - Math.Min(i, m_RValues.Count - 1)); // index in last tuple - - bc.Emit_Pop(m_RValues.Count); - } - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/BreakStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/BreakStatement.cs deleted file mode 100644 index 66c6be2d..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/BreakStatement.cs +++ /dev/null @@ -1,37 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class BreakStatement : Statement - { - SourceRef m_Ref; - - public BreakStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - m_Ref = CheckTokenType(lcontext, TokenType.Break).GetSourceRef(); - lcontext.Source.Refs.Add(m_Ref); - } - - - - public override void Compile(ByteCode bc) - { - using (bc.EnterSource(m_Ref)) - { - if (bc.LoopTracker.Loops.Count == 0) - throw new SyntaxErrorException(this.Script, m_Ref, " at line {0} not inside a loop", m_Ref.FromLine); - - ILoop loop = bc.LoopTracker.Loops.Peek(); - - if (loop.IsBoundary()) - throw new SyntaxErrorException(this.Script, m_Ref, " at line {0} not inside a loop", m_Ref.FromLine); - - loop.CompileBreak(bc); - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ChunkStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ChunkStatement.cs deleted file mode 100644 index b9968b0f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ChunkStatement.cs +++ /dev/null @@ -1,52 +0,0 @@ -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ChunkStatement : Statement, IClosureBuilder - { - Statement m_Block; - RuntimeScopeFrame m_StackFrame; - SymbolRef m_Env; - SymbolRef m_VarArgs; - - public ChunkStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - lcontext.Scope.PushFunction(this, true); - m_Env = lcontext.Scope.DefineLocal(WellKnownSymbols.ENV); - m_VarArgs = lcontext.Scope.DefineLocal(WellKnownSymbols.VARARGS); - - m_Block = new CompositeStatement(lcontext); - - if (lcontext.Lexer.Current.Type != TokenType.Eof) - throw new SyntaxErrorException(lcontext.Lexer.Current, " expected near '{0}'", lcontext.Lexer.Current.Text); - - m_StackFrame = lcontext.Scope.PopFunction(); - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - Instruction meta = bc.Emit_Meta("", OpCodeMetadataType.ChunkEntrypoint); - int metaip = bc.GetJumpPointForLastInstruction(); - - bc.Emit_BeginFn(m_StackFrame); - bc.Emit_Args(m_VarArgs); - - bc.Emit_Load(SymbolRef.Upvalue(WellKnownSymbols.ENV, 0)); - bc.Emit_Store(m_Env, 0, 0); - bc.Emit_Pop(); - - m_Block.Compile(bc); - bc.Emit_Ret(0); - - meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; - } - - public SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol) - { - return null; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/CompositeStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/CompositeStatement.cs deleted file mode 100644 index 2d0b1eec..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/CompositeStatement.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections.Generic; - -using MoonSharp.Interpreter.Execution; - - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class CompositeStatement : Statement - { - List m_Statements = new List(); - - public CompositeStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - while (true) - { - Token t = lcontext.Lexer.Current; - if (t.IsEndOfBlock()) break; - - bool forceLast; - - Statement s = Statement.CreateStatement(lcontext, out forceLast); - m_Statements.Add(s); - - if (forceLast) break; - } - - // eat away all superfluos ';'s - while (lcontext.Lexer.Current.Type == TokenType.SemiColon) - lcontext.Lexer.Next(); - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - if (m_Statements != null) - { - foreach (Statement s in m_Statements) - { - s.Compile(bc); - } - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/EmptyStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/EmptyStatement.cs deleted file mode 100644 index b0076749..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/EmptyStatement.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class EmptyStatement : Statement - { - public EmptyStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForEachLoopStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForEachLoopStatement.cs deleted file mode 100644 index b7496871..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForEachLoopStatement.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ForEachLoopStatement : Statement - { - RuntimeScopeBlock m_StackFrame; - SymbolRef[] m_Names; - IVariable[] m_NameExps; - Expression m_RValues; - Statement m_Block; - SourceRef m_RefFor, m_RefEnd; - - public ForEachLoopStatement(ScriptLoadingContext lcontext, Token firstNameToken, Token forToken) - : base(lcontext) - { - // for namelist in explist do block end | - - List names = new List(); - names.Add(firstNameToken.Text); - - while (lcontext.Lexer.Current.Type == TokenType.Comma) - { - lcontext.Lexer.Next(); - Token name = CheckTokenType(lcontext, TokenType.Name); - names.Add(name.Text); - } - - CheckTokenType(lcontext, TokenType.In); - - m_RValues = new ExprListExpression(Expression.ExprList(lcontext), lcontext); - - lcontext.Scope.PushBlock(); - - m_Names = names - .Select(n => lcontext.Scope.TryDefineLocal(n)) - .ToArray(); - - m_NameExps = m_Names - .Select(s => new SymbolRefExpression(lcontext, s)) - .Cast() - .ToArray(); - - m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); - - m_Block = new CompositeStatement(lcontext); - - m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - - m_StackFrame = lcontext.Scope.PopBlock(); - - lcontext.Source.Refs.Add(m_RefFor); - lcontext.Source.Refs.Add(m_RefEnd); - } - - - public override void Compile(ByteCode bc) - { - //for var_1, ···, var_n in explist do block end - - bc.PushSourceRef(m_RefFor); - - Loop L = new Loop() - { - Scope = m_StackFrame - }; - bc.LoopTracker.Loops.Push(L); - - // get iterator tuple - m_RValues.Compile(bc); - - // prepares iterator tuple - stack : iterator-tuple - bc.Emit_IterPrep(); - - // loop start - stack : iterator-tuple - int start = bc.GetJumpPointForNextInstruction(); - bc.Emit_Enter(m_StackFrame); - - // expand the tuple - stack : iterator-tuple, f, var, s - bc.Emit_ExpTuple(0); - - // calls f(s, var) - stack : iterator-tuple, iteration result - bc.Emit_Call(2, "for..in"); - - // perform assignment of iteration result- stack : iterator-tuple, iteration result - for (int i = 0; i < m_NameExps.Length; i++) - m_NameExps[i].CompileAssignment(bc, 0, i); - - // pops - stack : iterator-tuple - bc.Emit_Pop(); - - // repushes the main iterator var - stack : iterator-tuple, main-iterator-var - bc.Emit_Load(m_Names[0]); - - // updates the iterator tuple - stack : iterator-tuple, main-iterator-var - bc.Emit_IterUpd(); - - // checks head, jumps if nil - stack : iterator-tuple, main-iterator-var - var endjump = bc.Emit_Jump(OpCode.JNil, -1); - - // executes the stuff - stack : iterator-tuple - m_Block.Compile(bc); - - bc.PopSourceRef(); - bc.PushSourceRef(m_RefEnd); - - // loop back again - stack : iterator-tuple - bc.Emit_Leave(m_StackFrame); - bc.Emit_Jump(OpCode.Jump, start); - - bc.LoopTracker.Loops.Pop(); - - int exitpointLoopExit = bc.GetJumpPointForNextInstruction(); - bc.Emit_Leave(m_StackFrame); - - int exitpointBreaks = bc.GetJumpPointForNextInstruction(); - - bc.Emit_Pop(); - - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpointBreaks; - - endjump.NumVal = exitpointLoopExit; - - bc.PopSourceRef(); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForLoopStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForLoopStatement.cs deleted file mode 100644 index 614c50b3..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ForLoopStatement.cs +++ /dev/null @@ -1,101 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ForLoopStatement : Statement - { - //for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end' - RuntimeScopeBlock m_StackFrame; - Statement m_InnerBlock; - SymbolRef m_VarName; - Expression m_Start, m_End, m_Step; - SourceRef m_RefFor, m_RefEnd; - - public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken) - : base(lcontext) - { - // for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | - - // lexer already at the '=' ! [due to dispatching vs for-each] - CheckTokenType(lcontext, TokenType.Op_Assignment); - - m_Start = Expression.Expr(lcontext); - CheckTokenType(lcontext, TokenType.Comma); - m_End = Expression.Expr(lcontext); - - if (lcontext.Lexer.Current.Type == TokenType.Comma) - { - lcontext.Lexer.Next(); - m_Step = Expression.Expr(lcontext); - } - else - { - m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1)); - } - - lcontext.Scope.PushBlock(); - m_VarName = lcontext.Scope.DefineLocal(nameToken.Text); - m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do)); - m_InnerBlock = new CompositeStatement(lcontext); - m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - m_StackFrame = lcontext.Scope.PopBlock(); - - lcontext.Source.Refs.Add(m_RefFor); - lcontext.Source.Refs.Add(m_RefEnd); - } - - - public override void Compile(ByteCode bc) - { - bc.PushSourceRef(m_RefFor); - - Loop L = new Loop() - { - Scope = m_StackFrame - }; - - bc.LoopTracker.Loops.Push(L); - - m_End.Compile(bc); - bc.Emit_ToNum(3); - m_Step.Compile(bc); - bc.Emit_ToNum(2); - m_Start.Compile(bc); - bc.Emit_ToNum(1); - - int start = bc.GetJumpPointForNextInstruction(); - var jumpend = bc.Emit_Jump(OpCode.JFor, -1); - bc.Emit_Enter(m_StackFrame); - //bc.Emit_SymStorN(m_VarName); - - bc.Emit_Store(m_VarName, 0, 0); - - m_InnerBlock.Compile(bc); - - bc.PopSourceRef(); - bc.PushSourceRef(m_RefEnd); - - bc.Emit_Debug("..end"); - bc.Emit_Leave(m_StackFrame); - bc.Emit_Incr(1); - bc.Emit_Jump(OpCode.Jump, start); - - bc.LoopTracker.Loops.Pop(); - - int exitpoint = bc.GetJumpPointForNextInstruction(); - - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; - - jumpend.NumVal = exitpoint; - bc.Emit_Pop(3); - - bc.PopSourceRef(); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionCallStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionCallStatement.cs deleted file mode 100755 index c48f5bee..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionCallStatement.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class FunctionCallStatement : Statement - { - FunctionCallExpression m_FunctionCallExpression; - - public FunctionCallStatement(ScriptLoadingContext lcontext, FunctionCallExpression functionCallExpression) - : base(lcontext) - { - m_FunctionCallExpression = functionCallExpression; - lcontext.Source.Refs.Add(m_FunctionCallExpression.SourceRef); - } - - - public override void Compile(ByteCode bc) - { - using (bc.EnterSource(m_FunctionCallExpression.SourceRef)) - { - m_FunctionCallExpression.Compile(bc); - RemoveBreakpointStop(bc.Emit_Pop()); - } - } - - private void RemoveBreakpointStop(Instruction instruction) - { - instruction.SourceCodeRef = null; - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionDefinitionStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionDefinitionStatement.cs deleted file mode 100644 index 73fc126f..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/FunctionDefinitionStatement.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class FunctionDefinitionStatement : Statement - { - SymbolRef m_FuncSymbol; - SourceRef m_SourceRef; - - bool m_Local = false; - bool m_IsMethodCallingConvention = false; - string m_MethodName = null; - - string m_FriendlyName; - List m_TableAccessors; - FunctionDefinitionExpression m_FuncDef; - - public FunctionDefinitionStatement(ScriptLoadingContext lcontext, bool local, Token localToken) - : base(lcontext) - { - // here lexer must be at the 'function' keyword - Token funcKeyword = CheckTokenType(lcontext, TokenType.Function); - funcKeyword = localToken ?? funcKeyword; // for debugger purposes - - m_Local = local; - - if (m_Local) - { - Token name = CheckTokenType(lcontext, TokenType.Name); - m_FuncSymbol = lcontext.Scope.TryDefineLocal(name.Text); - m_FriendlyName = string.Format("{0} (local)", name.Text); - m_SourceRef = funcKeyword.GetSourceRef(name); - } - else - { - Token name = CheckTokenType(lcontext, TokenType.Name); - string firstName = name.Text; - - m_SourceRef = funcKeyword.GetSourceRef(name); - - m_FuncSymbol = lcontext.Scope.Find(firstName); - m_FriendlyName = firstName; - - if (lcontext.Lexer.Current.Type != TokenType.Brk_Open_Round) - { - m_TableAccessors = new List(); - - while (lcontext.Lexer.Current.Type != TokenType.Brk_Open_Round) - { - Token separator = lcontext.Lexer.Current; - - if (separator.Type != TokenType.Colon && separator.Type != TokenType.Dot) - UnexpectedTokenType(separator); - - lcontext.Lexer.Next(); - - Token field = CheckTokenType(lcontext, TokenType.Name); - - m_FriendlyName += separator.Text + field.Text; - m_SourceRef = funcKeyword.GetSourceRef(field); - - if (separator.Type == TokenType.Colon) - { - m_MethodName = field.Text; - m_IsMethodCallingConvention = true; - break; - } - else - { - m_TableAccessors.Add(field.Text); - } - } - - if (m_MethodName == null && m_TableAccessors.Count > 0) - { - m_MethodName = m_TableAccessors[m_TableAccessors.Count - 1]; - m_TableAccessors.RemoveAt(m_TableAccessors.Count - 1); - } - } - } - - m_FuncDef = new FunctionDefinitionExpression(lcontext, m_IsMethodCallingConvention, false); - lcontext.Source.Refs.Add(m_SourceRef); - } - - public override void Compile(Execution.VM.ByteCode bc) - { - using (bc.EnterSource(m_SourceRef)) - { - if (m_Local) - { - bc.Emit_Literal(DynValue.Nil); - bc.Emit_Store(m_FuncSymbol, 0, 0); - m_FuncDef.Compile(bc, () => SetFunction(bc, 2), m_FriendlyName); - } - else if (m_MethodName == null) - { - m_FuncDef.Compile(bc, () => SetFunction(bc, 1), m_FriendlyName); - } - else - { - m_FuncDef.Compile(bc, () => SetMethod(bc), m_FriendlyName); - } - } - } - - private int SetMethod(Execution.VM.ByteCode bc) - { - int cnt = 0; - - cnt += bc.Emit_Load(m_FuncSymbol); - - foreach (string str in m_TableAccessors) - { - bc.Emit_Index(DynValue.NewString(str), true); - cnt += 1; - } - - bc.Emit_IndexSet(0, 0, DynValue.NewString(m_MethodName), true); - - return 1 + cnt; - } - - private int SetFunction(Execution.VM.ByteCode bc, int numPop) - { - int num = bc.Emit_Store(m_FuncSymbol, 0, 0); - bc.Emit_Pop(numPop); - return num + 1; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/GotoStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/GotoStatement.cs deleted file mode 100644 index eac339ad..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/GotoStatement.cs +++ /dev/null @@ -1,53 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class GotoStatement : Statement - { - internal SourceRef SourceRef { get; private set; } - internal Token GotoToken { get; private set; } - public string Label { get; private set; } - - internal int DefinedVarsCount { get; private set; } - internal string LastDefinedVarName { get; private set; } - - Instruction m_Jump; - int m_LabelAddress = -1; - - public GotoStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - GotoToken = CheckTokenType(lcontext, TokenType.Goto); - Token name = CheckTokenType(lcontext, TokenType.Name); - - SourceRef = GotoToken.GetSourceRef(name); - - Label = name.Text; - - lcontext.Scope.RegisterGoto(this); - } - - public override void Compile(ByteCode bc) - { - m_Jump = bc.Emit_Jump(OpCode.Jump, m_LabelAddress); - } - - internal void SetDefinedVars(int definedVarsCount, string lastDefinedVarsName) - { - DefinedVarsCount = definedVarsCount; - LastDefinedVarName = lastDefinedVarsName; - } - - - internal void SetAddress(int labelAddress) - { - m_LabelAddress = labelAddress; - - if (m_Jump != null) - m_Jump.NumVal = labelAddress; - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/IfStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/IfStatement.cs deleted file mode 100644 index 5f5dda5a..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/IfStatement.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class IfStatement : Statement - { - private class IfBlock - { - public Expression Exp; - public Statement Block; - public RuntimeScopeBlock StackFrame; - public SourceRef Source; - } - - List m_Ifs = new List(); - IfBlock m_Else = null; - SourceRef m_End; - - public IfStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - while (lcontext.Lexer.Current.Type != TokenType.Else && lcontext.Lexer.Current.Type != TokenType.End) - { - m_Ifs.Add(CreateIfBlock(lcontext)); - } - - if (lcontext.Lexer.Current.Type == TokenType.Else) - { - m_Else = CreateElseBlock(lcontext); - } - - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - lcontext.Source.Refs.Add(m_End); - } - - IfBlock CreateIfBlock(ScriptLoadingContext lcontext) - { - Token type = CheckTokenType(lcontext, TokenType.If, TokenType.ElseIf); - - lcontext.Scope.PushBlock(); - - var ifblock = new IfBlock(); - - ifblock.Exp = Expression.Expr(lcontext); - ifblock.Source = type.GetSourceRef(CheckTokenType(lcontext, TokenType.Then)); - ifblock.Block = new CompositeStatement(lcontext); - ifblock.StackFrame = lcontext.Scope.PopBlock(); - lcontext.Source.Refs.Add(ifblock.Source); - - - return ifblock; - } - - IfBlock CreateElseBlock(ScriptLoadingContext lcontext) - { - Token type = CheckTokenType(lcontext, TokenType.Else); - - lcontext.Scope.PushBlock(); - - var ifblock = new IfBlock(); - ifblock.Block = new CompositeStatement(lcontext); - ifblock.StackFrame = lcontext.Scope.PopBlock(); - ifblock.Source = type.GetSourceRef(); - lcontext.Source.Refs.Add(ifblock.Source); - return ifblock; - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - List endJumps = new List(); - - Instruction lastIfJmp = null; - - foreach (var ifblock in m_Ifs) - { - using (bc.EnterSource(ifblock.Source)) - { - if (lastIfJmp != null) - lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); - - ifblock.Exp.Compile(bc); - lastIfJmp = bc.Emit_Jump(OpCode.Jf, -1); - bc.Emit_Enter(ifblock.StackFrame); - ifblock.Block.Compile(bc); - } - - using (bc.EnterSource(m_End)) - bc.Emit_Leave(ifblock.StackFrame); - - endJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); - } - - lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); - - if (m_Else != null) - { - using (bc.EnterSource(m_Else.Source)) - { - bc.Emit_Enter(m_Else.StackFrame); - m_Else.Block.Compile(bc); - } - - using (bc.EnterSource(m_End)) - bc.Emit_Leave(m_Else.StackFrame); - } - - foreach(var endjmp in endJumps) - endjmp.NumVal = bc.GetJumpPointForNextInstruction(); - } - - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/LabelStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/LabelStatement.cs deleted file mode 100644 index 6d562d23..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/LabelStatement.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Collections.Generic; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class LabelStatement : Statement - { - public string Label { get; private set; } - public int Address { get; private set; } - public SourceRef SourceRef { get; private set; } - public Token NameToken { get; private set; } - - internal int DefinedVarsCount { get; private set; } - internal string LastDefinedVarName { get; private set; } - - List m_Gotos = new List(); - RuntimeScopeBlock m_StackFrame; - - - public LabelStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - CheckTokenType(lcontext, TokenType.DoubleColon); - NameToken = CheckTokenType(lcontext, TokenType.Name); - CheckTokenType(lcontext, TokenType.DoubleColon); - - SourceRef = NameToken.GetSourceRef(); - Label = NameToken.Text; - - lcontext.Scope.DefineLabel(this); - } - - internal void SetDefinedVars(int definedVarsCount, string lastDefinedVarsName) - { - DefinedVarsCount = definedVarsCount; - LastDefinedVarName = lastDefinedVarsName; - } - - internal void RegisterGoto(GotoStatement gotostat) - { - m_Gotos.Add(gotostat); - } - - - public override void Compile(Execution.VM.ByteCode bc) - { - bc.Emit_Clean(m_StackFrame); - - Address = bc.GetJumpPointForLastInstruction(); - - foreach (var gotostat in m_Gotos) - gotostat.SetAddress(this.Address); - } - - internal void SetScope(RuntimeScopeBlock runtimeScopeBlock) - { - m_StackFrame = runtimeScopeBlock; - } - } -} - diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/RepeatStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/RepeatStatement.cs deleted file mode 100644 index 7929ddf5..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/RepeatStatement.cs +++ /dev/null @@ -1,70 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class RepeatStatement : Statement - { - Expression m_Condition; - Statement m_Block; - RuntimeScopeBlock m_StackFrame; - SourceRef m_Repeat, m_Until; - - public RepeatStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - m_Repeat = CheckTokenType(lcontext, TokenType.Repeat).GetSourceRef(); - - lcontext.Scope.PushBlock(); - m_Block = new CompositeStatement(lcontext); - - Token until = CheckTokenType(lcontext, TokenType.Until); - - m_Condition = Expression.Expr(lcontext); - - m_Until = until.GetSourceRefUpTo(lcontext.Lexer.Current); - - m_StackFrame = lcontext.Scope.PopBlock(); - lcontext.Source.Refs.Add(m_Repeat); - lcontext.Source.Refs.Add(m_Until); - } - - public override void Compile(ByteCode bc) - { - Loop L = new Loop() - { - Scope = m_StackFrame - }; - - bc.PushSourceRef(m_Repeat); - - bc.LoopTracker.Loops.Push(L); - - int start = bc.GetJumpPointForNextInstruction(); - - bc.Emit_Enter(m_StackFrame); - m_Block.Compile(bc); - - bc.PopSourceRef(); - bc.PushSourceRef(m_Until); - bc.Emit_Debug("..end"); - - m_Condition.Compile(bc); - bc.Emit_Leave(m_StackFrame); - bc.Emit_Jump(OpCode.Jf, start); - - bc.LoopTracker.Loops.Pop(); - - int exitpoint = bc.GetJumpPointForNextInstruction(); - - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; - - bc.PopSourceRef(); - } - - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ReturnStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ReturnStatement.cs deleted file mode 100644 index e0ab2f98..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ReturnStatement.cs +++ /dev/null @@ -1,64 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -using MoonSharp.Interpreter.Tree.Expressions; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ReturnStatement: Statement - { - Expression m_Expression = null; - SourceRef m_Ref; - - public ReturnStatement(ScriptLoadingContext lcontext, Expression e, SourceRef sref) - : base(lcontext) - { - m_Expression = e; - m_Ref = sref; - lcontext.Source.Refs.Add(sref); - } - - - - - public ReturnStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - Token ret = lcontext.Lexer.Current; - - lcontext.Lexer.Next(); - - Token cur = lcontext.Lexer.Current; - - if (cur.IsEndOfBlock() || cur.Type == TokenType.SemiColon) - { - m_Expression = null; - m_Ref = ret.GetSourceRef(); - } - else - { - m_Expression = new ExprListExpression(Expression.ExprList(lcontext), lcontext); - m_Ref = ret.GetSourceRefUpTo(lcontext.Lexer.Current); - } - lcontext.Source.Refs.Add(m_Ref); - } - - - - public override void Compile(Execution.VM.ByteCode bc) - { - using (bc.EnterSource(m_Ref)) - { - if (m_Expression != null) - { - m_Expression.Compile(bc); - bc.Emit_Ret(1); - } - else - { - bc.Emit_Ret(0); - } - } - } - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ScopeBlockStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ScopeBlockStatement.cs deleted file mode 100644 index cac73104..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/ScopeBlockStatement.cs +++ /dev/null @@ -1,42 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class ScopeBlockStatement : Statement - { - Statement m_Block; - RuntimeScopeBlock m_StackFrame; - SourceRef m_Do, m_End; - - public ScopeBlockStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - lcontext.Scope.PushBlock(); - - m_Do = CheckTokenType(lcontext, TokenType.Do).GetSourceRef(); - - m_Block = new CompositeStatement(lcontext); - - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - - m_StackFrame = lcontext.Scope.PopBlock(); - lcontext.Source.Refs.Add(m_Do); - lcontext.Source.Refs.Add(m_End); - } - - - - public override void Compile(Execution.VM.ByteCode bc) - { - using(bc.EnterSource(m_Do)) - bc.Emit_Enter(m_StackFrame); - - m_Block.Compile(bc); - - using (bc.EnterSource(m_End)) - bc.Emit_Leave(m_StackFrame); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/WhileStatement.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/WhileStatement.cs deleted file mode 100644 index 39bcfd70..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/Tree/Statements/WhileStatement.cs +++ /dev/null @@ -1,79 +0,0 @@ -using MoonSharp.Interpreter.Debugging; -using MoonSharp.Interpreter.Execution; -using MoonSharp.Interpreter.Execution.VM; - - -namespace MoonSharp.Interpreter.Tree.Statements -{ - class WhileStatement : Statement - { - Expression m_Condition; - Statement m_Block; - RuntimeScopeBlock m_StackFrame; - SourceRef m_Start, m_End; - - public WhileStatement(ScriptLoadingContext lcontext) - : base(lcontext) - { - Token whileTk = CheckTokenType(lcontext, TokenType.While); - - m_Condition = Expression.Expr(lcontext); - - m_Start = whileTk.GetSourceRefUpTo(lcontext.Lexer.Current); - - //m_Start = BuildSourceRef(context.Start, exp.Stop); - //m_End = BuildSourceRef(context.Stop, context.END()); - - lcontext.Scope.PushBlock(); - CheckTokenType(lcontext, TokenType.Do); - m_Block = new CompositeStatement(lcontext); - m_End = CheckTokenType(lcontext, TokenType.End).GetSourceRef(); - m_StackFrame = lcontext.Scope.PopBlock(); - - lcontext.Source.Refs.Add(m_Start); - lcontext.Source.Refs.Add(m_End); - } - - - public override void Compile(ByteCode bc) - { - Loop L = new Loop() - { - Scope = m_StackFrame - }; - - - bc.LoopTracker.Loops.Push(L); - - bc.PushSourceRef(m_Start); - - int start = bc.GetJumpPointForNextInstruction(); - - m_Condition.Compile(bc); - var jumpend = bc.Emit_Jump(OpCode.Jf, -1); - - bc.Emit_Enter(m_StackFrame); - - m_Block.Compile(bc); - - bc.PopSourceRef(); - bc.Emit_Debug("..end"); - bc.PushSourceRef(m_End); - - bc.Emit_Leave(m_StackFrame); - bc.Emit_Jump(OpCode.Jump, start); - - bc.LoopTracker.Loops.Pop(); - - int exitpoint = bc.GetJumpPointForNextInstruction(); - - foreach (Instruction i in L.BreakJumps) - i.NumVal = exitpoint; - - jumpend.NumVal = exitpoint; - - bc.PopSourceRef(); - } - - } -} diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/MoonSharp.Interpreter.portable40.csproj b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/MoonSharp.Interpreter.portable40.csproj deleted file mode 100644 index 128614e7..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/MoonSharp.Interpreter.portable40.csproj +++ /dev/null @@ -1,826 +0,0 @@ - - - - - 10.0 - Debug - AnyCPU - {49F32476-FCA0-45FD-8F89-0C7C0D15E409} - Library - Properties - MoonSharp.Interpreter - MoonSharp.Interpreter - en-US - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile328 - v4.0 - true - ..\..\..\keypair.snk - - - true - full - false - bin\Debug\ - TRACE;DEBUG;HASDYNAMIC,PCL - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;HASDYNAMIC,PCL - prompt - 4 - bin\Release\MoonSharp.Interpreter.XML - - - true - bin\Dev\ - TRACE;DEBUG;HASDYNAMIC,PCL - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - TRACE;DEBUG;HASDYNAMIC,PCL - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - AsyncExtensions.cs - - - AstNode.cs - - - Framework.cs - - - FrameworkBase.cs - - - FrameworkCLR.cs - - - FrameworkReflectionBase.cs - - - FrameworkClrBase.cs - - - FrameworkCore.cs - - - FrameworkPCL.cs - - - FrameworkWin8.cs - - - CoroutineModule.cs - - - BasicModule.cs - - - DebugModule.cs - - - DynamicModule.cs - - - ErrorHandlingModule.cs - - - BinaryEncoding.cs - - - FileUserData.cs - - - IoModule.cs - - - FileUserDataBase.cs - - - StandardIOFileUserDataBase.cs - - - StreamFileUserDataBase.cs - - - JsonModule.cs - - - LoadModule.cs - - - Bit32Module.cs - - - MathModule.cs - - - MetaTableModule.cs - - - OsSystemModule.cs - - - OsTimeModule.cs - - - KopiLua_StrLib.cs - - - MultiDictionary.cs - - - ReferenceEqualityComparer.cs - - - DebuggerCaps.cs - - - DebugService.cs - - - OpCodeMetadataType.cs - - - MoonSharpPropertyAttribute.cs - - - MoonSharpUserDataMetamethodAttribute.cs - - - MoonSharpHideMemberAttribute.cs - - - MoonSharpHiddenAttribute.cs - - - IMemberDescriptor.cs - - - IOptimizableDescriptor.cs - - - IOverloadableMemberDescriptor.cs - - - IWireableDescriptor.cs - - - MemberDescriptorAccess.cs - - - ParameterDescriptor.cs - - - ClrToScriptConversions.cs - - - NumericConversions.cs - - - ScriptToClrConversions.cs - - - StringConversions.cs - - - TableConversions.cs - - - CustomConvertersCollection.cs - - - DescriptorHelpers.cs - - - DispatchingUserDataDescriptor.cs - - - IGeneratorUserDataDescriptor.cs - - - PropertyTableAssigner.cs - - - DelegateProxyFactory.cs - - - IProxyFactory.cs - - - ReflectionSpecialNames.cs - - - AutomaticRegistrationPolicy.cs - - - DefaultRegistrationPolicy.cs - - - PermanentRegistrationPolicy.cs - - - IRegistrationPolicy.cs - - - EventFacade.cs - - - DefaultValue.cs - - - HardwiredMemberDescriptor.cs - - - HardwiredMethodMemberDescriptor.cs - - - HardwiredUserDataDescriptor.cs - - - ArrayMemberDescriptor.cs - - - ProxyUserDataDescriptor.cs - - - ObjectCallbackMemberDescriptor.cs - - - FunctionMemberDescriptorBase.cs - - - StandardEnumUserDataDescriptor.cs - - - DynValueMemberDescriptor.cs - - - EventMemberDescriptor.cs - - - OverloadedMethodMemberDescriptor.cs - - - FieldMemberDescriptor.cs - - - ValueTypeDefaultCtorMemberDescriptor.cs - - - StandardGenericsUserDataDescriptor.cs - - - ExtensionMethodsRegistry.cs - - - TypeDescriptorRegistry.cs - - - BinDumpBinaryReader.cs - - - Code - BinDumpBinaryWriter.cs - - - UndisposableStream.cs - - - InstructionFieldUsage.cs - - - Processor_BinaryDump.cs - - - InteropRegistrationPolicy.cs - - - IUserDataType.cs - - - ScriptFunctionDelegate.cs - - - TypeValidationFlags.cs - - - DynamicExpressionException.cs - - - DynamicExpression.cs - - - CallStackItemFlags.cs - - - AnonWrapper.cs - - - IUserDataDescriptor.cs - - - CharPtr.cs - - - LuaBase.cs - - - StringRange.cs - - - Tools.cs - - - StringModule.cs - - - TableIteratorsModule.cs - - - TableModule.cs - - - Extension_Methods.cs - - - FastStackDynamic.cs - - - LinkedListIndex.cs - - - Slice.cs - - - Coroutine.cs - - - IScriptPrivateResource.cs - - - RefIdObject.cs - - - TailCallData.cs - - - Code - UserData.cs - - - WellKnownSymbols.cs - - - YieldRequest.cs - - - DebuggerAction.cs - - - IDebugger.cs - - - SourceRef.cs - - - WatchItem.cs - - - WatchType.cs - - - DummyPerformanceStopwatch.cs - - - IPerformanceStopwatch.cs - - - PerformanceCounter.cs - - - GlobalPerformanceStopwatch.cs - - - PerformanceCounterType.cs - - - PerformanceStatistics.cs - - - PerformanceResult.cs - - - PerformanceStopwatch.cs - - - Code - ScriptRuntimeException.cs - - - InternalErrorException.cs - - - InterpreterException.cs - - - SyntaxErrorException.cs - - - CallbackArguments.cs - - - Closure.cs - - - CallbackFunction.cs - - - Code - DynValue.cs - - - TablePair.cs - - - Code - ScriptExecutionContext.cs - - - SourceCode.cs - - - CoroutineState.cs - - - ExecutionState.cs - - - DebugContext.cs - - - Processor_Coroutines.cs - - - Processor_Errors.cs - - - EnumerableWrapper.cs - - - LinqHelpers.cs - - - LuaBase_CLib.cs - - - LuaLBuffer.cs - - - LuaState.cs - - - MoonSharpUserDataAttribute.cs - - - MoonSharpVisibleAttribute.cs - - - Code - AutoDescribingUserDataDescriptor.cs - - - Code - CompositeUserDataDescriptor.cs - - - StandardUserDataDescriptor.cs - - - InteropAccessMode.cs - - - MethodMemberDescriptor.cs - - - Code - PropertyMemberDescriptor.cs - - - ClosureContext.cs - - - LoopTracker.cs - - - IClosureBuilder.cs - - - SymbolRefType.cs - - - SymbolRef.cs - - - BuildTimeScope.cs - - - BuildTimeScopeBlock.cs - - - BuildTimeScopeFrame.cs - - - RuntimeScopeBlock.cs - - - RuntimeScopeFrame.cs - - - ScriptLoadingContext.cs - - - DataType.cs - - - EmbeddedResourcesScriptLoader.cs - - - FileSystemScriptLoader.cs - - - InvalidScriptLoader.cs - - - ColonOperatorBehaviour.cs - - - FuzzySymbolMatchingBehavior.cs - - - DotNetCorePlatformAccessor.cs - - - ReplHistoryNavigator.cs - - - ReplInterpreterScriptLoader.cs - - - ScriptLoaderBase.cs - - - IScriptLoader.cs - - - UnityAssetsScriptLoader.cs - - - MoonSharpModuleConstantAttribute.cs - - - NameSpace_XmlHelp.cs - - - IPlatformAccessor.cs - - - PlatformAccessorBase.cs - - - PlatformAutoDetector.cs - - - LimitedPlatformAccessor.cs - - - StandardFileType.cs - - - StandardPlatformAccessor.cs - - - Attributes.cs - - - Stopwatch.cs - - - ReplInterpreter.cs - - - Script.cs - - - Table.cs - - - ByteCode.cs - - - FastStack.cs - - - Instruction.cs - - - OpCode.cs - - - CallStackItem.cs - - - Code - Processor.cs - - - Processor_Debugger.cs - - - Processor_IExecutionContext.cs - - - Processor_InstructionLoop.cs - - - Processor_Scope.cs - - - Processor_UtilityFunctions.cs - - - CoreModules.cs - - - Code - ModuleRegister.cs - - - MoonSharpModuleMethodAttribute.cs - - - Code - MoonSharpModuleAttribute.cs - - - ScriptGlobalOptions.cs - - - ScriptOptions.cs - - - JsonNull.cs - - - JsonTableConverter.cs - - - ObjectValueConverter.cs - - - SerializationExtensions.cs - - - AdjustmentExpression.cs - - - BinaryOperatorExpression.cs - - - DynamicExprExpression.cs - - - FunctionCallExpression.cs - - - FunctionDefinitionExpression.cs - - - LiteralExpression.cs - - - UnaryOperatorExpression.cs - - - Loader_Fast.cs - - - GotoStatement.cs - - - IVariable.cs - - - AssemblyInfo.cs - - - ExprListExpression.cs - - - IndexExpression.cs - - - LexerUtils.cs - - - EmptyStatement.cs - - - FunctionCallStatement.cs - - - FunctionDefinitionStatement.cs - - - Expression_.cs - - - SymbolRefExpression.cs - - - Lexer.cs - - - Token.cs - - - TokenType.cs - - - Loop.cs - - - NodeBase.cs - - - AssignmentStatement.cs - - - Code - ChunkStatement.cs - - - CompositeStatement.cs - - - BreakStatement.cs - - - ForEachLoopStatement.cs - - - ForLoopStatement.cs - - - IfStatement.cs - - - Statement.cs - - - LabelStatement.cs - - - RepeatStatement.cs - - - ReturnStatement.cs - - - TableConstructor.cs - - - ScopeBlockStatement.cs - - - WhileStatement.cs - - - - - \ No newline at end of file diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/Properties/AssemblyInfo.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/Properties/AssemblyInfo.cs deleted file mode 100644 index c13b6481..00000000 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.portable40/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Resources; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.Intepreter.portable40")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MoonSharp.Intepreter.portable40")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("en")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MoonSharp.RemoteDebugger/DebugServer.cs b/src/MoonSharp.RemoteDebugger/DebugServer.cs deleted file mode 100644 index 2a4f05f7..00000000 --- a/src/MoonSharp.RemoteDebugger/DebugServer.cs +++ /dev/null @@ -1,470 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.RemoteDebugger.Network; -using MoonSharp.RemoteDebugger.Threading; - -namespace MoonSharp.RemoteDebugger -{ - public class DebugServer : IDebugger, IDisposable - { - List m_Watches = new List(); - HashSet m_WatchesChanging = new HashSet(); - Utf8TcpServer m_Server; - Script m_Script; - string m_AppName; - object m_Lock = new object(); - BlockingQueue m_QueuedActions = new BlockingQueue(); - SourceRef m_LastSentSourceRef = null; - bool m_InGetActionLoop = false; - bool m_HostBusySent = false; - private bool m_RequestPause = false; - string[] m_CachedWatches = new string[(int)WatchType.MaxValue]; - bool m_FreeRunAfterAttach; - Regex m_ErrorRegEx = new Regex(@"\A.*\Z"); - - - public DebugServer(string appName, Script script, int port, Utf8TcpServerOptions options, bool freeRunAfterAttach) - { - m_AppName = appName; - - m_Server = new Utf8TcpServer(port, 1 << 20, '\0', options); - m_Server.Start(); - m_Server.DataReceived += m_Server_DataReceived; - m_Script = script; - m_FreeRunAfterAttach = freeRunAfterAttach; - } - - public string AppName { get { return m_AppName; } } - public int Port { get { return m_Server.PortNumber; } } - - public string GetState() - { - if (m_HostBusySent) - return "Busy"; - else if (m_InGetActionLoop) - return "Waiting debugger"; - else - return "Unknown"; - } - - public int ConnectedClients() - { - return m_Server.GetConnectedClients(); - } - - - #region Writes - - public void SetSourceCode(SourceCode sourceCode) - { - Send(xw => - { - using (xw.Element("source-code")) - { - xw.Attribute("id", sourceCode.SourceID) - .Attribute("name", sourceCode.Name); - - foreach (string line in sourceCode.Lines) - xw.ElementCData("l", EpurateNewLines(line)); - } - }); - } - - private string EpurateNewLines(string line) - { - return line.Replace('\n', ' ').Replace('\r', ' '); - } - - - private void Send(Action a) - { - XmlWriterSettings xs = new XmlWriterSettings() - { - CheckCharacters = true, - CloseOutput = true, - ConformanceLevel = ConformanceLevel.Fragment, - Encoding = Encoding.UTF8, - Indent = false, - }; - - StringBuilder sb = new StringBuilder(); - XmlWriter xw = XmlWriter.Create(sb, xs); - - a(xw); - - xw.Close(); - - string xml = sb.ToString(); - m_Server.BroadcastMessage(xml); - } - - - private void SendWelcome() - { - Send(xw => - { - using (xw.Element("welcome")) - { - xw.Attribute("app", m_AppName) - .Attribute("moonsharpver", Assembly.GetAssembly(typeof(Script)).GetName().Version.ToString()); - } - }); - - SendOption("error_rx", m_ErrorRegEx.ToString()); - } - - public void Update(WatchType watchType, IEnumerable items) - { - if (watchType != WatchType.CallStack && watchType != WatchType.Watches) - return; - - int watchIdx = (int)watchType; - - string watchHash = string.Join("|", items.Select(l => l.ToString()).ToArray()); - - if (m_CachedWatches[watchIdx] == null || m_CachedWatches[watchIdx] != watchHash) - { - m_CachedWatches[watchIdx] = watchHash; - - Send(xw => - { - using (xw.Element(watchType.ToString().ToLowerInvariant())) - { - foreach (WatchItem wi in items) - { - using (xw.Element("item")) - { - if (wi.Name == null) - { - if (watchType == WatchType.CallStack) - { - xw.Attribute("name", ((wi.RetAddress < 0) ? "" : "")); - } - else - { - xw.Attribute("name", "(null name ??)"); - } - } - else - { - xw.Attribute("name", wi.Name); - } - - - - if (wi.Value != null) - { - xw.Attribute("value", wi.Value.ToString()); - xw.Attribute("type", - wi.IsError ? "error" : - wi.Value.Type.ToLuaDebuggerString()); - } - - xw.Attribute("address", wi.Address.ToString("X8")); - xw.Attribute("baseptr", wi.BasePtr.ToString("X8")); - xw.Attribute("lvalue", wi.LValue); - xw.Attribute("retaddress", wi.RetAddress.ToString("X8")); - } - } - } - }); - } - } - - public void SetByteCode(string[] byteCode) - { - // Skip sending bytecode updates for now. - //Send(xw => - // { - // using (xw.Element("bytecode")) - // { - // foreach (string line in byteCode) - // xw.Element("l", line); - // } - // }); - } - - #endregion - - public void QueueAction(DebuggerAction action) - { - m_QueuedActions.Enqueue(action); - } - - public DebuggerAction GetAction(int ip, SourceRef sourceref) - { - try - { - if (m_FreeRunAfterAttach) - { - m_FreeRunAfterAttach = false; - return new DebuggerAction() { Action = DebuggerAction.ActionType.Run }; - } - - m_InGetActionLoop = true; - m_RequestPause = false; - - if (m_HostBusySent) - { - m_HostBusySent = false; - SendMessage("Host ready!"); - } - - if (sourceref != m_LastSentSourceRef) - { - Send(xw => - { - SendSourceRef(xw, sourceref); - }); - } - - while (true) - { - DebuggerAction da = m_QueuedActions.Dequeue(); - - if (da.Action == DebuggerAction.ActionType.Refresh || da.Action == DebuggerAction.ActionType.HardRefresh) - { - lock (m_Lock) - { - HashSet existing = new HashSet(); - - // remove all not present anymore - m_Watches.RemoveAll(de => !m_WatchesChanging.Contains(de.ExpressionCode)); - - // add all missing - existing.UnionWith(m_Watches.Select(de => de.ExpressionCode)); - - m_Watches.AddRange(m_WatchesChanging - .Where(code => !existing.Contains(code)) - .Select(code => CreateDynExpr(code))); - } - - return da; - } - - if (da.Action == DebuggerAction.ActionType.ToggleBreakpoint || da.Action == DebuggerAction.ActionType.SetBreakpoint - || da.Action == DebuggerAction.ActionType.ClearBreakpoint) - return da; - - if (da.Age < TimeSpan.FromMilliseconds(100)) - return da; - } - } - finally - { - m_InGetActionLoop = false; - } - } - - private DynamicExpression CreateDynExpr(string code) - { - try - { - return m_Script.CreateDynamicExpression(code); - } - catch (Exception ex) - { - SendMessage(string.Format("Error setting watch {0} :\n{1}", code, ex.Message)); - return m_Script.CreateConstantDynamicExpression(code, DynValue.NewString(ex.Message)); - } - } - - private void SendSourceRef(XmlWriter xw, SourceRef sourceref) - { - using (xw.Element("source-loc")) - { - xw.Attribute("srcid", sourceref.SourceIdx) - .Attribute("cf", sourceref.FromChar) - .Attribute("ct", sourceref.ToChar) - .Attribute("lf", sourceref.FromLine) - .Attribute("lt", sourceref.ToLine); - } - } - - void m_Server_DataReceived(object sender, Utf8TcpPeerEventArgs e) - { - XmlDocument xdoc = new XmlDocument(); - xdoc.LoadXml(e.Message); - - if (xdoc.DocumentElement.Name == "policy-file-request") - { - Send(xw => - { - using (xw.Element("cross-domain-policy")) - { - using (xw.Element("allow-access-from")) - { - xw.Attribute("domain", "*"); - xw.Attribute("to-ports", m_Server.PortNumber); - } - } - }); - return; - } - - if (xdoc.DocumentElement.Name == "Command") - { - string cmd = xdoc.DocumentElement.GetAttribute("cmd").ToLowerInvariant(); - string arg = xdoc.DocumentElement.GetAttribute("arg"); - - switch (cmd) - { - case "handshake": - SendWelcome(); - - for (int i = 0; i < m_Script.SourceCodeCount; i++) - SetSourceCode(m_Script.GetSourceCode(i)); - break; - case "stepin": - QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.StepIn }); - break; - case "refresh": - lock (m_Lock) - { - for (int i = 0; i < (int)WatchType.MaxValue; i++) - m_CachedWatches[i] = null; - } - QueueRefresh(); - break; - case "run": - QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.Run }); - break; - case "stepover": - QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.StepOver }); - break; - case "stepout": - QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.StepOut }); - break; - case "pause": - m_RequestPause = true; - break; - case "error_rx": - m_ErrorRegEx = new Regex(arg.Trim()); - SendOption("error_rx", m_ErrorRegEx.ToString()); - break; - case "addwatch": - lock (m_Lock) - m_WatchesChanging.UnionWith(arg.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim())); - - QueueRefresh(); - break; - case "delwatch": - lock (m_Lock) - { - var args = arg.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - - foreach (var a in args) - m_WatchesChanging.Remove(a); - } - QueueRefresh(); - break; - case "breakpoint": - DebuggerAction.ActionType action = DebuggerAction.ActionType.ToggleBreakpoint; - - if (arg == "set") action = DebuggerAction.ActionType.SetBreakpoint; - else if (arg == "clear") action = DebuggerAction.ActionType.ClearBreakpoint; - - QueueAction(new DebuggerAction() - { - Action = action, - SourceID = int.Parse(xdoc.DocumentElement.GetAttribute("src")), - SourceLine = int.Parse(xdoc.DocumentElement.GetAttribute("line")), - SourceCol = int.Parse(xdoc.DocumentElement.GetAttribute("col")), - }); - break; - } - - } - } - - private void QueueRefresh() - { - if (!m_InGetActionLoop) - { - SendMessage("Host busy, wait for it to become ready..."); - m_HostBusySent = true; - } - - QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.HardRefresh }); - } - - private void SendOption(string optionName, string optionVal) - { - Send(xw => - { - using (xw.Element(optionName)) - { - xw.Attribute("arg", optionVal); - } - }); - } - - - private void SendMessage(string text) - { - Send(xw => - { - xw.ElementCData("message", text); - }); - } - - - public List GetWatchItems() - { - return m_Watches; - } - - - public bool IsPauseRequested() - { - return m_RequestPause; - } - - - public void SignalExecutionEnded() - { - Send(xw => xw.Element("execution-completed", "")); - } - - - public void RefreshBreakpoints(IEnumerable refs) - { - Send(xw => - { - using (xw.Element("breakpoints")) - { - foreach (var rf in refs) - SendSourceRef(xw, rf); - } - }); - } - - public bool SignalRuntimeException(ScriptRuntimeException ex) - { - SendMessage(string.Format("Error: {0}", ex.DecoratedMessage)); - m_RequestPause = m_ErrorRegEx.IsMatch(ex.Message); - return IsPauseRequested(); - } - - public void Dispose() - { - m_Server.Dispose(); - } - - public void SetDebugService(DebugService debugService) - { - } - - public DebuggerCaps GetDebuggerCaps() - { - return DebuggerCaps.CanDebugSourceCode; - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/DebugWebHost.cs b/src/MoonSharp.RemoteDebugger/DebugWebHost.cs deleted file mode 100644 index a276d895..00000000 --- a/src/MoonSharp.RemoteDebugger/DebugWebHost.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.RemoteDebugger.Network; - -namespace MoonSharp.RemoteDebugger -{ - public class DebugWebHost : HttpServer - { - public DebugWebHost(int port, Utf8TcpServerOptions options) - : base(port, options) - { - RegisterEmbeddedResource("Main.html", HttpResourceType.Html, "Debugger"); - RegisterEmbeddedResource("Main.swf", HttpResourceType.Binary); - RegisterEmbeddedResource("playerProductInstall.swf", HttpResourceType.Binary); - RegisterEmbeddedResource("swfobject.js", HttpResourceType.PlainText); - - RegisterEmbeddedResource("bootstrap.min.css", HttpResourceType.Css); - RegisterEmbeddedResource("theme.css", HttpResourceType.Css); - RegisterEmbeddedResource("moonsharpdbg.png", HttpResourceType.Png); - RegisterEmbeddedResource("bootstrap.min.js", HttpResourceType.Javascript); - RegisterEmbeddedResource("jquery.min.js", HttpResourceType.Javascript); - } - - private HttpResource RegisterEmbeddedResource(string resourceName, HttpResourceType type, string urlName = null) - { - urlName = urlName ?? resourceName; - - byte[] data = GetResourceData(resourceName); - - HttpResource r = HttpResource.CreateBinary(type, data); - RegisterResource("/" + urlName, r); - RegisterResource(urlName, r); - return r; - } - - private byte[] GetResourceData(string resourceName) - { - var assembly = Assembly.GetExecutingAssembly(); - - using (Stream stream = assembly.GetManifestResourceStream("MoonSharp.RemoteDebugger.Resources." + resourceName)) - { - byte[] data = new byte[stream.Length]; - stream.Read(data, 0, data.Length); - return data; - } - } - - public string GetJumpPageText() - { - byte[] data = GetResourceData("JumpPage.html"); - return Encoding.UTF8.GetString(data); - } - - - - - } -} diff --git a/src/MoonSharp.RemoteDebugger/MoonSharp.RemoteDebugger.net35-client.csproj b/src/MoonSharp.RemoteDebugger/MoonSharp.RemoteDebugger.net35-client.csproj deleted file mode 100644 index 4d8c40a8..00000000 --- a/src/MoonSharp.RemoteDebugger/MoonSharp.RemoteDebugger.net35-client.csproj +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Debug - AnyCPU - {43D3AD52-FED5-4305-B0F4-6B991220CD0A} - Library - Properties - MoonSharp.RemoteDebugger - MoonSharp.RemoteDebugger - v3.5 - 512 - Client - true - ..\keypair.snk - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AnyCPU - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\Dev\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Devp4\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - - - - - - - - - - - - {91ea9b9d-fe03-4273-bdaf-8ad42ede1e59} - MoonSharp.Interpreter.net35-client - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/MoonSharp.RemoteDebugger/Network/HttpResource.cs b/src/MoonSharp.RemoteDebugger/Network/HttpResource.cs deleted file mode 100644 index 05244c93..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/HttpResource.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.RemoteDebugger.Network -{ - public class HttpResource - { - public HttpResourceType Type { get; private set; } - public byte[] Data { get; private set; } - public Func, HttpResource> Callback { get; private set; } - - private HttpResource() { } - - public static HttpResource CreateBinary(HttpResourceType type, byte[] data) - { - return new HttpResource() - { - Type = type, - Data = data - }; - } - - public static HttpResource CreateBinary(HttpResourceType type, string base64data) - { - return new HttpResource() - { - Type = type, - Data = Convert.FromBase64String(base64data) - }; - } - - public static HttpResource CreateText(HttpResourceType type, string data) - { - return new HttpResource() - { - Type = type, - Data = Encoding.UTF8.GetBytes(data) - }; - } - - - public static HttpResource CreateCallback(Func, HttpResource> callback) - { - return new HttpResource() - { - Type = HttpResourceType.Callback, - Callback = callback - }; - } - - - public string GetContentTypeString() - { - switch (Type) - { - case HttpResourceType.PlainText: - return "text/plain"; - case HttpResourceType.Html: - return "text/html"; - case HttpResourceType.Json: - return "application/json"; - case HttpResourceType.Xml: - return "application/xml"; - case HttpResourceType.Jpeg: - return "image/jpeg"; - case HttpResourceType.Png: - return "image/png"; - case HttpResourceType.Binary: - return "application/octet-stream"; - case HttpResourceType.Javascript: - return "application/javascript"; - case HttpResourceType.Css: - return "text/css"; - case HttpResourceType.Callback: - default: - throw new InvalidOperationException(); - } - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/HttpResourceType.cs b/src/MoonSharp.RemoteDebugger/Network/HttpResourceType.cs deleted file mode 100644 index e49a9f50..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/HttpResourceType.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.RemoteDebugger.Network -{ - public enum HttpResourceType - { - PlainText, - Html, - Xml, - Json, - Jpeg, - Png, - Binary, - Callback, - Css, - Javascript - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/HttpServer.cs b/src/MoonSharp.RemoteDebugger/Network/HttpServer.cs deleted file mode 100644 index 299be9f2..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/HttpServer.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using MoonSharp.Interpreter; - -namespace MoonSharp.RemoteDebugger.Network -{ - /// - /// This is a very very (very!) simplified and light http server. It exists to run on platforms where - /// more standard methods offered by .NET BCL are not available and/or if priviledges cannot be - /// excalated. This just uses a TcpListener and a Socket. - /// This supports only GET method and basic (or no) authentication. - /// - public class HttpServer : IDisposable - { - Utf8TcpServer m_Server; - Dictionary> m_HttpData = new Dictionary>(); - Dictionary m_Resources = new Dictionary(); - object m_Lock = new object(); - - const string ERROR_TEMPLATE = "{0}

{0}

{1}
MoonSharp Remote Debugger / {2}
"; - - static readonly string VERSION = Assembly.GetExecutingAssembly().GetName().Version.ToString(); - readonly string ERROR_401 = string.Format(ERROR_TEMPLATE, "401 Unauthorized", "Please login.", VERSION); - readonly string ERROR_404 = string.Format(ERROR_TEMPLATE, "404 Not Found", "The specified resource cannot be found.", VERSION); - readonly string ERROR_500 = string.Format(ERROR_TEMPLATE, "500 Internal Server Error", "An internal server error occurred.", VERSION); - - public HttpServer(int port, Utf8TcpServerOptions options) - { - m_Server = new Utf8TcpServer(port, 100 << 10, '\n', options); - m_Server.DataReceived += OnDataReceivedAny; - m_Server.ClientDisconnected += OnClientDisconnected; - } - - public Func Authenticator { get; set; } - - public void Start() - { - m_Server.Start(); - } - - void OnDataReceivedAny(object sender, Utf8TcpPeerEventArgs e) - { - lock (m_Lock) - { - List httpdata; - - string msg = e.Message.Replace("\n", "").Replace("\r", ""); - - if (!m_HttpData.TryGetValue(e.Peer.Id, out httpdata)) - { - httpdata = new List(); - m_HttpData.Add(e.Peer.Id, httpdata); - } - - if (msg.Length == 0) - { - ExecHttpRequest(e.Peer, httpdata); - e.Peer.Disconnect(); - } - else - { - httpdata.Add(msg); - } - } - } - - private void SendHttp(Utf8TcpPeer peer, string responseCode, string contentType, string data, params string[] extraHeaders) - { - SendHttp(peer, responseCode, contentType, Encoding.UTF8.GetBytes(data), extraHeaders); - } - - - private void SendHttp(Utf8TcpPeer peer, string responseCode, string contentType, byte[] data, params string[] extraHeaders) - { - peer.Send("HTTP/1.0 {0}", responseCode); - peer.Send("Server: moonsharp-remote-debugger/{0}", VERSION); - peer.Send("Content-Type: {0}", contentType); - peer.Send("Content-Length: {0}", data.Length); - peer.Send("Connection: close"); - peer.Send("Cache-Control: max-age=0, no-cache"); - - foreach (string h in extraHeaders) - peer.Send(h); - - peer.Send(""); - peer.SendBinary(data); - } - - - private void ExecHttpRequest(Utf8TcpPeer peer, List httpdata) - { - try - { - if (Authenticator != null) - { - string authstr = httpdata.FirstOrDefault(s => s.StartsWith("Authorization:")); - bool authorized = false; - - if (authstr != null) - { - string user, password; - ParseAuthenticationString(authstr, out user, out password); - authorized = Authenticator(user, password); - } - - if (!authorized) - { - SendHttp(peer, "401 Not Authorized", "text/html", ERROR_401, "WWW-Authenticate: Basic realm=\"moonsharp-remote-debugger\""); - return; - } - } - - HttpResource res = GetResourceFromPath(httpdata[0]); - - if (res == null) - { - SendHttp(peer, "404 Not Found", "text/html", ERROR_404); - } - else - { - SendHttp(peer, "200 OK", res.GetContentTypeString(), res.Data); - } - } - catch (Exception ex) - { - m_Server.Logger(ex.Message); - - try - { - SendHttp(peer, "500 Internal Server Error", "text/html", ERROR_500); - } - catch (Exception ex2) - { - m_Server.Logger(ex2.Message); - } - } - } - - private void ParseAuthenticationString(string authstr, out string user, out string password) - { - // example: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== - user = null; password = null; - - string[] parts = authstr.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length < 3) - return; - - if (parts[1] != "Basic") - return; - - byte[] credentialBytes = Convert.FromBase64String(parts[2]); - string credentialString = Encoding.UTF8.GetString(credentialBytes); - string[] credentials = credentialString.Split(new char[] { ':' }, 2); - - if (credentials.Length != 2) - return; - - user = credentials[0]; - password = credentials[1]; - } - - - private HttpResource GetResourceFromPath(string path) - { - string[] parts = path.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length < 2) - return null; - - if (parts[0] != "GET") - return null; - - string uri = parts[1]; - - if (!uri.Contains('?')) - { - return GetResourceFromUri(uri, null); - } - else - { - string[] macroparts = uri.Split(new char[] { '?' }, 2); - uri = macroparts[0]; - string[] tuples = macroparts[1].Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); - - Dictionary args = new Dictionary(); - foreach (string t in tuples) - { - ParseArgument(t, args); - } - - return GetResourceFromUri(uri, args); - } - } - - private void ParseArgument(string t, Dictionary args) - { - string[] parts = t.Split(new char[] { '=' }, 2); - - if (parts.Length == 2) - args.Add(parts[0], parts[1]); - else - args.Add(t, null); - } - - private HttpResource GetResourceFromUri(string uri, Dictionary args) - { - if (uri != "/") - uri = uri.TrimEnd('/'); - - HttpResource ret; - if (m_Resources.TryGetValue(uri, out ret)) - { - if (ret.Type == HttpResourceType.Callback) - { - if (args == null) args = new Dictionary(); - args.Add("?", uri); - return ret.Callback(args); - } - else - { - return ret; - } - } - - return null; - } - - - - - void OnClientDisconnected(object sender, Utf8TcpPeerEventArgs e) - { - lock (m_Lock) - { - if (m_HttpData.ContainsKey(e.Peer.Id)) - m_HttpData.Remove(e.Peer.Id); - } - } - - /// - /// Registers the resource. - /// - /// The path, including a starting '/'. - /// The resource. - public void RegisterResource(string path, HttpResource resource) - { - m_Resources.Add(path, resource); - } - - public void Dispose() - { - m_Server.Dispose(); - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeer.cs b/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeer.cs deleted file mode 100644 index f2c2275d..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeer.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; - -namespace MoonSharp.RemoteDebugger.Network -{ - public class Utf8TcpPeer - { - Socket m_Socket; - Utf8TcpServer m_Server; - int m_PrevSize = 0; - byte[] m_RecvBuffer; - - public string Id { get; private set; } - - public event EventHandler ConnectionClosed; - public event EventHandler DataReceived; - - internal Utf8TcpPeer(Utf8TcpServer server, Socket socket) - { - m_Socket = socket; - m_Server = server; - m_RecvBuffer = new byte[m_Server.BufferSize]; - Id = Guid.NewGuid().ToString(); - } - - internal void Start() - { - m_Socket.BeginReceive(m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None, OnDataReceived, null); - } - - private void OnDataReceived(IAsyncResult ar) - { - try - { - bool dataReceived = false; - int size = m_Socket.EndReceive(ar); - - if (size == 0) - { - CloseConnection("zero byte received"); - return; - } - - int ptr0 = m_PrevSize; - m_PrevSize += size; - - do - { - dataReceived = false; - - char term = m_Server.PacketSeparator; - - - for (int i = ptr0; i < m_PrevSize; i++) - { - if (m_RecvBuffer[i] == term) - { - dataReceived = true; - string message = Encoding.UTF8.GetString(m_RecvBuffer, 0, i); - - for (int j = i + 1; j < m_PrevSize; j++) - { - m_RecvBuffer[j - (i + 1)] = m_RecvBuffer[j]; - } - - ptr0 = 0; - m_PrevSize = m_PrevSize - i - 1; - - if (DataReceived != null) - { - DataReceived(this, new Utf8TcpPeerEventArgs(this, message)); - } - - break; - } - } - } while (dataReceived); - - if (m_Socket.Connected) - m_Socket.BeginReceive(m_RecvBuffer, m_PrevSize, m_RecvBuffer.Length - m_PrevSize, SocketFlags.None, OnDataReceived, null); - } - catch (SocketException ex) - { - m_Server.Logger(ex.Message); - CloseConnection(ex.Message); - } - catch (ObjectDisposedException ex) - { - m_Server.Logger(ex.Message); - CloseConnection(ex.Message); - } - } - - - private void CloseConnection(string reason) - { - if (DataReceived != null) - { - ConnectionClosed(this, new Utf8TcpPeerEventArgs(this, reason)); - } - - try - { - m_Socket.Close(); - } - catch {} - } - - public void Send(string message) - { - SendTerminated(m_Server.CompleteMessage(message)); - } - - public void Send(string message, params object[] args) - { - SendTerminated(m_Server.CompleteMessage(string.Format(message, args))); - } - - - public void SendTerminated(string message) - { - byte[] bytes = Encoding.UTF8.GetBytes(message); - SendBinary(bytes); - } - - public void Disconnect() - { - m_Socket.Close(); - } - - public void SendBinary(byte[] bytes) - { - try - { - m_Socket.Send(bytes); - } - catch (SocketException ex) - { - m_Server.Logger(ex.Message); - CloseConnection(ex.Message); - } - catch (ObjectDisposedException ex) - { - m_Server.Logger(ex.Message); - CloseConnection(ex.Message); - } - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeerEventArgs.cs b/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeerEventArgs.cs deleted file mode 100644 index 3204f249..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpPeerEventArgs.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.RemoteDebugger.Network -{ - public class Utf8TcpPeerEventArgs : EventArgs - { - public Utf8TcpPeerEventArgs(Utf8TcpPeer peer, string message = null) - { - Peer = peer; - Message = message; - } - - public Utf8TcpPeer Peer { get; private set; } - public string Message { get; private set; } - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServer.cs b/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServer.cs deleted file mode 100644 index 9ceef521..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServer.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; - - -namespace MoonSharp.RemoteDebugger.Network -{ - public class Utf8TcpServer : IDisposable - { - int m_PortNumber = 1912; - IPAddress m_IPAddress; - TcpListener m_Listener = null; - Action m_Logger; - List m_PeerList = new List(); - object m_PeerListLock = new object(); - public char PacketSeparator { get; private set; } - - public Utf8TcpServerOptions Options { get; private set; } - - public event EventHandler ClientConnected; - public event EventHandler DataReceived; - public event EventHandler ClientDisconnected; - - public int PortNumber - { - get { return m_PortNumber; } - } - - - public Utf8TcpServer(int port, int bufferSize, char packetSeparator, Utf8TcpServerOptions options) - { - m_IPAddress = ((options & Utf8TcpServerOptions.LocalHostOnly) != 0) ? IPAddress.Loopback : IPAddress.Any; - m_PortNumber = port; - m_Logger = s => System.Diagnostics.Debug.WriteLine(s); - PacketSeparator = packetSeparator; - BufferSize = bufferSize; - Options = options; - } - - public Action Logger - { - get { return m_Logger; } - set { m_Logger = value ?? (s => Console.WriteLine(s)); } - } - - public void Start() - { - m_Listener = new TcpListener(m_IPAddress, m_PortNumber); - m_Listener.Start(); - m_Listener.BeginAcceptSocket(OnAcceptSocket, null); - } - - public int BufferSize { get; private set; } - - - private void OnAcceptSocket(IAsyncResult ar) - { - try - { - Socket s = m_Listener.EndAcceptSocket(ar); - AddNewClient(s); - m_Listener.BeginAcceptSocket(OnAcceptSocket, null); - } - catch (SocketException ex) - { - Logger("OnAcceptSocket : " + ex.Message); - } - catch (ObjectDisposedException ex) - { - Logger("OnAcceptSocket : " + ex.Message); - } - } - - public int GetConnectedClients() - { - lock (m_PeerListLock) - return m_PeerList.Count; - } - - - private void AddNewClient(Socket socket) - { - if ((Options & Utf8TcpServerOptions.SingleClientOnly) != 0) - { - lock (m_PeerListLock) - { - foreach (var pp in m_PeerList) - { - pp.Disconnect(); - } - } - } - - Utf8TcpPeer peer = new Utf8TcpPeer(this, socket); - - lock (m_PeerListLock) - { - m_PeerList.Add(peer); - peer.ConnectionClosed += OnPeerDisconnected; - peer.DataReceived += OnPeerDataReceived; - } - - - if (ClientConnected != null) - { - Utf8TcpPeerEventArgs args = new Utf8TcpPeerEventArgs(peer); - ClientConnected(this, args); - } - - peer.Start(); - } - - private void OnPeerDataReceived(object sender, Utf8TcpPeerEventArgs e) - { - if (DataReceived != null) - { - DataReceived(this, e); - } - } - - void OnPeerDisconnected(object sender, Utf8TcpPeerEventArgs e) - { - try - { - if (ClientDisconnected != null) - { - ClientDisconnected(this, e); - } - - lock (m_PeerListLock) - { - m_PeerList.Remove(e.Peer); - e.Peer.ConnectionClosed -= OnPeerDisconnected; - e.Peer.DataReceived -= OnPeerDataReceived; - } - } - catch - { - } - } - - public void BroadcastMessage(string message) - { - List peers; - - lock (m_PeerListLock) - { - peers = m_PeerList.ToList(); - } - - message = CompleteMessage(message); - - if (message == null) - return; - - foreach (Utf8TcpPeer peer in peers) - { - try - { - peer.SendTerminated(message); - } - catch { } - } - } - - public string CompleteMessage(string message) - { - if (string.IsNullOrEmpty(message)) - return PacketSeparator.ToString(); - - if (message[message.Length - 1] != PacketSeparator) - message = message + PacketSeparator; - - return message; - } - - public void Stop() - { - m_Listener.Stop(); - } - - - public void Dispose() - { - Stop(); - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServerOptions.cs b/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServerOptions.cs deleted file mode 100644 index 4485191e..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/Utf8TcpServerOptions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.RemoteDebugger.Network -{ - [Flags] - public enum Utf8TcpServerOptions - { - /// - /// Connections can come only from localhost - /// - LocalHostOnly = 1, - /// - /// As a client connects, every other non-connected client is disconnected - /// - SingleClientOnly = 2, - /// - /// The default - /// - Default = 0, - } -} diff --git a/src/MoonSharp.RemoteDebugger/Network/XmlWriter_Extensions.cs b/src/MoonSharp.RemoteDebugger/Network/XmlWriter_Extensions.cs deleted file mode 100644 index bae3663d..00000000 --- a/src/MoonSharp.RemoteDebugger/Network/XmlWriter_Extensions.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Xml; - -namespace MoonSharp.RemoteDebugger.Network -{ - static class XmlWriter_Extensions - { - private class RaiiExecutor : IDisposable - { - Action m_Action; - - public RaiiExecutor(Action a) - { - m_Action = a; - } - - public void Dispose() - { - m_Action(); - } - } - - public static IDisposable Element(this XmlWriter xw, string name) - { - xw.WriteStartElement(name); - return new RaiiExecutor(() => xw.WriteEndElement()); - } - - public static XmlWriter Attribute(this XmlWriter xw, string name, string val) - { - if (val == null) val = "(null)"; - xw.WriteAttributeString(name, val); - return xw; - } - - public static XmlWriter Attribute(this XmlWriter xw, string name, object val) - { - if (val == null) val = "(null)"; - xw.WriteAttributeString(name, val.ToString()); - return xw; - } - - public static XmlWriter Element(this XmlWriter xw, string name, string val) - { - if (val == null) val = "(null)"; - xw.WriteElementString(name, val); - return xw; - } - - public static XmlWriter ElementCData(this XmlWriter xw, string name, string val) - { - if (val == null) val = "(null)"; - - xw.WriteStartElement(name); - xw.WriteCData(val); - xw.WriteEndElement(); - return xw; - } - - public static XmlWriter Comment(this XmlWriter xw, object text) - { - if (text == null) return xw; - xw.WriteComment(text.ToString()); - return xw; - } - - public static XmlWriter Attribute(this XmlWriter xw, string name, string format, params object[] args) - { - xw.WriteAttributeString(name, string.Format(format, args)); - return xw; - } - - public static XmlWriter Element(this XmlWriter xw, string name, string format, params object[] args) - { - xw.WriteElementString(name, string.Format(format, args)); - return xw; - } - - public static XmlWriter ElementCData(this XmlWriter xw, string name, string format, params object[] args) - { - xw.WriteStartElement(name); - xw.WriteCData(string.Format(format, args)); - xw.WriteEndElement(); - return xw; - } - - public static XmlWriter Comment(this XmlWriter xw, string format, params object[] args) - { - xw.WriteComment(string.Format(format, args)); - return xw; - } - - - } -} diff --git a/src/MoonSharp.RemoteDebugger/Properties/AssemblyInfo.cs b/src/MoonSharp.RemoteDebugger/Properties/AssemblyInfo.cs deleted file mode 100644 index 1964fca7..00000000 --- a/src/MoonSharp.RemoteDebugger/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MoonSharp.RemoteDebugger")] -[assembly: AssemblyDescription("Remote Debugger for the MoonSharp interpreter")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://www.moonsharp.org")] -[assembly: AssemblyProduct("MoonSharp.Debugger")] -[assembly: AssemblyCopyright("Copyright © 2014-2015, Marco Mastropaolo")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -//[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -//[assembly: Guid("cb040393-a596-41b5-9b11-5d2bed6b768c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion(MoonSharp.Interpreter.Script.VERSION)] -[assembly: AssemblyFileVersion(MoonSharp.Interpreter.Script.VERSION)] diff --git a/src/MoonSharp.RemoteDebugger/RemoteDebugger.cs b/src/MoonSharp.RemoteDebugger/RemoteDebugger.cs deleted file mode 100644 index f03dad1c..00000000 --- a/src/MoonSharp.RemoteDebugger/RemoteDebugger.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.Interpreter; -using MoonSharp.RemoteDebugger.Network; - -namespace MoonSharp.RemoteDebugger -{ - public class RemoteDebuggerService : IDisposable - { - RemoteDebuggerOptions m_Options; - DebugWebHost m_HttpServer; - string m_JumpPage; - int m_RpcPortMax; - List m_DebugServers = new List(); - - object m_Lock = new object(); - - - public RemoteDebuggerService() - : this(RemoteDebuggerOptions.Default) - { } - - public RemoteDebuggerService(RemoteDebuggerOptions options) - { - m_Options = options; - - if (options.HttpPort.HasValue) - { - Utf8TcpServerOptions httpopts = options.NetworkOptions & (~Network.Utf8TcpServerOptions.SingleClientOnly); - m_HttpServer = new DebugWebHost(options.HttpPort.Value, httpopts); - - if (options.SingleScriptMode) - { - m_HttpServer.RegisterResource("/", HttpResource.CreateText(HttpResourceType.Html, - string.Format("", options.RpcPortBase))); - } - else - { - m_JumpPage = m_HttpServer.GetJumpPageText(); - - m_HttpServer.RegisterResource("/", HttpResource.CreateCallback(GetJumpPageData)); - } - - m_HttpServer.Start(); - } - - m_RpcPortMax = options.RpcPortBase; - } - - private HttpResource GetJumpPageData(Dictionary arg) - { - lock (m_Lock) - { - return HttpResource.CreateText(HttpResourceType.Html, - string.Format(m_JumpPage, GetJumpHtmlFragment())); - } - } - - public void Attach(Script S, string scriptName, bool freeRunAfterAttach = false) - { - lock (m_Lock) - { - DebugServer d = new DebugServer(scriptName, S, m_RpcPortMax, m_Options.NetworkOptions, freeRunAfterAttach); - S.AttachDebugger(d); - m_DebugServers.Add(d); - } - } - - public string GetJumpHtmlFragment() - { - StringBuilder sb = new StringBuilder(); - lock (m_Lock) - { - foreach(DebugServer d in m_DebugServers) - { - sb.AppendFormat("
\n", - d.Port, d.AppName, d.GetState(), d.ConnectedClients()); - } - } - return sb.ToString(); - } - - public void Dispose() - { - m_HttpServer.Dispose(); - m_DebugServers.ForEach(s => s.Dispose()); - } - - public string HttpUrlStringLocalHost - { - get - { - if (m_HttpServer != null) - { - return string.Format("http://127.0.0.1:{0}/", m_Options.HttpPort.Value); - } - return null; - } - } - } -} diff --git a/src/MoonSharp.RemoteDebugger/RemoteDebuggerOptions.cs b/src/MoonSharp.RemoteDebugger/RemoteDebuggerOptions.cs deleted file mode 100644 index 5ee36c03..00000000 --- a/src/MoonSharp.RemoteDebugger/RemoteDebuggerOptions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MoonSharp.RemoteDebugger.Network; - -namespace MoonSharp.RemoteDebugger -{ - public struct RemoteDebuggerOptions - { - public Utf8TcpServerOptions NetworkOptions; - - public bool SingleScriptMode; - - public int? HttpPort; - public int RpcPortBase; - - public static RemoteDebuggerOptions Default - { - get - { - return new RemoteDebuggerOptions() - { - NetworkOptions = Utf8TcpServerOptions.LocalHostOnly | Utf8TcpServerOptions.SingleClientOnly, - SingleScriptMode = false, - HttpPort = 2705, - RpcPortBase = 2006, - }; - } - } - - } -} diff --git a/src/MoonSharp.RemoteDebugger/Resources/JumpPage.html b/src/MoonSharp.RemoteDebugger/Resources/JumpPage.html deleted file mode 100644 index 38de533c..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/JumpPage.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - MoonSharp Remote Debugger - - - - - - - - - - - - -
- -
- -
- -
-

MoonSharp Debugger

-

Select which script you want to open the debugger for.

-
-
- -
- -
{1}{2}{3}{0}
- - - - - - - - {0} - - -
Script NameStateConnected debuggersPort
- - - - - - diff --git a/src/MoonSharp.RemoteDebugger/Resources/MXFTEText.css b/src/MoonSharp.RemoteDebugger/Resources/MXFTEText.css deleted file mode 100644 index 64b9d7c3..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/MXFTEText.css +++ /dev/null @@ -1,237 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* - This style sheet configures many -- but not all -- MX components - to use the new Flash Text Engine (FTE) and Text Layout Framework (TLF) - to display and edit text, rather than using the older TextField class. - - If you are using the command-line MXML compiler, you should apply - this style sheet as one of the themes for your application: - - mxmlc -theme+=frameworks/projects/spark/MXFTEText.css MyApp.mxml - - FTE and TLF provide text rendering and editing - with high-quality international typography and layout. - They support displaying left-to-right (ltr) text such as French, - right-to-left (rtl) text such as Arabic, and bidirectional text - such as a French phrase inside of an Arabic sentence. - FTE and TLF are used for all text rendering in Spark components. - - By using this style sheet, your MX and Spark components can use - the same embedded font; otherwise, you have to embed a font twice, - once with embedAsCFF="true" for Spark components using FTE/TLF - and once with embedAsCFF="false" for MX components using TextField. - - Note: The , , and - components are not supported by this style sheet, because the - FTETextField class does not support all the functionality - that TextField supports. - You should use the , , and - components instead if you require FTE/TLF text. - - You should not modify this file. -*/ - -@namespace charts "mx.charts.chartClasses.*"; -@namespace mx "library://ns.adobe.com/flex/mx"; -@namespace mxair "mx.core.windowClasses.*"; -@namespace olap "mx.controls.olapDataGridClasses.*"; -@namespace s "library://ns.adobe.com/flex/spark"; - -mx|AlertForm -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|Button -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|CalendarLayout -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ColorPicker -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|ComboBox -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|DataGrid -{ - defaultDataGridItemEditor: ClassReference("mx.controls.MXFTETextInput"); - defaultDataGridItemRenderer: ClassReference("mx.controls.dataGridClasses.FTEDataGridItemRenderer"); -} - -mx|DateChooser -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|DateField -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -s|FTEDataGridItemRenderer -{ - paddingLeft: 5 /* to match DataGridItemRenderer in the MX defaults.css */ -} - -mx|Label -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|List -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|ListItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|MenuBarItem -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|MenuItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -s|MXFTETextInput -{ - skinClass: ClassReference("spark.skins.spark.TextInputSkin"); -} - -mx|NumericStepper -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|Panel -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ProgressBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|SwatchPanel -{ - textInputClass: ClassReference("mx.controls.MXFTETextInput"); -} - -mx|TileListItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|TreeItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|ToolTip -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGrid -{ - defaultDataGridItemEditor: ClassReference("mx.controls.MXFTETextInput"); - defaultDataGridItemRenderer: ClassReference("mx.controls.advancedDataGridClasses.FTEAdvancedDataGridItemRenderer"); -} - -mx|AdvancedDataGridGroupItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGridHeaderRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|AdvancedDataGridSortItemRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mxair|StatusBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mxair|TitleBar -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|ChartLabel -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|DataTip -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|DualStyleObject -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -charts|Series -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -mx|LegendItem -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -olap|OLAPDataGridGroupRenderer -{ - textFieldClass: ClassReference("mx.core.UIFTETextField"); -} - -s|FTEAdvancedDataGridItemRenderer -{ - paddingLeft: 5 /* to match AdvancedDataGridItemRenderer in the MX defaults.css */ -} - diff --git a/src/MoonSharp.RemoteDebugger/Resources/Main.css b/src/MoonSharp.RemoteDebugger/Resources/Main.css deleted file mode 100644 index 08dfdfa1..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/Main.css +++ /dev/null @@ -1,154 +0,0 @@ -@namespace s "library://ns.adobe.com/flex/spark"; -@namespace mx "library://ns.adobe.com/flex/mx"; - -@font-face -{ - src: url("assets/Ubuntu-R.ttf"); - fontFamily: Ubuntu; - fontStyle: normal; - fontWeight: normal; - embed-as-cff: true; - advancedAntiAliasing: false; -} - -@font-face -{ - src: url("assets/Ubuntu-B.ttf"); - fontFamily: Ubuntu; - fontStyle: normal; - fontWeight: bold; - embed-as-cff: true; - advancedAntiAliasing: false; -} - -@font-face -{ - src: url("assets/UbuntuMono-R.ttf"); - fontFamily: UbuntuMono; - fontStyle: normal; - fontWeight: normal; - advancedAntiAliasing: true; -} - -global -{ - fontFamily: Ubuntu; - contentBackgroundColor: #555555; - chrome-color: #333333; - color: #EEEEEE; - symbol-color: #000000; - roll-over-color: #777777; - selection-color: #B1AEFA; - accent-color: #8C8C8C; - focus-color: #B1AEFA; - focusAlpha: 1; -} - -mx|Alert, mx|TitleWindow, mx|MenuBar, mx|Panel -{ - /* fontFamily: UbuntuMx; */ -} - - -mx|CheckBox,s|CheckBox -{ - symbolColor: #b1aefa; -} - - -s|List -{ - roll-over-color: #777777; - selection-color: #B1AEFA; -} - -s|Button -{ - cornerRadius: 0; - skinClass:ClassReference("CustomButtonSkin"); - borderWeight: 1; - borderColor: #000000; -} - -s|Button:over -{ - chrome-color: #999999; - borderColor: #b1aefa; - borderWeight: 1; - cornerRadius: 0; -} - -s|Button:down -{ - chrome-color: #222222; - borderColor: #b1aefa; - borderWeight: 1; - cornerRadius: 0; -} - -/* // mx|TabNavigator,mx|SwatchPanel */ - -s|Panel,mx|TitleWindow -{ - background-color: #666666; -} - -s|TextArea -{ - color: #CCCCCC; - background-color: #555555; - contentBackgroundColor: #555555; -} - -s|Panel -{ - chrome-color: #222222; - borderAlpha: 0.5; - borderColor: 0; - cornerRadius: 0; - dropShadowVisible: true; - background-color: #484848; -} - -s|RichEditableText -{ - focusedTextSelectionColor: #777777; - unfocusedTextSelectionColor: #777777; -} - - -mx|Accordion -{ - openDuration: 320; - chrome-color: #222222; -} - -s|DropDownList -{ - borderVisible : false; - contentBackgroundColor: #555555; -} - -s|DataGrid -{ - alternatingRowColors : #505050, #555555; - skinClass: ClassReference("CustomDataGridSkin") -} - -mx|ToolTip -{ - color: #000000; -} - - -mx|MenuBar -{ - selectionColor: #B1AEFA; - leading: 0; - contentBackgroundColor: #777777; - roll-over-color: #B1AEFA; -} - - - - diff --git a/src/MoonSharp.RemoteDebugger/Resources/Main.html b/src/MoonSharp.RemoteDebugger/Resources/Main.html deleted file mode 100644 index c3ebcb5a..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/Main.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
-

- To view this page ensure that Adobe Flash Player version - 11.1.0 or greater is installed. -

- -
- - - - diff --git a/src/MoonSharp.RemoteDebugger/Resources/Main.swf b/src/MoonSharp.RemoteDebugger/Resources/Main.swf deleted file mode 100644 index 8743ac1f..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/Main.swf and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-B.ttf b/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-B.ttf deleted file mode 100644 index c0142fea..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-B.ttf and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-R.ttf b/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-R.ttf deleted file mode 100644 index 45a038ba..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/Ubuntu-R.ttf and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/UbuntuMono-R.ttf b/src/MoonSharp.RemoteDebugger/Resources/assets/UbuntuMono-R.ttf deleted file mode 100644 index fdd309d7..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/UbuntuMono-R.ttf and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/add.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/add.gif deleted file mode 100644 index 252d7ebc..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/add.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/breakpoint.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/breakpoint.gif deleted file mode 100644 index f529c5a4..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/breakpoint.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/moonsharp.png b/src/MoonSharp.RemoteDebugger/Resources/assets/moonsharp.png deleted file mode 100644 index cceedb3e..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/moonsharp.png and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/pause.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/pause.gif deleted file mode 100644 index d645fa5c..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/pause.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/remove.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/remove.gif deleted file mode 100644 index b6922ac1..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/remove.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/run.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/run.gif deleted file mode 100644 index d6b3bdcc..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/run.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/step_current.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/step_current.gif deleted file mode 100644 index e3a7cc76..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/step_current.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/stepin.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/stepin.gif deleted file mode 100644 index 75d165bc..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/stepin.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/stepout.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/stepout.gif deleted file mode 100644 index 4c2f2193..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/stepout.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/assets/stepover.gif b/src/MoonSharp.RemoteDebugger/Resources/assets/stepover.gif deleted file mode 100644 index 1ec36ae2..00000000 Binary files a/src/MoonSharp.RemoteDebugger/Resources/assets/stepover.gif and /dev/null differ diff --git a/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.css b/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.css deleted file mode 100644 index 5d439f22..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.css +++ /dev/null @@ -1,6568 +0,0 @@ -/*! - * bootswatch v3.2.0 - * Homepage: http://bootswatch.com - * Copyright 2012-2014 Thomas Park - * Licensed under MIT - * Based on Bootstrap -*/ -/*! normalize.css v3.0.1 | MIT License | git.io/normalize */ -html { - font-family: sans-serif; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100%; -} -body { - margin: 0; -} -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -nav, -section, -summary { - display: block; -} -audio, -canvas, -progress, -video { - display: inline-block; - vertical-align: baseline; -} -audio:not([controls]) { - display: none; - height: 0; -} -[hidden], -template { - display: none; -} -a { - background: transparent; -} -a:active, -a:hover { - outline: 0; -} -abbr[title] { - border-bottom: 1px dotted; -} -b, -strong { - font-weight: bold; -} -dfn { - font-style: italic; -} -h1 { - font-size: 2em; - margin: 0.67em 0; -} -mark { - background: #ff0; - color: #000; -} -small { - font-size: 80%; -} -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} -sup { - top: -0.5em; -} -sub { - bottom: -0.25em; -} -img { - border: 0; -} -svg:not(:root) { - overflow: hidden; -} -figure { - margin: 1em 40px; -} -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0; -} -pre { - overflow: auto; -} -code, -kbd, -pre, -samp { - font-family: monospace, monospace; - font-size: 1em; -} -button, -input, -optgroup, -select, -textarea { - color: inherit; - font: inherit; - margin: 0; -} -button { - overflow: visible; -} -button, -select { - text-transform: none; -} -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; - cursor: pointer; -} -button[disabled], -html input[disabled] { - cursor: default; -} -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} -input { - line-height: normal; -} -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; - padding: 0; -} -input[type="number"]::-webkit-inner-spin-button, -input[type="number"]::-webkit-outer-spin-button { - height: auto; -} -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} -legend { - border: 0; - padding: 0; -} -textarea { - overflow: auto; -} -optgroup { - font-weight: bold; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -td, -th { - padding: 0; -} -@media print { - * { - text-shadow: none !important; - color: #000 !important; - background: transparent !important; - box-shadow: none !important; - } - a, - a:visited { - text-decoration: underline; - } - a[href]:after { - content: " (" attr(href) ")"; - } - abbr[title]:after { - content: " (" attr(title) ")"; - } - a[href^="javascript:"]:after, - a[href^="#"]:after { - content: ""; - } - pre, - blockquote { - border: 1px solid #999; - page-break-inside: avoid; - } - thead { - display: table-header-group; - } - tr, - img { - page-break-inside: avoid; - } - img { - max-width: 100% !important; - } - p, - h2, - h3 { - orphans: 3; - widows: 3; - } - h2, - h3 { - page-break-after: avoid; - } - select { - background: #fff !important; - } - .navbar { - display: none; - } - .table td, - .table th { - background-color: #fff !important; - } - .btn > .caret, - .dropup > .btn > .caret { - border-top-color: #000 !important; - } - .label { - border: 1px solid #000; - } - .table { - border-collapse: collapse !important; - } - .table-bordered th, - .table-bordered td { - border: 1px solid #ddd !important; - } -} -@font-face { - font-family: 'Glyphicons Halflings'; - src: url('../fonts/glyphicons-halflings-regular.eot'); - src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); -} -.glyphicon { - position: relative; - top: 1px; - display: inline-block; - font-family: 'Glyphicons Halflings'; - font-style: normal; - font-weight: normal; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} -.glyphicon-asterisk:before { - content: "\2a"; -} -.glyphicon-plus:before { - content: "\2b"; -} -.glyphicon-euro:before { - content: "\20ac"; -} -.glyphicon-minus:before { - content: "\2212"; -} -.glyphicon-cloud:before { - content: "\2601"; -} -.glyphicon-envelope:before { - content: "\2709"; -} -.glyphicon-pencil:before { - content: "\270f"; -} -.glyphicon-glass:before { - content: "\e001"; -} -.glyphicon-music:before { - content: "\e002"; -} -.glyphicon-search:before { - content: "\e003"; -} -.glyphicon-heart:before { - content: "\e005"; -} -.glyphicon-star:before { - content: "\e006"; -} -.glyphicon-star-empty:before { - content: "\e007"; -} -.glyphicon-user:before { - content: "\e008"; -} -.glyphicon-film:before { - content: "\e009"; -} -.glyphicon-th-large:before { - content: "\e010"; -} -.glyphicon-th:before { - content: "\e011"; -} -.glyphicon-th-list:before { - content: "\e012"; -} -.glyphicon-ok:before { - content: "\e013"; -} -.glyphicon-remove:before { - content: "\e014"; -} -.glyphicon-zoom-in:before { - content: "\e015"; -} -.glyphicon-zoom-out:before { - content: "\e016"; -} -.glyphicon-off:before { - content: "\e017"; -} -.glyphicon-signal:before { - content: "\e018"; -} -.glyphicon-cog:before { - content: "\e019"; -} -.glyphicon-trash:before { - content: "\e020"; -} -.glyphicon-home:before { - content: "\e021"; -} -.glyphicon-file:before { - content: "\e022"; -} -.glyphicon-time:before { - content: "\e023"; -} -.glyphicon-road:before { - content: "\e024"; -} -.glyphicon-download-alt:before { - content: "\e025"; -} -.glyphicon-download:before { - content: "\e026"; -} -.glyphicon-upload:before { - content: "\e027"; -} -.glyphicon-inbox:before { - content: "\e028"; -} -.glyphicon-play-circle:before { - content: "\e029"; -} -.glyphicon-repeat:before { - content: "\e030"; -} -.glyphicon-refresh:before { - content: "\e031"; -} -.glyphicon-list-alt:before { - content: "\e032"; -} -.glyphicon-lock:before { - content: "\e033"; -} -.glyphicon-flag:before { - content: "\e034"; -} -.glyphicon-headphones:before { - content: "\e035"; -} -.glyphicon-volume-off:before { - content: "\e036"; -} -.glyphicon-volume-down:before { - content: "\e037"; -} -.glyphicon-volume-up:before { - content: "\e038"; -} -.glyphicon-qrcode:before { - content: "\e039"; -} -.glyphicon-barcode:before { - content: "\e040"; -} -.glyphicon-tag:before { - content: "\e041"; -} -.glyphicon-tags:before { - content: "\e042"; -} -.glyphicon-book:before { - content: "\e043"; -} -.glyphicon-bookmark:before { - content: "\e044"; -} -.glyphicon-print:before { - content: "\e045"; -} -.glyphicon-camera:before { - content: "\e046"; -} -.glyphicon-font:before { - content: "\e047"; -} -.glyphicon-bold:before { - content: "\e048"; -} -.glyphicon-italic:before { - content: "\e049"; -} -.glyphicon-text-height:before { - content: "\e050"; -} -.glyphicon-text-width:before { - content: "\e051"; -} -.glyphicon-align-left:before { - content: "\e052"; -} -.glyphicon-align-center:before { - content: "\e053"; -} -.glyphicon-align-right:before { - content: "\e054"; -} -.glyphicon-align-justify:before { - content: "\e055"; -} -.glyphicon-list:before { - content: "\e056"; -} -.glyphicon-indent-left:before { - content: "\e057"; -} -.glyphicon-indent-right:before { - content: "\e058"; -} -.glyphicon-facetime-video:before { - content: "\e059"; -} -.glyphicon-picture:before { - content: "\e060"; -} -.glyphicon-map-marker:before { - content: "\e062"; -} -.glyphicon-adjust:before { - content: "\e063"; -} -.glyphicon-tint:before { - content: "\e064"; -} -.glyphicon-edit:before { - content: "\e065"; -} -.glyphicon-share:before { - content: "\e066"; -} -.glyphicon-check:before { - content: "\e067"; -} -.glyphicon-move:before { - content: "\e068"; -} -.glyphicon-step-backward:before { - content: "\e069"; -} -.glyphicon-fast-backward:before { - content: "\e070"; -} -.glyphicon-backward:before { - content: "\e071"; -} -.glyphicon-play:before { - content: "\e072"; -} -.glyphicon-pause:before { - content: "\e073"; -} -.glyphicon-stop:before { - content: "\e074"; -} -.glyphicon-forward:before { - content: "\e075"; -} -.glyphicon-fast-forward:before { - content: "\e076"; -} -.glyphicon-step-forward:before { - content: "\e077"; -} -.glyphicon-eject:before { - content: "\e078"; -} -.glyphicon-chevron-left:before { - content: "\e079"; -} -.glyphicon-chevron-right:before { - content: "\e080"; -} -.glyphicon-plus-sign:before { - content: "\e081"; -} -.glyphicon-minus-sign:before { - content: "\e082"; -} -.glyphicon-remove-sign:before { - content: "\e083"; -} -.glyphicon-ok-sign:before { - content: "\e084"; -} -.glyphicon-question-sign:before { - content: "\e085"; -} -.glyphicon-info-sign:before { - content: "\e086"; -} -.glyphicon-screenshot:before { - content: "\e087"; -} -.glyphicon-remove-circle:before { - content: "\e088"; -} -.glyphicon-ok-circle:before { - content: "\e089"; -} -.glyphicon-ban-circle:before { - content: "\e090"; -} -.glyphicon-arrow-left:before { - content: "\e091"; -} -.glyphicon-arrow-right:before { - content: "\e092"; -} -.glyphicon-arrow-up:before { - content: "\e093"; -} -.glyphicon-arrow-down:before { - content: "\e094"; -} -.glyphicon-share-alt:before { - content: "\e095"; -} -.glyphicon-resize-full:before { - content: "\e096"; -} -.glyphicon-resize-small:before { - content: "\e097"; -} -.glyphicon-exclamation-sign:before { - content: "\e101"; -} -.glyphicon-gift:before { - content: "\e102"; -} -.glyphicon-leaf:before { - content: "\e103"; -} -.glyphicon-fire:before { - content: "\e104"; -} -.glyphicon-eye-open:before { - content: "\e105"; -} -.glyphicon-eye-close:before { - content: "\e106"; -} -.glyphicon-warning-sign:before { - content: "\e107"; -} -.glyphicon-plane:before { - content: "\e108"; -} -.glyphicon-calendar:before { - content: "\e109"; -} -.glyphicon-random:before { - content: "\e110"; -} -.glyphicon-comment:before { - content: "\e111"; -} -.glyphicon-magnet:before { - content: "\e112"; -} -.glyphicon-chevron-up:before { - content: "\e113"; -} -.glyphicon-chevron-down:before { - content: "\e114"; -} -.glyphicon-retweet:before { - content: "\e115"; -} -.glyphicon-shopping-cart:before { - content: "\e116"; -} -.glyphicon-folder-close:before { - content: "\e117"; -} -.glyphicon-folder-open:before { - content: "\e118"; -} -.glyphicon-resize-vertical:before { - content: "\e119"; -} -.glyphicon-resize-horizontal:before { - content: "\e120"; -} -.glyphicon-hdd:before { - content: "\e121"; -} -.glyphicon-bullhorn:before { - content: "\e122"; -} -.glyphicon-bell:before { - content: "\e123"; -} -.glyphicon-certificate:before { - content: "\e124"; -} -.glyphicon-thumbs-up:before { - content: "\e125"; -} -.glyphicon-thumbs-down:before { - content: "\e126"; -} -.glyphicon-hand-right:before { - content: "\e127"; -} -.glyphicon-hand-left:before { - content: "\e128"; -} -.glyphicon-hand-up:before { - content: "\e129"; -} -.glyphicon-hand-down:before { - content: "\e130"; -} -.glyphicon-circle-arrow-right:before { - content: "\e131"; -} -.glyphicon-circle-arrow-left:before { - content: "\e132"; -} -.glyphicon-circle-arrow-up:before { - content: "\e133"; -} -.glyphicon-circle-arrow-down:before { - content: "\e134"; -} -.glyphicon-globe:before { - content: "\e135"; -} -.glyphicon-wrench:before { - content: "\e136"; -} -.glyphicon-tasks:before { - content: "\e137"; -} -.glyphicon-filter:before { - content: "\e138"; -} -.glyphicon-briefcase:before { - content: "\e139"; -} -.glyphicon-fullscreen:before { - content: "\e140"; -} -.glyphicon-dashboard:before { - content: "\e141"; -} -.glyphicon-paperclip:before { - content: "\e142"; -} -.glyphicon-heart-empty:before { - content: "\e143"; -} -.glyphicon-link:before { - content: "\e144"; -} -.glyphicon-phone:before { - content: "\e145"; -} -.glyphicon-pushpin:before { - content: "\e146"; -} -.glyphicon-usd:before { - content: "\e148"; -} -.glyphicon-gbp:before { - content: "\e149"; -} -.glyphicon-sort:before { - content: "\e150"; -} -.glyphicon-sort-by-alphabet:before { - content: "\e151"; -} -.glyphicon-sort-by-alphabet-alt:before { - content: "\e152"; -} -.glyphicon-sort-by-order:before { - content: "\e153"; -} -.glyphicon-sort-by-order-alt:before { - content: "\e154"; -} -.glyphicon-sort-by-attributes:before { - content: "\e155"; -} -.glyphicon-sort-by-attributes-alt:before { - content: "\e156"; -} -.glyphicon-unchecked:before { - content: "\e157"; -} -.glyphicon-expand:before { - content: "\e158"; -} -.glyphicon-collapse-down:before { - content: "\e159"; -} -.glyphicon-collapse-up:before { - content: "\e160"; -} -.glyphicon-log-in:before { - content: "\e161"; -} -.glyphicon-flash:before { - content: "\e162"; -} -.glyphicon-log-out:before { - content: "\e163"; -} -.glyphicon-new-window:before { - content: "\e164"; -} -.glyphicon-record:before { - content: "\e165"; -} -.glyphicon-save:before { - content: "\e166"; -} -.glyphicon-open:before { - content: "\e167"; -} -.glyphicon-saved:before { - content: "\e168"; -} -.glyphicon-import:before { - content: "\e169"; -} -.glyphicon-export:before { - content: "\e170"; -} -.glyphicon-send:before { - content: "\e171"; -} -.glyphicon-floppy-disk:before { - content: "\e172"; -} -.glyphicon-floppy-saved:before { - content: "\e173"; -} -.glyphicon-floppy-remove:before { - content: "\e174"; -} -.glyphicon-floppy-save:before { - content: "\e175"; -} -.glyphicon-floppy-open:before { - content: "\e176"; -} -.glyphicon-credit-card:before { - content: "\e177"; -} -.glyphicon-transfer:before { - content: "\e178"; -} -.glyphicon-cutlery:before { - content: "\e179"; -} -.glyphicon-header:before { - content: "\e180"; -} -.glyphicon-compressed:before { - content: "\e181"; -} -.glyphicon-earphone:before { - content: "\e182"; -} -.glyphicon-phone-alt:before { - content: "\e183"; -} -.glyphicon-tower:before { - content: "\e184"; -} -.glyphicon-stats:before { - content: "\e185"; -} -.glyphicon-sd-video:before { - content: "\e186"; -} -.glyphicon-hd-video:before { - content: "\e187"; -} -.glyphicon-subtitles:before { - content: "\e188"; -} -.glyphicon-sound-stereo:before { - content: "\e189"; -} -.glyphicon-sound-dolby:before { - content: "\e190"; -} -.glyphicon-sound-5-1:before { - content: "\e191"; -} -.glyphicon-sound-6-1:before { - content: "\e192"; -} -.glyphicon-sound-7-1:before { - content: "\e193"; -} -.glyphicon-copyright-mark:before { - content: "\e194"; -} -.glyphicon-registration-mark:before { - content: "\e195"; -} -.glyphicon-cloud-download:before { - content: "\e197"; -} -.glyphicon-cloud-upload:before { - content: "\e198"; -} -.glyphicon-tree-conifer:before { - content: "\e199"; -} -.glyphicon-tree-deciduous:before { - content: "\e200"; -} -* { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -*:before, -*:after { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -html { - font-size: 10px; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} -body { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.42857143; - color: #c8c8c8; - background-color: #272b30; -} -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - line-height: inherit; -} -a { - color: #ffffff; - text-decoration: none; -} -a:hover, -a:focus { - color: #ffffff; - text-decoration: underline; -} -a:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -figure { - margin: 0; -} -img { - vertical-align: middle; -} -.img-responsive, -.thumbnail > img, -.thumbnail a > img, -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - width: 100% \9; - max-width: 100%; - height: auto; -} -.img-rounded { - border-radius: 6px; -} -.img-thumbnail { - padding: 4px; - line-height: 1.42857143; - background-color: #1c1e22; - border: 1px solid #0c0d0e; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - -o-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; - display: inline-block; - width: 100% \9; - max-width: 100%; - height: auto; -} -.img-circle { - border-radius: 50%; -} -hr { - margin-top: 20px; - margin-bottom: 20px; - border: 0; - border-top: 1px solid #1c1e22; -} -.sr-only { - position: absolute; - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; - clip: rect(0, 0, 0, 0); - border: 0; -} -.sr-only-focusable:active, -.sr-only-focusable:focus { - position: static; - width: auto; - height: auto; - margin: 0; - overflow: visible; - clip: auto; -} -h1, -h2, -h3, -h4, -h5, -h6, -.h1, -.h2, -.h3, -.h4, -.h5, -.h6 { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-weight: 500; - line-height: 1.1; - color: inherit; -} -h1 small, -h2 small, -h3 small, -h4 small, -h5 small, -h6 small, -.h1 small, -.h2 small, -.h3 small, -.h4 small, -.h5 small, -.h6 small, -h1 .small, -h2 .small, -h3 .small, -h4 .small, -h5 .small, -h6 .small, -.h1 .small, -.h2 .small, -.h3 .small, -.h4 .small, -.h5 .small, -.h6 .small { - font-weight: normal; - line-height: 1; - color: #7a8288; -} -h1, -.h1, -h2, -.h2, -h3, -.h3 { - margin-top: 20px; - margin-bottom: 10px; -} -h1 small, -.h1 small, -h2 small, -.h2 small, -h3 small, -.h3 small, -h1 .small, -.h1 .small, -h2 .small, -.h2 .small, -h3 .small, -.h3 .small { - font-size: 65%; -} -h4, -.h4, -h5, -.h5, -h6, -.h6 { - margin-top: 10px; - margin-bottom: 10px; -} -h4 small, -.h4 small, -h5 small, -.h5 small, -h6 small, -.h6 small, -h4 .small, -.h4 .small, -h5 .small, -.h5 .small, -h6 .small, -.h6 .small { - font-size: 75%; -} -h1, -.h1 { - font-size: 36px; -} -h2, -.h2 { - font-size: 30px; -} -h3, -.h3 { - font-size: 24px; -} -h4, -.h4 { - font-size: 18px; -} -h5, -.h5 { - font-size: 14px; -} -h6, -.h6 { - font-size: 12px; -} -p { - margin: 0 0 10px; -} -.lead { - margin-bottom: 20px; - font-size: 16px; - font-weight: 300; - line-height: 1.4; -} -@media (min-width: 768px) { - .lead { - font-size: 21px; - } -} -small, -.small { - font-size: 85%; -} -cite { - font-style: normal; -} -mark, -.mark { - background-color: #f89406; - padding: .2em; -} -.text-left { - text-align: left; -} -.text-right { - text-align: right; -} -.text-center { - text-align: center; -} -.text-justify { - text-align: justify; -} -.text-nowrap { - white-space: nowrap; -} -.text-lowercase { - text-transform: lowercase; -} -.text-uppercase { - text-transform: uppercase; -} -.text-capitalize { - text-transform: capitalize; -} -.text-muted { - color: #7a8288; -} -.text-primary { - color: #7a8288; -} -a.text-primary:hover { - color: #62686d; -} -.text-success { - color: #ffffff; -} -a.text-success:hover { - color: #e6e6e6; -} -.text-info { - color: #ffffff; -} -a.text-info:hover { - color: #e6e6e6; -} -.text-warning { - color: #ffffff; -} -a.text-warning:hover { - color: #e6e6e6; -} -.text-danger { - color: #ffffff; -} -a.text-danger:hover { - color: #e6e6e6; -} -.bg-primary { - color: #fff; - background-color: #7a8288; -} -a.bg-primary:hover { - background-color: #62686d; -} -.bg-success { - background-color: #62c462; -} -a.bg-success:hover { - background-color: #42b142; -} -.bg-info { - background-color: #5bc0de; -} -a.bg-info:hover { - background-color: #31b0d5; -} -.bg-warning { - background-color: #f89406; -} -a.bg-warning:hover { - background-color: #c67605; -} -.bg-danger { - background-color: #ee5f5b; -} -a.bg-danger:hover { - background-color: #e9322d; -} -.page-header { - padding-bottom: 9px; - margin: 40px 0 20px; - border-bottom: 1px solid #1c1e22; -} -ul, -ol { - margin-top: 0; - margin-bottom: 10px; -} -ul ul, -ol ul, -ul ol, -ol ol { - margin-bottom: 0; -} -.list-unstyled { - padding-left: 0; - list-style: none; -} -.list-inline { - padding-left: 0; - list-style: none; - margin-left: -5px; -} -.list-inline > li { - display: inline-block; - padding-left: 5px; - padding-right: 5px; -} -dl { - margin-top: 0; - margin-bottom: 20px; -} -dt, -dd { - line-height: 1.42857143; -} -dt { - font-weight: bold; -} -dd { - margin-left: 0; -} -@media (min-width: 768px) { - .dl-horizontal dt { - float: left; - width: 160px; - clear: left; - text-align: right; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - .dl-horizontal dd { - margin-left: 180px; - } -} -abbr[title], -abbr[data-original-title] { - cursor: help; - border-bottom: 1px dotted #7a8288; -} -.initialism { - font-size: 90%; - text-transform: uppercase; -} -blockquote { - padding: 10px 20px; - margin: 0 0 20px; - font-size: 17.5px; - border-left: 5px solid #7a8288; -} -blockquote p:last-child, -blockquote ul:last-child, -blockquote ol:last-child { - margin-bottom: 0; -} -blockquote footer, -blockquote small, -blockquote .small { - display: block; - font-size: 80%; - line-height: 1.42857143; - color: #7a8288; -} -blockquote footer:before, -blockquote small:before, -blockquote .small:before { - content: '\2014 \00A0'; -} -.blockquote-reverse, -blockquote.pull-right { - padding-right: 15px; - padding-left: 0; - border-right: 5px solid #7a8288; - border-left: 0; - text-align: right; -} -.blockquote-reverse footer:before, -blockquote.pull-right footer:before, -.blockquote-reverse small:before, -blockquote.pull-right small:before, -.blockquote-reverse .small:before, -blockquote.pull-right .small:before { - content: ''; -} -.blockquote-reverse footer:after, -blockquote.pull-right footer:after, -.blockquote-reverse small:after, -blockquote.pull-right small:after, -.blockquote-reverse .small:after, -blockquote.pull-right .small:after { - content: '\00A0 \2014'; -} -blockquote:before, -blockquote:after { - content: ""; -} -address { - margin-bottom: 20px; - font-style: normal; - line-height: 1.42857143; -} -code, -kbd, -pre, -samp { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; -} -code { - padding: 2px 4px; - font-size: 90%; - color: #c7254e; - background-color: #f9f2f4; - border-radius: 4px; -} -kbd { - padding: 2px 4px; - font-size: 90%; - color: #ffffff; - background-color: #333333; - border-radius: 3px; - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); -} -kbd kbd { - padding: 0; - font-size: 100%; - box-shadow: none; -} -pre { - display: block; - padding: 9.5px; - margin: 0 0 10px; - font-size: 13px; - line-height: 1.42857143; - word-break: break-all; - word-wrap: break-word; - color: #3a3f44; - background-color: #f5f5f5; - border: 1px solid #cccccc; - border-radius: 4px; -} -pre code { - padding: 0; - font-size: inherit; - color: inherit; - white-space: pre-wrap; - background-color: transparent; - border-radius: 0; -} -.pre-scrollable { - max-height: 340px; - overflow-y: scroll; -} -.container { - margin-right: auto; - margin-left: auto; - padding-left: 15px; - padding-right: 15px; -} -@media (min-width: 768px) { - .container { - width: 750px; - } -} -@media (min-width: 992px) { - .container { - width: 970px; - } -} -@media (min-width: 1200px) { - .container { - width: 1170px; - } -} -.container-fluid { - margin-right: auto; - margin-left: auto; - padding-left: 15px; - padding-right: 15px; -} -.row { - margin-left: -15px; - margin-right: -15px; -} -.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { - position: relative; - min-height: 1px; - padding-left: 15px; - padding-right: 15px; -} -.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { - float: left; -} -.col-xs-12 { - width: 100%; -} -.col-xs-11 { - width: 91.66666667%; -} -.col-xs-10 { - width: 83.33333333%; -} -.col-xs-9 { - width: 75%; -} -.col-xs-8 { - width: 66.66666667%; -} -.col-xs-7 { - width: 58.33333333%; -} -.col-xs-6 { - width: 50%; -} -.col-xs-5 { - width: 41.66666667%; -} -.col-xs-4 { - width: 33.33333333%; -} -.col-xs-3 { - width: 25%; -} -.col-xs-2 { - width: 16.66666667%; -} -.col-xs-1 { - width: 8.33333333%; -} -.col-xs-pull-12 { - right: 100%; -} -.col-xs-pull-11 { - right: 91.66666667%; -} -.col-xs-pull-10 { - right: 83.33333333%; -} -.col-xs-pull-9 { - right: 75%; -} -.col-xs-pull-8 { - right: 66.66666667%; -} -.col-xs-pull-7 { - right: 58.33333333%; -} -.col-xs-pull-6 { - right: 50%; -} -.col-xs-pull-5 { - right: 41.66666667%; -} -.col-xs-pull-4 { - right: 33.33333333%; -} -.col-xs-pull-3 { - right: 25%; -} -.col-xs-pull-2 { - right: 16.66666667%; -} -.col-xs-pull-1 { - right: 8.33333333%; -} -.col-xs-pull-0 { - right: auto; -} -.col-xs-push-12 { - left: 100%; -} -.col-xs-push-11 { - left: 91.66666667%; -} -.col-xs-push-10 { - left: 83.33333333%; -} -.col-xs-push-9 { - left: 75%; -} -.col-xs-push-8 { - left: 66.66666667%; -} -.col-xs-push-7 { - left: 58.33333333%; -} -.col-xs-push-6 { - left: 50%; -} -.col-xs-push-5 { - left: 41.66666667%; -} -.col-xs-push-4 { - left: 33.33333333%; -} -.col-xs-push-3 { - left: 25%; -} -.col-xs-push-2 { - left: 16.66666667%; -} -.col-xs-push-1 { - left: 8.33333333%; -} -.col-xs-push-0 { - left: auto; -} -.col-xs-offset-12 { - margin-left: 100%; -} -.col-xs-offset-11 { - margin-left: 91.66666667%; -} -.col-xs-offset-10 { - margin-left: 83.33333333%; -} -.col-xs-offset-9 { - margin-left: 75%; -} -.col-xs-offset-8 { - margin-left: 66.66666667%; -} -.col-xs-offset-7 { - margin-left: 58.33333333%; -} -.col-xs-offset-6 { - margin-left: 50%; -} -.col-xs-offset-5 { - margin-left: 41.66666667%; -} -.col-xs-offset-4 { - margin-left: 33.33333333%; -} -.col-xs-offset-3 { - margin-left: 25%; -} -.col-xs-offset-2 { - margin-left: 16.66666667%; -} -.col-xs-offset-1 { - margin-left: 8.33333333%; -} -.col-xs-offset-0 { - margin-left: 0%; -} -@media (min-width: 768px) { - .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { - float: left; - } - .col-sm-12 { - width: 100%; - } - .col-sm-11 { - width: 91.66666667%; - } - .col-sm-10 { - width: 83.33333333%; - } - .col-sm-9 { - width: 75%; - } - .col-sm-8 { - width: 66.66666667%; - } - .col-sm-7 { - width: 58.33333333%; - } - .col-sm-6 { - width: 50%; - } - .col-sm-5 { - width: 41.66666667%; - } - .col-sm-4 { - width: 33.33333333%; - } - .col-sm-3 { - width: 25%; - } - .col-sm-2 { - width: 16.66666667%; - } - .col-sm-1 { - width: 8.33333333%; - } - .col-sm-pull-12 { - right: 100%; - } - .col-sm-pull-11 { - right: 91.66666667%; - } - .col-sm-pull-10 { - right: 83.33333333%; - } - .col-sm-pull-9 { - right: 75%; - } - .col-sm-pull-8 { - right: 66.66666667%; - } - .col-sm-pull-7 { - right: 58.33333333%; - } - .col-sm-pull-6 { - right: 50%; - } - .col-sm-pull-5 { - right: 41.66666667%; - } - .col-sm-pull-4 { - right: 33.33333333%; - } - .col-sm-pull-3 { - right: 25%; - } - .col-sm-pull-2 { - right: 16.66666667%; - } - .col-sm-pull-1 { - right: 8.33333333%; - } - .col-sm-pull-0 { - right: auto; - } - .col-sm-push-12 { - left: 100%; - } - .col-sm-push-11 { - left: 91.66666667%; - } - .col-sm-push-10 { - left: 83.33333333%; - } - .col-sm-push-9 { - left: 75%; - } - .col-sm-push-8 { - left: 66.66666667%; - } - .col-sm-push-7 { - left: 58.33333333%; - } - .col-sm-push-6 { - left: 50%; - } - .col-sm-push-5 { - left: 41.66666667%; - } - .col-sm-push-4 { - left: 33.33333333%; - } - .col-sm-push-3 { - left: 25%; - } - .col-sm-push-2 { - left: 16.66666667%; - } - .col-sm-push-1 { - left: 8.33333333%; - } - .col-sm-push-0 { - left: auto; - } - .col-sm-offset-12 { - margin-left: 100%; - } - .col-sm-offset-11 { - margin-left: 91.66666667%; - } - .col-sm-offset-10 { - margin-left: 83.33333333%; - } - .col-sm-offset-9 { - margin-left: 75%; - } - .col-sm-offset-8 { - margin-left: 66.66666667%; - } - .col-sm-offset-7 { - margin-left: 58.33333333%; - } - .col-sm-offset-6 { - margin-left: 50%; - } - .col-sm-offset-5 { - margin-left: 41.66666667%; - } - .col-sm-offset-4 { - margin-left: 33.33333333%; - } - .col-sm-offset-3 { - margin-left: 25%; - } - .col-sm-offset-2 { - margin-left: 16.66666667%; - } - .col-sm-offset-1 { - margin-left: 8.33333333%; - } - .col-sm-offset-0 { - margin-left: 0%; - } -} -@media (min-width: 992px) { - .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { - float: left; - } - .col-md-12 { - width: 100%; - } - .col-md-11 { - width: 91.66666667%; - } - .col-md-10 { - width: 83.33333333%; - } - .col-md-9 { - width: 75%; - } - .col-md-8 { - width: 66.66666667%; - } - .col-md-7 { - width: 58.33333333%; - } - .col-md-6 { - width: 50%; - } - .col-md-5 { - width: 41.66666667%; - } - .col-md-4 { - width: 33.33333333%; - } - .col-md-3 { - width: 25%; - } - .col-md-2 { - width: 16.66666667%; - } - .col-md-1 { - width: 8.33333333%; - } - .col-md-pull-12 { - right: 100%; - } - .col-md-pull-11 { - right: 91.66666667%; - } - .col-md-pull-10 { - right: 83.33333333%; - } - .col-md-pull-9 { - right: 75%; - } - .col-md-pull-8 { - right: 66.66666667%; - } - .col-md-pull-7 { - right: 58.33333333%; - } - .col-md-pull-6 { - right: 50%; - } - .col-md-pull-5 { - right: 41.66666667%; - } - .col-md-pull-4 { - right: 33.33333333%; - } - .col-md-pull-3 { - right: 25%; - } - .col-md-pull-2 { - right: 16.66666667%; - } - .col-md-pull-1 { - right: 8.33333333%; - } - .col-md-pull-0 { - right: auto; - } - .col-md-push-12 { - left: 100%; - } - .col-md-push-11 { - left: 91.66666667%; - } - .col-md-push-10 { - left: 83.33333333%; - } - .col-md-push-9 { - left: 75%; - } - .col-md-push-8 { - left: 66.66666667%; - } - .col-md-push-7 { - left: 58.33333333%; - } - .col-md-push-6 { - left: 50%; - } - .col-md-push-5 { - left: 41.66666667%; - } - .col-md-push-4 { - left: 33.33333333%; - } - .col-md-push-3 { - left: 25%; - } - .col-md-push-2 { - left: 16.66666667%; - } - .col-md-push-1 { - left: 8.33333333%; - } - .col-md-push-0 { - left: auto; - } - .col-md-offset-12 { - margin-left: 100%; - } - .col-md-offset-11 { - margin-left: 91.66666667%; - } - .col-md-offset-10 { - margin-left: 83.33333333%; - } - .col-md-offset-9 { - margin-left: 75%; - } - .col-md-offset-8 { - margin-left: 66.66666667%; - } - .col-md-offset-7 { - margin-left: 58.33333333%; - } - .col-md-offset-6 { - margin-left: 50%; - } - .col-md-offset-5 { - margin-left: 41.66666667%; - } - .col-md-offset-4 { - margin-left: 33.33333333%; - } - .col-md-offset-3 { - margin-left: 25%; - } - .col-md-offset-2 { - margin-left: 16.66666667%; - } - .col-md-offset-1 { - margin-left: 8.33333333%; - } - .col-md-offset-0 { - margin-left: 0%; - } -} -@media (min-width: 1200px) { - .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { - float: left; - } - .col-lg-12 { - width: 100%; - } - .col-lg-11 { - width: 91.66666667%; - } - .col-lg-10 { - width: 83.33333333%; - } - .col-lg-9 { - width: 75%; - } - .col-lg-8 { - width: 66.66666667%; - } - .col-lg-7 { - width: 58.33333333%; - } - .col-lg-6 { - width: 50%; - } - .col-lg-5 { - width: 41.66666667%; - } - .col-lg-4 { - width: 33.33333333%; - } - .col-lg-3 { - width: 25%; - } - .col-lg-2 { - width: 16.66666667%; - } - .col-lg-1 { - width: 8.33333333%; - } - .col-lg-pull-12 { - right: 100%; - } - .col-lg-pull-11 { - right: 91.66666667%; - } - .col-lg-pull-10 { - right: 83.33333333%; - } - .col-lg-pull-9 { - right: 75%; - } - .col-lg-pull-8 { - right: 66.66666667%; - } - .col-lg-pull-7 { - right: 58.33333333%; - } - .col-lg-pull-6 { - right: 50%; - } - .col-lg-pull-5 { - right: 41.66666667%; - } - .col-lg-pull-4 { - right: 33.33333333%; - } - .col-lg-pull-3 { - right: 25%; - } - .col-lg-pull-2 { - right: 16.66666667%; - } - .col-lg-pull-1 { - right: 8.33333333%; - } - .col-lg-pull-0 { - right: auto; - } - .col-lg-push-12 { - left: 100%; - } - .col-lg-push-11 { - left: 91.66666667%; - } - .col-lg-push-10 { - left: 83.33333333%; - } - .col-lg-push-9 { - left: 75%; - } - .col-lg-push-8 { - left: 66.66666667%; - } - .col-lg-push-7 { - left: 58.33333333%; - } - .col-lg-push-6 { - left: 50%; - } - .col-lg-push-5 { - left: 41.66666667%; - } - .col-lg-push-4 { - left: 33.33333333%; - } - .col-lg-push-3 { - left: 25%; - } - .col-lg-push-2 { - left: 16.66666667%; - } - .col-lg-push-1 { - left: 8.33333333%; - } - .col-lg-push-0 { - left: auto; - } - .col-lg-offset-12 { - margin-left: 100%; - } - .col-lg-offset-11 { - margin-left: 91.66666667%; - } - .col-lg-offset-10 { - margin-left: 83.33333333%; - } - .col-lg-offset-9 { - margin-left: 75%; - } - .col-lg-offset-8 { - margin-left: 66.66666667%; - } - .col-lg-offset-7 { - margin-left: 58.33333333%; - } - .col-lg-offset-6 { - margin-left: 50%; - } - .col-lg-offset-5 { - margin-left: 41.66666667%; - } - .col-lg-offset-4 { - margin-left: 33.33333333%; - } - .col-lg-offset-3 { - margin-left: 25%; - } - .col-lg-offset-2 { - margin-left: 16.66666667%; - } - .col-lg-offset-1 { - margin-left: 8.33333333%; - } - .col-lg-offset-0 { - margin-left: 0%; - } -} -table { - background-color: #2e3338; -} -th { - text-align: left; -} -.table { - width: 100%; - max-width: 100%; - margin-bottom: 20px; -} -.table > thead > tr > th, -.table > tbody > tr > th, -.table > tfoot > tr > th, -.table > thead > tr > td, -.table > tbody > tr > td, -.table > tfoot > tr > td { - padding: 8px; - line-height: 1.42857143; - vertical-align: top; - border-top: 1px solid #1c1e22; -} -.table > thead > tr > th { - vertical-align: bottom; - border-bottom: 2px solid #1c1e22; -} -.table > caption + thead > tr:first-child > th, -.table > colgroup + thead > tr:first-child > th, -.table > thead:first-child > tr:first-child > th, -.table > caption + thead > tr:first-child > td, -.table > colgroup + thead > tr:first-child > td, -.table > thead:first-child > tr:first-child > td { - border-top: 0; -} -.table > tbody + tbody { - border-top: 2px solid #1c1e22; -} -.table .table { - background-color: #272b30; -} -.table-condensed > thead > tr > th, -.table-condensed > tbody > tr > th, -.table-condensed > tfoot > tr > th, -.table-condensed > thead > tr > td, -.table-condensed > tbody > tr > td, -.table-condensed > tfoot > tr > td { - padding: 5px; -} -.table-bordered { - border: 1px solid #1c1e22; -} -.table-bordered > thead > tr > th, -.table-bordered > tbody > tr > th, -.table-bordered > tfoot > tr > th, -.table-bordered > thead > tr > td, -.table-bordered > tbody > tr > td, -.table-bordered > tfoot > tr > td { - border: 1px solid #1c1e22; -} -.table-bordered > thead > tr > th, -.table-bordered > thead > tr > td { - border-bottom-width: 2px; -} -.table-striped > tbody > tr:nth-child(odd) > td, -.table-striped > tbody > tr:nth-child(odd) > th { - background-color: #353a41; -} -.table-hover > tbody > tr:hover > td, -.table-hover > tbody > tr:hover > th { - background-color: #49515a; -} -table col[class*="col-"] { - position: static; - float: none; - display: table-column; -} -table td[class*="col-"], -table th[class*="col-"] { - position: static; - float: none; - display: table-cell; -} -.table > thead > tr > td.active, -.table > tbody > tr > td.active, -.table > tfoot > tr > td.active, -.table > thead > tr > th.active, -.table > tbody > tr > th.active, -.table > tfoot > tr > th.active, -.table > thead > tr.active > td, -.table > tbody > tr.active > td, -.table > tfoot > tr.active > td, -.table > thead > tr.active > th, -.table > tbody > tr.active > th, -.table > tfoot > tr.active > th { - background-color: #49515a; -} -.table-hover > tbody > tr > td.active:hover, -.table-hover > tbody > tr > th.active:hover, -.table-hover > tbody > tr.active:hover > td, -.table-hover > tbody > tr:hover > .active, -.table-hover > tbody > tr.active:hover > th { - background-color: #3e444c; -} -.table > thead > tr > td.success, -.table > tbody > tr > td.success, -.table > tfoot > tr > td.success, -.table > thead > tr > th.success, -.table > tbody > tr > th.success, -.table > tfoot > tr > th.success, -.table > thead > tr.success > td, -.table > tbody > tr.success > td, -.table > tfoot > tr.success > td, -.table > thead > tr.success > th, -.table > tbody > tr.success > th, -.table > tfoot > tr.success > th { - background-color: #62c462; -} -.table-hover > tbody > tr > td.success:hover, -.table-hover > tbody > tr > th.success:hover, -.table-hover > tbody > tr.success:hover > td, -.table-hover > tbody > tr:hover > .success, -.table-hover > tbody > tr.success:hover > th { - background-color: #4fbd4f; -} -.table > thead > tr > td.info, -.table > tbody > tr > td.info, -.table > tfoot > tr > td.info, -.table > thead > tr > th.info, -.table > tbody > tr > th.info, -.table > tfoot > tr > th.info, -.table > thead > tr.info > td, -.table > tbody > tr.info > td, -.table > tfoot > tr.info > td, -.table > thead > tr.info > th, -.table > tbody > tr.info > th, -.table > tfoot > tr.info > th { - background-color: #5bc0de; -} -.table-hover > tbody > tr > td.info:hover, -.table-hover > tbody > tr > th.info:hover, -.table-hover > tbody > tr.info:hover > td, -.table-hover > tbody > tr:hover > .info, -.table-hover > tbody > tr.info:hover > th { - background-color: #46b8da; -} -.table > thead > tr > td.warning, -.table > tbody > tr > td.warning, -.table > tfoot > tr > td.warning, -.table > thead > tr > th.warning, -.table > tbody > tr > th.warning, -.table > tfoot > tr > th.warning, -.table > thead > tr.warning > td, -.table > tbody > tr.warning > td, -.table > tfoot > tr.warning > td, -.table > thead > tr.warning > th, -.table > tbody > tr.warning > th, -.table > tfoot > tr.warning > th { - background-color: #f89406; -} -.table-hover > tbody > tr > td.warning:hover, -.table-hover > tbody > tr > th.warning:hover, -.table-hover > tbody > tr.warning:hover > td, -.table-hover > tbody > tr:hover > .warning, -.table-hover > tbody > tr.warning:hover > th { - background-color: #df8505; -} -.table > thead > tr > td.danger, -.table > tbody > tr > td.danger, -.table > tfoot > tr > td.danger, -.table > thead > tr > th.danger, -.table > tbody > tr > th.danger, -.table > tfoot > tr > th.danger, -.table > thead > tr.danger > td, -.table > tbody > tr.danger > td, -.table > tfoot > tr.danger > td, -.table > thead > tr.danger > th, -.table > tbody > tr.danger > th, -.table > tfoot > tr.danger > th { - background-color: #ee5f5b; -} -.table-hover > tbody > tr > td.danger:hover, -.table-hover > tbody > tr > th.danger:hover, -.table-hover > tbody > tr.danger:hover > td, -.table-hover > tbody > tr:hover > .danger, -.table-hover > tbody > tr.danger:hover > th { - background-color: #ec4844; -} -@media screen and (max-width: 767px) { - .table-responsive { - width: 100%; - margin-bottom: 15px; - overflow-y: hidden; - overflow-x: auto; - -ms-overflow-style: -ms-autohiding-scrollbar; - border: 1px solid #1c1e22; - -webkit-overflow-scrolling: touch; - } - .table-responsive > .table { - margin-bottom: 0; - } - .table-responsive > .table > thead > tr > th, - .table-responsive > .table > tbody > tr > th, - .table-responsive > .table > tfoot > tr > th, - .table-responsive > .table > thead > tr > td, - .table-responsive > .table > tbody > tr > td, - .table-responsive > .table > tfoot > tr > td { - white-space: nowrap; - } - .table-responsive > .table-bordered { - border: 0; - } - .table-responsive > .table-bordered > thead > tr > th:first-child, - .table-responsive > .table-bordered > tbody > tr > th:first-child, - .table-responsive > .table-bordered > tfoot > tr > th:first-child, - .table-responsive > .table-bordered > thead > tr > td:first-child, - .table-responsive > .table-bordered > tbody > tr > td:first-child, - .table-responsive > .table-bordered > tfoot > tr > td:first-child { - border-left: 0; - } - .table-responsive > .table-bordered > thead > tr > th:last-child, - .table-responsive > .table-bordered > tbody > tr > th:last-child, - .table-responsive > .table-bordered > tfoot > tr > th:last-child, - .table-responsive > .table-bordered > thead > tr > td:last-child, - .table-responsive > .table-bordered > tbody > tr > td:last-child, - .table-responsive > .table-bordered > tfoot > tr > td:last-child { - border-right: 0; - } - .table-responsive > .table-bordered > tbody > tr:last-child > th, - .table-responsive > .table-bordered > tfoot > tr:last-child > th, - .table-responsive > .table-bordered > tbody > tr:last-child > td, - .table-responsive > .table-bordered > tfoot > tr:last-child > td { - border-bottom: 0; - } -} -fieldset { - padding: 0; - margin: 0; - border: 0; - min-width: 0; -} -legend { - display: block; - width: 100%; - padding: 0; - margin-bottom: 20px; - font-size: 21px; - line-height: inherit; - color: #c8c8c8; - border: 0; - border-bottom: 1px solid #1c1e22; -} -label { - display: inline-block; - max-width: 100%; - margin-bottom: 5px; - font-weight: bold; -} -input[type="search"] { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -input[type="radio"], -input[type="checkbox"] { - margin: 4px 0 0; - margin-top: 1px \9; - line-height: normal; -} -input[type="file"] { - display: block; -} -input[type="range"] { - display: block; - width: 100%; -} -select[multiple], -select[size] { - height: auto; -} -input[type="file"]:focus, -input[type="radio"]:focus, -input[type="checkbox"]:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -output { - display: block; - padding-top: 9px; - font-size: 14px; - line-height: 1.42857143; - color: #272b30; -} -.form-control { - display: block; - width: 100%; - height: 38px; - padding: 8px 12px; - font-size: 14px; - line-height: 1.42857143; - color: #272b30; - background-color: #ffffff; - background-image: none; - border: 1px solid #cccccc; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; -} -.form-control:focus { - border-color: #66afe9; - outline: 0; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); - box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); -} -.form-control::-moz-placeholder { - color: #7a8288; - opacity: 1; -} -.form-control:-ms-input-placeholder { - color: #7a8288; -} -.form-control::-webkit-input-placeholder { - color: #7a8288; -} -.form-control[disabled], -.form-control[readonly], -fieldset[disabled] .form-control { - cursor: not-allowed; - background-color: #999999; - opacity: 1; -} -textarea.form-control { - height: auto; -} -input[type="search"] { - -webkit-appearance: none; -} -input[type="date"], -input[type="time"], -input[type="datetime-local"], -input[type="month"] { - line-height: 38px; - line-height: 1.42857143 \0; -} -input[type="date"].input-sm, -input[type="time"].input-sm, -input[type="datetime-local"].input-sm, -input[type="month"].input-sm { - line-height: 30px; -} -input[type="date"].input-lg, -input[type="time"].input-lg, -input[type="datetime-local"].input-lg, -input[type="month"].input-lg { - line-height: 54px; -} -.form-group { - margin-bottom: 15px; -} -.radio, -.checkbox { - position: relative; - display: block; - min-height: 20px; - margin-top: 10px; - margin-bottom: 10px; -} -.radio label, -.checkbox label { - padding-left: 20px; - margin-bottom: 0; - font-weight: normal; - cursor: pointer; -} -.radio input[type="radio"], -.radio-inline input[type="radio"], -.checkbox input[type="checkbox"], -.checkbox-inline input[type="checkbox"] { - position: absolute; - margin-left: -20px; - margin-top: 4px \9; -} -.radio + .radio, -.checkbox + .checkbox { - margin-top: -5px; -} -.radio-inline, -.checkbox-inline { - display: inline-block; - padding-left: 20px; - margin-bottom: 0; - vertical-align: middle; - font-weight: normal; - cursor: pointer; -} -.radio-inline + .radio-inline, -.checkbox-inline + .checkbox-inline { - margin-top: 0; - margin-left: 10px; -} -input[type="radio"][disabled], -input[type="checkbox"][disabled], -input[type="radio"].disabled, -input[type="checkbox"].disabled, -fieldset[disabled] input[type="radio"], -fieldset[disabled] input[type="checkbox"] { - cursor: not-allowed; -} -.radio-inline.disabled, -.checkbox-inline.disabled, -fieldset[disabled] .radio-inline, -fieldset[disabled] .checkbox-inline { - cursor: not-allowed; -} -.radio.disabled label, -.checkbox.disabled label, -fieldset[disabled] .radio label, -fieldset[disabled] .checkbox label { - cursor: not-allowed; -} -.form-control-static { - padding-top: 9px; - padding-bottom: 9px; - margin-bottom: 0; -} -.form-control-static.input-lg, -.form-control-static.input-sm { - padding-left: 0; - padding-right: 0; -} -.input-sm, -.form-horizontal .form-group-sm .form-control { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-sm { - height: 30px; - line-height: 30px; -} -textarea.input-sm, -select[multiple].input-sm { - height: auto; -} -.input-lg, -.form-horizontal .form-group-lg .form-control { - height: 54px; - padding: 14px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} -select.input-lg { - height: 54px; - line-height: 54px; -} -textarea.input-lg, -select[multiple].input-lg { - height: auto; -} -.has-feedback { - position: relative; -} -.has-feedback .form-control { - padding-right: 47.5px; -} -.form-control-feedback { - position: absolute; - top: 25px; - right: 0; - z-index: 2; - display: block; - width: 38px; - height: 38px; - line-height: 38px; - text-align: center; -} -.input-lg + .form-control-feedback { - width: 54px; - height: 54px; - line-height: 54px; -} -.input-sm + .form-control-feedback { - width: 30px; - height: 30px; - line-height: 30px; -} -.has-success .help-block, -.has-success .control-label, -.has-success .radio, -.has-success .checkbox, -.has-success .radio-inline, -.has-success .checkbox-inline { - color: #ffffff; -} -.has-success .form-control { - border-color: #ffffff; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-success .form-control:focus { - border-color: #e6e6e6; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-success .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #62c462; -} -.has-success .form-control-feedback { - color: #ffffff; -} -.has-warning .help-block, -.has-warning .control-label, -.has-warning .radio, -.has-warning .checkbox, -.has-warning .radio-inline, -.has-warning .checkbox-inline { - color: #ffffff; -} -.has-warning .form-control { - border-color: #ffffff; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-warning .form-control:focus { - border-color: #e6e6e6; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-warning .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #f89406; -} -.has-warning .form-control-feedback { - color: #ffffff; -} -.has-error .help-block, -.has-error .control-label, -.has-error .radio, -.has-error .checkbox, -.has-error .radio-inline, -.has-error .checkbox-inline { - color: #ffffff; -} -.has-error .form-control { - border-color: #ffffff; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-error .form-control:focus { - border-color: #e6e6e6; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-error .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #ee5f5b; -} -.has-error .form-control-feedback { - color: #ffffff; -} -.has-feedback label.sr-only ~ .form-control-feedback { - top: 0; -} -.help-block { - display: block; - margin-top: 5px; - margin-bottom: 10px; - color: #ffffff; -} -@media (min-width: 768px) { - .form-inline .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .form-control { - display: inline-block; - width: auto; - vertical-align: middle; - } - .form-inline .input-group { - display: inline-table; - vertical-align: middle; - } - .form-inline .input-group .input-group-addon, - .form-inline .input-group .input-group-btn, - .form-inline .input-group .form-control { - width: auto; - } - .form-inline .input-group > .form-control { - width: 100%; - } - .form-inline .control-label { - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio, - .form-inline .checkbox { - display: inline-block; - margin-top: 0; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio label, - .form-inline .checkbox label { - padding-left: 0; - } - .form-inline .radio input[type="radio"], - .form-inline .checkbox input[type="checkbox"] { - position: relative; - margin-left: 0; - } - .form-inline .has-feedback .form-control-feedback { - top: 0; - } -} -.form-horizontal .radio, -.form-horizontal .checkbox, -.form-horizontal .radio-inline, -.form-horizontal .checkbox-inline { - margin-top: 0; - margin-bottom: 0; - padding-top: 9px; -} -.form-horizontal .radio, -.form-horizontal .checkbox { - min-height: 29px; -} -.form-horizontal .form-group { - margin-left: -15px; - margin-right: -15px; -} -@media (min-width: 768px) { - .form-horizontal .control-label { - text-align: right; - margin-bottom: 0; - padding-top: 9px; - } -} -.form-horizontal .has-feedback .form-control-feedback { - top: 0; - right: 15px; -} -@media (min-width: 768px) { - .form-horizontal .form-group-lg .control-label { - padding-top: 19.62px; - } -} -@media (min-width: 768px) { - .form-horizontal .form-group-sm .control-label { - padding-top: 6px; - } -} -.btn { - display: inline-block; - margin-bottom: 0; - font-weight: normal; - text-align: center; - vertical-align: middle; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - white-space: nowrap; - padding: 8px 12px; - font-size: 14px; - line-height: 1.42857143; - border-radius: 4px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.btn:focus, -.btn:active:focus, -.btn.active:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -.btn:hover, -.btn:focus { - color: #ffffff; - text-decoration: none; -} -.btn:active, -.btn.active { - outline: 0; - background-image: none; - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -.btn.disabled, -.btn[disabled], -fieldset[disabled] .btn { - cursor: not-allowed; - pointer-events: none; - opacity: 0.65; - filter: alpha(opacity=65); - -webkit-box-shadow: none; - box-shadow: none; -} -.btn-default { - color: #ffffff; - background-color: #3a3f44; - border-color: #3a3f44; -} -.btn-default:hover, -.btn-default:focus, -.btn-default:active, -.btn-default.active, -.open > .dropdown-toggle.btn-default { - color: #ffffff; - background-color: #232628; - border-color: #1e2023; -} -.btn-default:active, -.btn-default.active, -.open > .dropdown-toggle.btn-default { - background-image: none; -} -.btn-default.disabled, -.btn-default[disabled], -fieldset[disabled] .btn-default, -.btn-default.disabled:hover, -.btn-default[disabled]:hover, -fieldset[disabled] .btn-default:hover, -.btn-default.disabled:focus, -.btn-default[disabled]:focus, -fieldset[disabled] .btn-default:focus, -.btn-default.disabled:active, -.btn-default[disabled]:active, -fieldset[disabled] .btn-default:active, -.btn-default.disabled.active, -.btn-default[disabled].active, -fieldset[disabled] .btn-default.active { - background-color: #3a3f44; - border-color: #3a3f44; -} -.btn-default .badge { - color: #3a3f44; - background-color: #ffffff; -} -.btn-primary { - color: #ffffff; - background-color: #7a8288; - border-color: #7a8288; -} -.btn-primary:hover, -.btn-primary:focus, -.btn-primary:active, -.btn-primary.active, -.open > .dropdown-toggle.btn-primary { - color: #ffffff; - background-color: #62686d; - border-color: #5d6368; -} -.btn-primary:active, -.btn-primary.active, -.open > .dropdown-toggle.btn-primary { - background-image: none; -} -.btn-primary.disabled, -.btn-primary[disabled], -fieldset[disabled] .btn-primary, -.btn-primary.disabled:hover, -.btn-primary[disabled]:hover, -fieldset[disabled] .btn-primary:hover, -.btn-primary.disabled:focus, -.btn-primary[disabled]:focus, -fieldset[disabled] .btn-primary:focus, -.btn-primary.disabled:active, -.btn-primary[disabled]:active, -fieldset[disabled] .btn-primary:active, -.btn-primary.disabled.active, -.btn-primary[disabled].active, -fieldset[disabled] .btn-primary.active { - background-color: #7a8288; - border-color: #7a8288; -} -.btn-primary .badge { - color: #7a8288; - background-color: #ffffff; -} -.btn-success { - color: #ffffff; - background-color: #62c462; - border-color: #62c462; -} -.btn-success:hover, -.btn-success:focus, -.btn-success:active, -.btn-success.active, -.open > .dropdown-toggle.btn-success { - color: #ffffff; - background-color: #42b142; - border-color: #40a940; -} -.btn-success:active, -.btn-success.active, -.open > .dropdown-toggle.btn-success { - background-image: none; -} -.btn-success.disabled, -.btn-success[disabled], -fieldset[disabled] .btn-success, -.btn-success.disabled:hover, -.btn-success[disabled]:hover, -fieldset[disabled] .btn-success:hover, -.btn-success.disabled:focus, -.btn-success[disabled]:focus, -fieldset[disabled] .btn-success:focus, -.btn-success.disabled:active, -.btn-success[disabled]:active, -fieldset[disabled] .btn-success:active, -.btn-success.disabled.active, -.btn-success[disabled].active, -fieldset[disabled] .btn-success.active { - background-color: #62c462; - border-color: #62c462; -} -.btn-success .badge { - color: #62c462; - background-color: #ffffff; -} -.btn-info { - color: #ffffff; - background-color: #5bc0de; - border-color: #5bc0de; -} -.btn-info:hover, -.btn-info:focus, -.btn-info:active, -.btn-info.active, -.open > .dropdown-toggle.btn-info { - color: #ffffff; - background-color: #31b0d5; - border-color: #2aabd2; -} -.btn-info:active, -.btn-info.active, -.open > .dropdown-toggle.btn-info { - background-image: none; -} -.btn-info.disabled, -.btn-info[disabled], -fieldset[disabled] .btn-info, -.btn-info.disabled:hover, -.btn-info[disabled]:hover, -fieldset[disabled] .btn-info:hover, -.btn-info.disabled:focus, -.btn-info[disabled]:focus, -fieldset[disabled] .btn-info:focus, -.btn-info.disabled:active, -.btn-info[disabled]:active, -fieldset[disabled] .btn-info:active, -.btn-info.disabled.active, -.btn-info[disabled].active, -fieldset[disabled] .btn-info.active { - background-color: #5bc0de; - border-color: #5bc0de; -} -.btn-info .badge { - color: #5bc0de; - background-color: #ffffff; -} -.btn-warning { - color: #ffffff; - background-color: #f89406; - border-color: #f89406; -} -.btn-warning:hover, -.btn-warning:focus, -.btn-warning:active, -.btn-warning.active, -.open > .dropdown-toggle.btn-warning { - color: #ffffff; - background-color: #c67605; - border-color: #bc7005; -} -.btn-warning:active, -.btn-warning.active, -.open > .dropdown-toggle.btn-warning { - background-image: none; -} -.btn-warning.disabled, -.btn-warning[disabled], -fieldset[disabled] .btn-warning, -.btn-warning.disabled:hover, -.btn-warning[disabled]:hover, -fieldset[disabled] .btn-warning:hover, -.btn-warning.disabled:focus, -.btn-warning[disabled]:focus, -fieldset[disabled] .btn-warning:focus, -.btn-warning.disabled:active, -.btn-warning[disabled]:active, -fieldset[disabled] .btn-warning:active, -.btn-warning.disabled.active, -.btn-warning[disabled].active, -fieldset[disabled] .btn-warning.active { - background-color: #f89406; - border-color: #f89406; -} -.btn-warning .badge { - color: #f89406; - background-color: #ffffff; -} -.btn-danger { - color: #ffffff; - background-color: #ee5f5b; - border-color: #ee5f5b; -} -.btn-danger:hover, -.btn-danger:focus, -.btn-danger:active, -.btn-danger.active, -.open > .dropdown-toggle.btn-danger { - color: #ffffff; - background-color: #e9322d; - border-color: #e82924; -} -.btn-danger:active, -.btn-danger.active, -.open > .dropdown-toggle.btn-danger { - background-image: none; -} -.btn-danger.disabled, -.btn-danger[disabled], -fieldset[disabled] .btn-danger, -.btn-danger.disabled:hover, -.btn-danger[disabled]:hover, -fieldset[disabled] .btn-danger:hover, -.btn-danger.disabled:focus, -.btn-danger[disabled]:focus, -fieldset[disabled] .btn-danger:focus, -.btn-danger.disabled:active, -.btn-danger[disabled]:active, -fieldset[disabled] .btn-danger:active, -.btn-danger.disabled.active, -.btn-danger[disabled].active, -fieldset[disabled] .btn-danger.active { - background-color: #ee5f5b; - border-color: #ee5f5b; -} -.btn-danger .badge { - color: #ee5f5b; - background-color: #ffffff; -} -.btn-link { - color: #ffffff; - font-weight: normal; - cursor: pointer; - border-radius: 0; -} -.btn-link, -.btn-link:active, -.btn-link[disabled], -fieldset[disabled] .btn-link { - background-color: transparent; - -webkit-box-shadow: none; - box-shadow: none; -} -.btn-link, -.btn-link:hover, -.btn-link:focus, -.btn-link:active { - border-color: transparent; -} -.btn-link:hover, -.btn-link:focus { - color: #ffffff; - text-decoration: underline; - background-color: transparent; -} -.btn-link[disabled]:hover, -fieldset[disabled] .btn-link:hover, -.btn-link[disabled]:focus, -fieldset[disabled] .btn-link:focus { - color: #7a8288; - text-decoration: none; -} -.btn-lg, -.btn-group-lg > .btn { - padding: 14px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} -.btn-sm, -.btn-group-sm > .btn { - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-xs, -.btn-group-xs > .btn { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-block { - display: block; - width: 100%; -} -.btn-block + .btn-block { - margin-top: 5px; -} -input[type="submit"].btn-block, -input[type="reset"].btn-block, -input[type="button"].btn-block { - width: 100%; -} -.fade { - opacity: 0; - -webkit-transition: opacity 0.15s linear; - -o-transition: opacity 0.15s linear; - transition: opacity 0.15s linear; -} -.fade.in { - opacity: 1; -} -.collapse { - display: none; -} -.collapse.in { - display: block; -} -tr.collapse.in { - display: table-row; -} -tbody.collapse.in { - display: table-row-group; -} -.collapsing { - position: relative; - height: 0; - overflow: hidden; - -webkit-transition: height 0.35s ease; - -o-transition: height 0.35s ease; - transition: height 0.35s ease; -} -.caret { - display: inline-block; - width: 0; - height: 0; - margin-left: 2px; - vertical-align: middle; - border-top: 4px solid; - border-right: 4px solid transparent; - border-left: 4px solid transparent; -} -.dropdown { - position: relative; -} -.dropdown-toggle:focus { - outline: 0; -} -.dropdown-menu { - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 0 0; - list-style: none; - font-size: 14px; - text-align: left; - background-color: #3a3f44; - border: 1px solid #272b30; - border: 1px solid rgba(0, 0, 0, 0.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - background-clip: padding-box; -} -.dropdown-menu.pull-right { - right: 0; - left: auto; -} -.dropdown-menu .divider { - height: 1px; - margin: 9px 0; - overflow: hidden; - background-color: #272b30; -} -.dropdown-menu > li > a { - display: block; - padding: 3px 20px; - clear: both; - font-weight: normal; - line-height: 1.42857143; - color: #c8c8c8; - white-space: nowrap; -} -.dropdown-menu > li > a:hover, -.dropdown-menu > li > a:focus { - text-decoration: none; - color: #ffffff; - background-color: #272b30; -} -.dropdown-menu > .active > a, -.dropdown-menu > .active > a:hover, -.dropdown-menu > .active > a:focus { - color: #ffffff; - text-decoration: none; - outline: 0; - background-color: #272b30; -} -.dropdown-menu > .disabled > a, -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - color: #7a8288; -} -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - text-decoration: none; - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); - cursor: not-allowed; -} -.open > .dropdown-menu { - display: block; -} -.open > a { - outline: 0; -} -.dropdown-menu-right { - left: auto; - right: 0; -} -.dropdown-menu-left { - left: 0; - right: auto; -} -.dropdown-header { - display: block; - padding: 3px 20px; - font-size: 12px; - line-height: 1.42857143; - color: #7a8288; - white-space: nowrap; -} -.dropdown-backdrop { - position: fixed; - left: 0; - right: 0; - bottom: 0; - top: 0; - z-index: 990; -} -.pull-right > .dropdown-menu { - right: 0; - left: auto; -} -.dropup .caret, -.navbar-fixed-bottom .dropdown .caret { - border-top: 0; - border-bottom: 4px solid; - content: ""; -} -.dropup .dropdown-menu, -.navbar-fixed-bottom .dropdown .dropdown-menu { - top: auto; - bottom: 100%; - margin-bottom: 1px; -} -@media (min-width: 768px) { - .navbar-right .dropdown-menu { - left: auto; - right: 0; - } - .navbar-right .dropdown-menu-left { - left: 0; - right: auto; - } -} -.btn-group, -.btn-group-vertical { - position: relative; - display: inline-block; - vertical-align: middle; -} -.btn-group > .btn, -.btn-group-vertical > .btn { - position: relative; - float: left; -} -.btn-group > .btn:hover, -.btn-group-vertical > .btn:hover, -.btn-group > .btn:focus, -.btn-group-vertical > .btn:focus, -.btn-group > .btn:active, -.btn-group-vertical > .btn:active, -.btn-group > .btn.active, -.btn-group-vertical > .btn.active { - z-index: 2; -} -.btn-group > .btn:focus, -.btn-group-vertical > .btn:focus { - outline: 0; -} -.btn-group .btn + .btn, -.btn-group .btn + .btn-group, -.btn-group .btn-group + .btn, -.btn-group .btn-group + .btn-group { - margin-left: -1px; -} -.btn-toolbar { - margin-left: -5px; -} -.btn-toolbar .btn-group, -.btn-toolbar .input-group { - float: left; -} -.btn-toolbar > .btn, -.btn-toolbar > .btn-group, -.btn-toolbar > .input-group { - margin-left: 5px; -} -.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { - border-radius: 0; -} -.btn-group > .btn:first-child { - margin-left: 0; -} -.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.btn-group > .btn:last-child:not(:first-child), -.btn-group > .dropdown-toggle:not(:first-child) { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.btn-group > .btn-group { - float: left; -} -.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} -.btn-group > .btn-group:first-child > .btn:last-child, -.btn-group > .btn-group:first-child > .dropdown-toggle { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.btn-group > .btn-group:last-child > .btn:first-child { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.btn-group .dropdown-toggle:active, -.btn-group.open .dropdown-toggle { - outline: 0; -} -.btn-group > .btn + .dropdown-toggle { - padding-left: 8px; - padding-right: 8px; -} -.btn-group > .btn-lg + .dropdown-toggle { - padding-left: 12px; - padding-right: 12px; -} -.btn-group.open .dropdown-toggle { - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -.btn-group.open .dropdown-toggle.btn-link { - -webkit-box-shadow: none; - box-shadow: none; -} -.btn .caret { - margin-left: 0; -} -.btn-lg .caret { - border-width: 5px 5px 0; - border-bottom-width: 0; -} -.dropup .btn-lg .caret { - border-width: 0 5px 5px; -} -.btn-group-vertical > .btn, -.btn-group-vertical > .btn-group, -.btn-group-vertical > .btn-group > .btn { - display: block; - float: none; - width: 100%; - max-width: 100%; -} -.btn-group-vertical > .btn-group > .btn { - float: none; -} -.btn-group-vertical > .btn + .btn, -.btn-group-vertical > .btn + .btn-group, -.btn-group-vertical > .btn-group + .btn, -.btn-group-vertical > .btn-group + .btn-group { - margin-top: -1px; - margin-left: 0; -} -.btn-group-vertical > .btn:not(:first-child):not(:last-child) { - border-radius: 0; -} -.btn-group-vertical > .btn:first-child:not(:last-child) { - border-top-right-radius: 4px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.btn-group-vertical > .btn:last-child:not(:first-child) { - border-bottom-left-radius: 4px; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child { - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.btn-group-justified { - display: table; - width: 100%; - table-layout: fixed; - border-collapse: separate; -} -.btn-group-justified > .btn, -.btn-group-justified > .btn-group { - float: none; - display: table-cell; - width: 1%; -} -.btn-group-justified > .btn-group .btn { - width: 100%; -} -.btn-group-justified > .btn-group .dropdown-menu { - left: auto; -} -[data-toggle="buttons"] > .btn > input[type="radio"], -[data-toggle="buttons"] > .btn > input[type="checkbox"] { - position: absolute; - z-index: -1; - opacity: 0; - filter: alpha(opacity=0); -} -.input-group { - position: relative; - display: table; - border-collapse: separate; -} -.input-group[class*="col-"] { - float: none; - padding-left: 0; - padding-right: 0; -} -.input-group .form-control { - position: relative; - z-index: 2; - float: left; - width: 100%; - margin-bottom: 0; -} -.input-group-lg > .form-control, -.input-group-lg > .input-group-addon, -.input-group-lg > .input-group-btn > .btn { - height: 54px; - padding: 14px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} -select.input-group-lg > .form-control, -select.input-group-lg > .input-group-addon, -select.input-group-lg > .input-group-btn > .btn { - height: 54px; - line-height: 54px; -} -textarea.input-group-lg > .form-control, -textarea.input-group-lg > .input-group-addon, -textarea.input-group-lg > .input-group-btn > .btn, -select[multiple].input-group-lg > .form-control, -select[multiple].input-group-lg > .input-group-addon, -select[multiple].input-group-lg > .input-group-btn > .btn { - height: auto; -} -.input-group-sm > .form-control, -.input-group-sm > .input-group-addon, -.input-group-sm > .input-group-btn > .btn { - height: 30px; - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-group-sm > .form-control, -select.input-group-sm > .input-group-addon, -select.input-group-sm > .input-group-btn > .btn { - height: 30px; - line-height: 30px; -} -textarea.input-group-sm > .form-control, -textarea.input-group-sm > .input-group-addon, -textarea.input-group-sm > .input-group-btn > .btn, -select[multiple].input-group-sm > .form-control, -select[multiple].input-group-sm > .input-group-addon, -select[multiple].input-group-sm > .input-group-btn > .btn { - height: auto; -} -.input-group-addon, -.input-group-btn, -.input-group .form-control { - display: table-cell; -} -.input-group-addon:not(:first-child):not(:last-child), -.input-group-btn:not(:first-child):not(:last-child), -.input-group .form-control:not(:first-child):not(:last-child) { - border-radius: 0; -} -.input-group-addon, -.input-group-btn { - width: 1%; - white-space: nowrap; - vertical-align: middle; -} -.input-group-addon { - padding: 8px 12px; - font-size: 14px; - font-weight: normal; - line-height: 1; - color: #272b30; - text-align: center; - background-color: #999999; - border: 1px solid #cccccc; - border-radius: 4px; -} -.input-group-addon.input-sm { - padding: 5px 10px; - font-size: 12px; - border-radius: 3px; -} -.input-group-addon.input-lg { - padding: 14px 16px; - font-size: 18px; - border-radius: 6px; -} -.input-group-addon input[type="radio"], -.input-group-addon input[type="checkbox"] { - margin-top: 0; -} -.input-group .form-control:first-child, -.input-group-addon:first-child, -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group > .btn, -.input-group-btn:first-child > .dropdown-toggle, -.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), -.input-group-btn:last-child > .btn-group:not(:last-child) > .btn { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.input-group-addon:first-child { - border-right: 0; -} -.input-group .form-control:last-child, -.input-group-addon:last-child, -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group > .btn, -.input-group-btn:last-child > .dropdown-toggle, -.input-group-btn:first-child > .btn:not(:first-child), -.input-group-btn:first-child > .btn-group:not(:first-child) > .btn { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.input-group-addon:last-child { - border-left: 0; -} -.input-group-btn { - position: relative; - font-size: 0; - white-space: nowrap; -} -.input-group-btn > .btn { - position: relative; -} -.input-group-btn > .btn + .btn { - margin-left: -1px; -} -.input-group-btn > .btn:hover, -.input-group-btn > .btn:focus, -.input-group-btn > .btn:active { - z-index: 2; -} -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group { - margin-right: -1px; -} -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group { - margin-left: -1px; -} -.nav { - margin-bottom: 0; - padding-left: 0; - list-style: none; -} -.nav > li { - position: relative; - display: block; -} -.nav > li > a { - position: relative; - display: block; - padding: 10px 15px; -} -.nav > li > a:hover, -.nav > li > a:focus { - text-decoration: none; - background-color: #3e444c; -} -.nav > li.disabled > a { - color: #7a8288; -} -.nav > li.disabled > a:hover, -.nav > li.disabled > a:focus { - color: #7a8288; - text-decoration: none; - background-color: transparent; - cursor: not-allowed; -} -.nav .open > a, -.nav .open > a:hover, -.nav .open > a:focus { - background-color: #3e444c; - border-color: #ffffff; -} -.nav .nav-divider { - height: 1px; - margin: 9px 0; - overflow: hidden; - background-color: #e5e5e5; -} -.nav > li > a > img { - max-width: none; -} -.nav-tabs { - border-bottom: 1px solid #1c1e22; -} -.nav-tabs > li { - float: left; - margin-bottom: -1px; -} -.nav-tabs > li > a { - margin-right: 2px; - line-height: 1.42857143; - border: 1px solid transparent; - border-radius: 4px 4px 0 0; -} -.nav-tabs > li > a:hover { - border-color: #1c1e22 #1c1e22 #1c1e22; -} -.nav-tabs > li.active > a, -.nav-tabs > li.active > a:hover, -.nav-tabs > li.active > a:focus { - color: #ffffff; - background-color: #3e444c; - border: 1px solid #1c1e22; - border-bottom-color: transparent; - cursor: default; -} -.nav-tabs.nav-justified { - width: 100%; - border-bottom: 0; -} -.nav-tabs.nav-justified > li { - float: none; -} -.nav-tabs.nav-justified > li > a { - text-align: center; - margin-bottom: 5px; -} -.nav-tabs.nav-justified > .dropdown .dropdown-menu { - top: auto; - left: auto; -} -@media (min-width: 768px) { - .nav-tabs.nav-justified > li { - display: table-cell; - width: 1%; - } - .nav-tabs.nav-justified > li > a { - margin-bottom: 0; - } -} -.nav-tabs.nav-justified > li > a { - margin-right: 0; - border-radius: 4px; -} -.nav-tabs.nav-justified > .active > a, -.nav-tabs.nav-justified > .active > a:hover, -.nav-tabs.nav-justified > .active > a:focus { - border: 1px solid #1c1e22; -} -@media (min-width: 768px) { - .nav-tabs.nav-justified > li > a { - border-bottom: 1px solid #1c1e22; - border-radius: 4px 4px 0 0; - } - .nav-tabs.nav-justified > .active > a, - .nav-tabs.nav-justified > .active > a:hover, - .nav-tabs.nav-justified > .active > a:focus { - border-bottom-color: #272b30; - } -} -.nav-pills > li { - float: left; -} -.nav-pills > li > a { - border-radius: 4px; -} -.nav-pills > li + li { - margin-left: 2px; -} -.nav-pills > li.active > a, -.nav-pills > li.active > a:hover, -.nav-pills > li.active > a:focus { - color: #ffffff; - background-color: transparent; -} -.nav-stacked > li { - float: none; -} -.nav-stacked > li + li { - margin-top: 2px; - margin-left: 0; -} -.nav-justified { - width: 100%; -} -.nav-justified > li { - float: none; -} -.nav-justified > li > a { - text-align: center; - margin-bottom: 5px; -} -.nav-justified > .dropdown .dropdown-menu { - top: auto; - left: auto; -} -@media (min-width: 768px) { - .nav-justified > li { - display: table-cell; - width: 1%; - } - .nav-justified > li > a { - margin-bottom: 0; - } -} -.nav-tabs-justified { - border-bottom: 0; -} -.nav-tabs-justified > li > a { - margin-right: 0; - border-radius: 4px; -} -.nav-tabs-justified > .active > a, -.nav-tabs-justified > .active > a:hover, -.nav-tabs-justified > .active > a:focus { - border: 1px solid #1c1e22; -} -@media (min-width: 768px) { - .nav-tabs-justified > li > a { - border-bottom: 1px solid #1c1e22; - border-radius: 4px 4px 0 0; - } - .nav-tabs-justified > .active > a, - .nav-tabs-justified > .active > a:hover, - .nav-tabs-justified > .active > a:focus { - border-bottom-color: #272b30; - } -} -.tab-content > .tab-pane { - display: none; -} -.tab-content > .active { - display: block; -} -.nav-tabs .dropdown-menu { - margin-top: -1px; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.navbar { - position: relative; - min-height: 50px; - margin-bottom: 20px; - border: 1px solid transparent; -} -@media (min-width: 768px) { - .navbar { - border-radius: 4px; - } -} -@media (min-width: 768px) { - .navbar-header { - float: left; - } -} -.navbar-collapse { - overflow-x: visible; - padding-right: 15px; - padding-left: 15px; - border-top: 1px solid transparent; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); - -webkit-overflow-scrolling: touch; -} -.navbar-collapse.in { - overflow-y: auto; -} -@media (min-width: 768px) { - .navbar-collapse { - width: auto; - border-top: 0; - box-shadow: none; - } - .navbar-collapse.collapse { - display: block !important; - height: auto !important; - padding-bottom: 0; - overflow: visible !important; - } - .navbar-collapse.in { - overflow-y: visible; - } - .navbar-fixed-top .navbar-collapse, - .navbar-static-top .navbar-collapse, - .navbar-fixed-bottom .navbar-collapse { - padding-left: 0; - padding-right: 0; - } -} -.navbar-fixed-top .navbar-collapse, -.navbar-fixed-bottom .navbar-collapse { - max-height: 340px; -} -@media (max-width: 480px) and (orientation: landscape) { - .navbar-fixed-top .navbar-collapse, - .navbar-fixed-bottom .navbar-collapse { - max-height: 200px; - } -} -.container > .navbar-header, -.container-fluid > .navbar-header, -.container > .navbar-collapse, -.container-fluid > .navbar-collapse { - margin-right: -15px; - margin-left: -15px; -} -@media (min-width: 768px) { - .container > .navbar-header, - .container-fluid > .navbar-header, - .container > .navbar-collapse, - .container-fluid > .navbar-collapse { - margin-right: 0; - margin-left: 0; - } -} -.navbar-static-top { - z-index: 1000; - border-width: 0 0 1px; -} -@media (min-width: 768px) { - .navbar-static-top { - border-radius: 0; - } -} -.navbar-fixed-top, -.navbar-fixed-bottom { - position: fixed; - right: 0; - left: 0; - z-index: 1030; - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); -} -@media (min-width: 768px) { - .navbar-fixed-top, - .navbar-fixed-bottom { - border-radius: 0; - } -} -.navbar-fixed-top { - top: 0; - border-width: 0 0 1px; -} -.navbar-fixed-bottom { - bottom: 0; - margin-bottom: 0; - border-width: 1px 0 0; -} -.navbar-brand { - float: left; - padding: 15px 15px; - font-size: 18px; - line-height: 20px; - height: 50px; -} -.navbar-brand:hover, -.navbar-brand:focus { - text-decoration: none; -} -@media (min-width: 768px) { - .navbar > .container .navbar-brand, - .navbar > .container-fluid .navbar-brand { - margin-left: -15px; - } -} -.navbar-toggle { - position: relative; - float: right; - margin-right: 15px; - padding: 9px 10px; - margin-top: 8px; - margin-bottom: 8px; - background-color: transparent; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; -} -.navbar-toggle:focus { - outline: 0; -} -.navbar-toggle .icon-bar { - display: block; - width: 22px; - height: 2px; - border-radius: 1px; -} -.navbar-toggle .icon-bar + .icon-bar { - margin-top: 4px; -} -@media (min-width: 768px) { - .navbar-toggle { - display: none; - } -} -.navbar-nav { - margin: 7.5px -15px; -} -.navbar-nav > li > a { - padding-top: 10px; - padding-bottom: 10px; - line-height: 20px; -} -@media (max-width: 767px) { - .navbar-nav .open .dropdown-menu { - position: static; - float: none; - width: auto; - margin-top: 0; - background-color: transparent; - border: 0; - box-shadow: none; - } - .navbar-nav .open .dropdown-menu > li > a, - .navbar-nav .open .dropdown-menu .dropdown-header { - padding: 5px 15px 5px 25px; - } - .navbar-nav .open .dropdown-menu > li > a { - line-height: 20px; - } - .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-nav .open .dropdown-menu > li > a:focus { - background-image: none; - } -} -@media (min-width: 768px) { - .navbar-nav { - float: left; - margin: 0; - } - .navbar-nav > li { - float: left; - } - .navbar-nav > li > a { - padding-top: 15px; - padding-bottom: 15px; - } - .navbar-nav.navbar-right:last-child { - margin-right: -15px; - } -} -@media (min-width: 768px) { - .navbar-left { - float: left !important; - } - .navbar-right { - float: right !important; - } -} -.navbar-form { - margin-left: -15px; - margin-right: -15px; - padding: 10px 15px; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); - margin-top: 6px; - margin-bottom: 6px; -} -@media (min-width: 768px) { - .navbar-form .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .form-control { - display: inline-block; - width: auto; - vertical-align: middle; - } - .navbar-form .input-group { - display: inline-table; - vertical-align: middle; - } - .navbar-form .input-group .input-group-addon, - .navbar-form .input-group .input-group-btn, - .navbar-form .input-group .form-control { - width: auto; - } - .navbar-form .input-group > .form-control { - width: 100%; - } - .navbar-form .control-label { - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .radio, - .navbar-form .checkbox { - display: inline-block; - margin-top: 0; - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .radio label, - .navbar-form .checkbox label { - padding-left: 0; - } - .navbar-form .radio input[type="radio"], - .navbar-form .checkbox input[type="checkbox"] { - position: relative; - margin-left: 0; - } - .navbar-form .has-feedback .form-control-feedback { - top: 0; - } -} -@media (max-width: 767px) { - .navbar-form .form-group { - margin-bottom: 5px; - } -} -@media (min-width: 768px) { - .navbar-form { - width: auto; - border: 0; - margin-left: 0; - margin-right: 0; - padding-top: 0; - padding-bottom: 0; - -webkit-box-shadow: none; - box-shadow: none; - } - .navbar-form.navbar-right:last-child { - margin-right: -15px; - } -} -.navbar-nav > li > .dropdown-menu { - margin-top: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.navbar-btn { - margin-top: 6px; - margin-bottom: 6px; -} -.navbar-btn.btn-sm { - margin-top: 10px; - margin-bottom: 10px; -} -.navbar-btn.btn-xs { - margin-top: 14px; - margin-bottom: 14px; -} -.navbar-text { - margin-top: 15px; - margin-bottom: 15px; -} -@media (min-width: 768px) { - .navbar-text { - float: left; - margin-left: 15px; - margin-right: 15px; - } - .navbar-text.navbar-right:last-child { - margin-right: 0; - } -} -.navbar-default { - background-color: #3a3f44; - border-color: #2b2e32; -} -.navbar-default .navbar-brand { - color: #c8c8c8; -} -.navbar-default .navbar-brand:hover, -.navbar-default .navbar-brand:focus { - color: #ffffff; - background-color: none; -} -.navbar-default .navbar-text { - color: #c8c8c8; -} -.navbar-default .navbar-nav > li > a { - color: #c8c8c8; -} -.navbar-default .navbar-nav > li > a:hover, -.navbar-default .navbar-nav > li > a:focus { - color: #ffffff; - background-color: #272b2e; -} -.navbar-default .navbar-nav > .active > a, -.navbar-default .navbar-nav > .active > a:hover, -.navbar-default .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #272b2e; -} -.navbar-default .navbar-nav > .disabled > a, -.navbar-default .navbar-nav > .disabled > a:hover, -.navbar-default .navbar-nav > .disabled > a:focus { - color: #cccccc; - background-color: transparent; -} -.navbar-default .navbar-toggle { - border-color: #272b2e; -} -.navbar-default .navbar-toggle:hover, -.navbar-default .navbar-toggle:focus { - background-color: #272b2e; -} -.navbar-default .navbar-toggle .icon-bar { - background-color: #c8c8c8; -} -.navbar-default .navbar-collapse, -.navbar-default .navbar-form { - border-color: #2b2e32; -} -.navbar-default .navbar-nav > .open > a, -.navbar-default .navbar-nav > .open > a:hover, -.navbar-default .navbar-nav > .open > a:focus { - background-color: #272b2e; - color: #ffffff; -} -@media (max-width: 767px) { - .navbar-default .navbar-nav .open .dropdown-menu > li > a { - color: #c8c8c8; - } - .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: #272b2e; - } - .navbar-default .navbar-nav .open .dropdown-menu > .active > a, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #272b2e; - } - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #cccccc; - background-color: transparent; - } -} -.navbar-default .navbar-link { - color: #c8c8c8; -} -.navbar-default .navbar-link:hover { - color: #ffffff; -} -.navbar-default .btn-link { - color: #c8c8c8; -} -.navbar-default .btn-link:hover, -.navbar-default .btn-link:focus { - color: #ffffff; -} -.navbar-default .btn-link[disabled]:hover, -fieldset[disabled] .navbar-default .btn-link:hover, -.navbar-default .btn-link[disabled]:focus, -fieldset[disabled] .navbar-default .btn-link:focus { - color: #cccccc; -} -.navbar-inverse { - background-color: #7a8288; - border-color: #62686d; -} -.navbar-inverse .navbar-brand { - color: #cccccc; -} -.navbar-inverse .navbar-brand:hover, -.navbar-inverse .navbar-brand:focus { - color: #ffffff; - background-color: none; -} -.navbar-inverse .navbar-text { - color: #cccccc; -} -.navbar-inverse .navbar-nav > li > a { - color: #cccccc; -} -.navbar-inverse .navbar-nav > li > a:hover, -.navbar-inverse .navbar-nav > li > a:focus { - color: #ffffff; - background-color: #5d6368; -} -.navbar-inverse .navbar-nav > .active > a, -.navbar-inverse .navbar-nav > .active > a:hover, -.navbar-inverse .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #5d6368; -} -.navbar-inverse .navbar-nav > .disabled > a, -.navbar-inverse .navbar-nav > .disabled > a:hover, -.navbar-inverse .navbar-nav > .disabled > a:focus { - color: #cccccc; - background-color: transparent; -} -.navbar-inverse .navbar-toggle { - border-color: #5d6368; -} -.navbar-inverse .navbar-toggle:hover, -.navbar-inverse .navbar-toggle:focus { - background-color: #5d6368; -} -.navbar-inverse .navbar-toggle .icon-bar { - background-color: #ffffff; -} -.navbar-inverse .navbar-collapse, -.navbar-inverse .navbar-form { - border-color: #697075; -} -.navbar-inverse .navbar-nav > .open > a, -.navbar-inverse .navbar-nav > .open > a:hover, -.navbar-inverse .navbar-nav > .open > a:focus { - background-color: #5d6368; - color: #ffffff; -} -@media (max-width: 767px) { - .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header { - border-color: #62686d; - } - .navbar-inverse .navbar-nav .open .dropdown-menu .divider { - background-color: #62686d; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { - color: #cccccc; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: #5d6368; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #5d6368; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #cccccc; - background-color: transparent; - } -} -.navbar-inverse .navbar-link { - color: #cccccc; -} -.navbar-inverse .navbar-link:hover { - color: #ffffff; -} -.navbar-inverse .btn-link { - color: #cccccc; -} -.navbar-inverse .btn-link:hover, -.navbar-inverse .btn-link:focus { - color: #ffffff; -} -.navbar-inverse .btn-link[disabled]:hover, -fieldset[disabled] .navbar-inverse .btn-link:hover, -.navbar-inverse .btn-link[disabled]:focus, -fieldset[disabled] .navbar-inverse .btn-link:focus { - color: #cccccc; -} -.breadcrumb { - padding: 8px 15px; - margin-bottom: 20px; - list-style: none; - background-color: transparent; - border-radius: 4px; -} -.breadcrumb > li { - display: inline-block; -} -.breadcrumb > li + li:before { - content: "/\00a0"; - padding: 0 5px; - color: #cccccc; -} -.breadcrumb > .active { - color: #7a8288; -} -.pagination { - display: inline-block; - padding-left: 0; - margin: 20px 0; - border-radius: 4px; -} -.pagination > li { - display: inline; -} -.pagination > li > a, -.pagination > li > span { - position: relative; - float: left; - padding: 8px 12px; - line-height: 1.42857143; - text-decoration: none; - color: #ffffff; - background-color: #3a3f44; - border: 1px solid rgba(0, 0, 0, 0.6); - margin-left: -1px; -} -.pagination > li:first-child > a, -.pagination > li:first-child > span { - margin-left: 0; - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} -.pagination > li:last-child > a, -.pagination > li:last-child > span { - border-bottom-right-radius: 4px; - border-top-right-radius: 4px; -} -.pagination > li > a:hover, -.pagination > li > span:hover, -.pagination > li > a:focus, -.pagination > li > span:focus { - color: #ffffff; - background-color: transparent; - border-color: rgba(0, 0, 0, 0.6); -} -.pagination > .active > a, -.pagination > .active > span, -.pagination > .active > a:hover, -.pagination > .active > span:hover, -.pagination > .active > a:focus, -.pagination > .active > span:focus { - z-index: 2; - color: #ffffff; - background-color: #232628; - border-color: rgba(0, 0, 0, 0.6); - cursor: default; -} -.pagination > .disabled > span, -.pagination > .disabled > span:hover, -.pagination > .disabled > span:focus, -.pagination > .disabled > a, -.pagination > .disabled > a:hover, -.pagination > .disabled > a:focus { - color: #7a8288; - background-color: #ffffff; - border-color: rgba(0, 0, 0, 0.6); - cursor: not-allowed; -} -.pagination-lg > li > a, -.pagination-lg > li > span { - padding: 14px 16px; - font-size: 18px; -} -.pagination-lg > li:first-child > a, -.pagination-lg > li:first-child > span { - border-bottom-left-radius: 6px; - border-top-left-radius: 6px; -} -.pagination-lg > li:last-child > a, -.pagination-lg > li:last-child > span { - border-bottom-right-radius: 6px; - border-top-right-radius: 6px; -} -.pagination-sm > li > a, -.pagination-sm > li > span { - padding: 5px 10px; - font-size: 12px; -} -.pagination-sm > li:first-child > a, -.pagination-sm > li:first-child > span { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} -.pagination-sm > li:last-child > a, -.pagination-sm > li:last-child > span { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} -.pager { - padding-left: 0; - margin: 20px 0; - list-style: none; - text-align: center; -} -.pager li { - display: inline; -} -.pager li > a, -.pager li > span { - display: inline-block; - padding: 5px 14px; - background-color: #3a3f44; - border: 1px solid rgba(0, 0, 0, 0.6); - border-radius: 15px; -} -.pager li > a:hover, -.pager li > a:focus { - text-decoration: none; - background-color: transparent; -} -.pager .next > a, -.pager .next > span { - float: right; -} -.pager .previous > a, -.pager .previous > span { - float: left; -} -.pager .disabled > a, -.pager .disabled > a:hover, -.pager .disabled > a:focus, -.pager .disabled > span { - color: #7a8288; - background-color: #3a3f44; - cursor: not-allowed; -} -.label { - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: bold; - line-height: 1; - color: #ffffff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; -} -a.label:hover, -a.label:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} -.label:empty { - display: none; -} -.btn .label { - position: relative; - top: -1px; -} -.label-default { - background-color: #3a3f44; -} -.label-default[href]:hover, -.label-default[href]:focus { - background-color: #232628; -} -.label-primary { - background-color: #7a8288; -} -.label-primary[href]:hover, -.label-primary[href]:focus { - background-color: #62686d; -} -.label-success { - background-color: #62c462; -} -.label-success[href]:hover, -.label-success[href]:focus { - background-color: #42b142; -} -.label-info { - background-color: #5bc0de; -} -.label-info[href]:hover, -.label-info[href]:focus { - background-color: #31b0d5; -} -.label-warning { - background-color: #f89406; -} -.label-warning[href]:hover, -.label-warning[href]:focus { - background-color: #c67605; -} -.label-danger { - background-color: #ee5f5b; -} -.label-danger[href]:hover, -.label-danger[href]:focus { - background-color: #e9322d; -} -.badge { - display: inline-block; - min-width: 10px; - padding: 3px 7px; - font-size: 12px; - font-weight: bold; - color: #ffffff; - line-height: 1; - vertical-align: baseline; - white-space: nowrap; - text-align: center; - background-color: #7a8288; - border-radius: 10px; -} -.badge:empty { - display: none; -} -.btn .badge { - position: relative; - top: -1px; -} -.btn-xs .badge { - top: 0; - padding: 1px 5px; -} -a.badge:hover, -a.badge:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} -a.list-group-item.active > .badge, -.nav-pills > .active > a > .badge { - color: #ffffff; - background-color: #7a8288; -} -.nav-pills > li > a > .badge { - margin-left: 3px; -} -.jumbotron { - padding: 30px; - margin-bottom: 30px; - color: inherit; - background-color: #1c1e22; -} -.jumbotron h1, -.jumbotron .h1 { - color: inherit; -} -.jumbotron p { - margin-bottom: 15px; - font-size: 21px; - font-weight: 200; -} -.jumbotron > hr { - border-top-color: #050506; -} -.container .jumbotron { - border-radius: 6px; -} -.jumbotron .container { - max-width: 100%; -} -@media screen and (min-width: 768px) { - .jumbotron { - padding-top: 48px; - padding-bottom: 48px; - } - .container .jumbotron { - padding-left: 60px; - padding-right: 60px; - } - .jumbotron h1, - .jumbotron .h1 { - font-size: 63px; - } -} -.thumbnail { - display: block; - padding: 4px; - margin-bottom: 20px; - line-height: 1.42857143; - background-color: #1c1e22; - border: 1px solid #0c0d0e; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - -o-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; -} -.thumbnail > img, -.thumbnail a > img { - margin-left: auto; - margin-right: auto; -} -a.thumbnail:hover, -a.thumbnail:focus, -a.thumbnail.active { - border-color: #ffffff; -} -.thumbnail .caption { - padding: 9px; - color: #c8c8c8; -} -.alert { - padding: 15px; - margin-bottom: 20px; - border: 1px solid transparent; - border-radius: 4px; -} -.alert h4 { - margin-top: 0; - color: inherit; -} -.alert .alert-link { - font-weight: bold; -} -.alert > p, -.alert > ul { - margin-bottom: 0; -} -.alert > p + p { - margin-top: 5px; -} -.alert-dismissable, -.alert-dismissible { - padding-right: 35px; -} -.alert-dismissable .close, -.alert-dismissible .close { - position: relative; - top: -2px; - right: -21px; - color: inherit; -} -.alert-success { - background-color: #62c462; - border-color: #62bd4f; - color: #ffffff; -} -.alert-success hr { - border-top-color: #55b142; -} -.alert-success .alert-link { - color: #e6e6e6; -} -.alert-info { - background-color: #5bc0de; - border-color: #3dced8; - color: #20485c; -} -.alert-info hr { - border-top-color: #2ac7d2; -} -.alert-info .alert-link { - color: #e6e6e6; -} -.alert-warning { - background-color: #f89406; - border-color: #e96506; - color: #ffffff; -} -.alert-warning hr { - border-top-color: #d05a05; -} -.alert-warning .alert-link { - color: #e6e6e6; -} -.alert-danger { - background-color: #ee5f5b; - border-color: #ed4d63; - color: #ffffff; -} -.alert-danger hr { - border-top-color: #ea364f; -} -.alert-danger .alert-link { - color: #e6e6e6; -} -@-webkit-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -@keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -.progress { - overflow: hidden; - height: 20px; - margin-bottom: 20px; - background-color: #1c1e22; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -} -.progress-bar { - float: left; - width: 0%; - height: 100%; - font-size: 12px; - line-height: 20px; - color: #ffffff; - text-align: center; - background-color: #7a8288; - -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-transition: width 0.6s ease; - -o-transition: width 0.6s ease; - transition: width 0.6s ease; -} -.progress-striped .progress-bar, -.progress-bar-striped { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-size: 40px 40px; -} -.progress.active .progress-bar, -.progress-bar.active { - -webkit-animation: progress-bar-stripes 2s linear infinite; - -o-animation: progress-bar-stripes 2s linear infinite; - animation: progress-bar-stripes 2s linear infinite; -} -.progress-bar[aria-valuenow="1"], -.progress-bar[aria-valuenow="2"] { - min-width: 30px; -} -.progress-bar[aria-valuenow="0"] { - color: #7a8288; - min-width: 30px; - background-color: transparent; - background-image: none; - box-shadow: none; -} -.progress-bar-success { - background-color: #62c462; -} -.progress-striped .progress-bar-success { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-info { - background-color: #5bc0de; -} -.progress-striped .progress-bar-info { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-warning { - background-color: #f89406; -} -.progress-striped .progress-bar-warning { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-danger { - background-color: #ee5f5b; -} -.progress-striped .progress-bar-danger { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.media, -.media-body { - overflow: hidden; - zoom: 1; -} -.media, -.media .media { - margin-top: 15px; -} -.media:first-child { - margin-top: 0; -} -.media-object { - display: block; -} -.media-heading { - margin: 0 0 5px; -} -.media > .pull-left { - margin-right: 10px; -} -.media > .pull-right { - margin-left: 10px; -} -.media-list { - padding-left: 0; - list-style: none; -} -.list-group { - margin-bottom: 20px; - padding-left: 0; -} -.list-group-item { - position: relative; - display: block; - padding: 10px 15px; - margin-bottom: -1px; - background-color: #32383e; - border: 1px solid rgba(0, 0, 0, 0.6); -} -.list-group-item:first-child { - border-top-right-radius: 4px; - border-top-left-radius: 4px; -} -.list-group-item:last-child { - margin-bottom: 0; - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; -} -.list-group-item > .badge { - float: right; -} -.list-group-item > .badge + .badge { - margin-right: 5px; -} -a.list-group-item { - color: #c8c8c8; -} -a.list-group-item .list-group-item-heading { - color: #ffffff; -} -a.list-group-item:hover, -a.list-group-item:focus { - text-decoration: none; - color: #c8c8c8; - background-color: #3e444c; -} -.list-group-item.disabled, -.list-group-item.disabled:hover, -.list-group-item.disabled:focus { - background-color: #999999; - color: #7a8288; -} -.list-group-item.disabled .list-group-item-heading, -.list-group-item.disabled:hover .list-group-item-heading, -.list-group-item.disabled:focus .list-group-item-heading { - color: inherit; -} -.list-group-item.disabled .list-group-item-text, -.list-group-item.disabled:hover .list-group-item-text, -.list-group-item.disabled:focus .list-group-item-text { - color: #7a8288; -} -.list-group-item.active, -.list-group-item.active:hover, -.list-group-item.active:focus { - z-index: 2; - color: #ffffff; - background-color: #3e444c; - border-color: rgba(0, 0, 0, 0.6); -} -.list-group-item.active .list-group-item-heading, -.list-group-item.active:hover .list-group-item-heading, -.list-group-item.active:focus .list-group-item-heading, -.list-group-item.active .list-group-item-heading > small, -.list-group-item.active:hover .list-group-item-heading > small, -.list-group-item.active:focus .list-group-item-heading > small, -.list-group-item.active .list-group-item-heading > .small, -.list-group-item.active:hover .list-group-item-heading > .small, -.list-group-item.active:focus .list-group-item-heading > .small { - color: inherit; -} -.list-group-item.active .list-group-item-text, -.list-group-item.active:hover .list-group-item-text, -.list-group-item.active:focus .list-group-item-text { - color: #a2aab4; -} -.list-group-item-success { - color: #ffffff; - background-color: #62c462; -} -a.list-group-item-success { - color: #ffffff; -} -a.list-group-item-success .list-group-item-heading { - color: inherit; -} -a.list-group-item-success:hover, -a.list-group-item-success:focus { - color: #ffffff; - background-color: #4fbd4f; -} -a.list-group-item-success.active, -a.list-group-item-success.active:hover, -a.list-group-item-success.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-info { - color: #ffffff; - background-color: #5bc0de; -} -a.list-group-item-info { - color: #ffffff; -} -a.list-group-item-info .list-group-item-heading { - color: inherit; -} -a.list-group-item-info:hover, -a.list-group-item-info:focus { - color: #ffffff; - background-color: #46b8da; -} -a.list-group-item-info.active, -a.list-group-item-info.active:hover, -a.list-group-item-info.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-warning { - color: #ffffff; - background-color: #f89406; -} -a.list-group-item-warning { - color: #ffffff; -} -a.list-group-item-warning .list-group-item-heading { - color: inherit; -} -a.list-group-item-warning:hover, -a.list-group-item-warning:focus { - color: #ffffff; - background-color: #df8505; -} -a.list-group-item-warning.active, -a.list-group-item-warning.active:hover, -a.list-group-item-warning.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-danger { - color: #ffffff; - background-color: #ee5f5b; -} -a.list-group-item-danger { - color: #ffffff; -} -a.list-group-item-danger .list-group-item-heading { - color: inherit; -} -a.list-group-item-danger:hover, -a.list-group-item-danger:focus { - color: #ffffff; - background-color: #ec4844; -} -a.list-group-item-danger.active, -a.list-group-item-danger.active:hover, -a.list-group-item-danger.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-heading { - margin-top: 0; - margin-bottom: 5px; -} -.list-group-item-text { - margin-bottom: 0; - line-height: 1.3; -} -.panel { - margin-bottom: 20px; - background-color: #2e3338; - border: 1px solid transparent; - border-radius: 4px; - -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); -} -.panel-body { - padding: 15px; -} -.panel-heading { - padding: 10px 15px; - border-bottom: 1px solid transparent; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel-heading > .dropdown .dropdown-toggle { - color: inherit; -} -.panel-title { - margin-top: 0; - margin-bottom: 0; - font-size: 16px; - color: inherit; -} -.panel-title > a { - color: inherit; -} -.panel-footer { - padding: 10px 15px; - background-color: #3e444c; - border-top: 1px solid rgba(0, 0, 0, 0.6); - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel > .list-group { - margin-bottom: 0; -} -.panel > .list-group .list-group-item { - border-width: 1px 0; - border-radius: 0; -} -.panel > .list-group:first-child .list-group-item:first-child { - border-top: 0; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel > .list-group:last-child .list-group-item:last-child { - border-bottom: 0; - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel-heading + .list-group .list-group-item:first-child { - border-top-width: 0; -} -.list-group + .panel-footer { - border-top-width: 0; -} -.panel > .table, -.panel > .table-responsive > .table, -.panel > .panel-collapse > .table { - margin-bottom: 0; -} -.panel > .table:first-child, -.panel > .table-responsive:first-child > .table:first-child { - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel > .table:first-child > thead:first-child > tr:first-child td:first-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child, -.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child, -.panel > .table:first-child > thead:first-child > tr:first-child th:first-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child, -.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child { - border-top-left-radius: 3px; -} -.panel > .table:first-child > thead:first-child > tr:first-child td:last-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child, -.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child, -.panel > .table:first-child > thead:first-child > tr:first-child th:last-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child, -.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child { - border-top-right-radius: 3px; -} -.panel > .table:last-child, -.panel > .table-responsive:last-child > .table:last-child { - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child, -.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child { - border-bottom-left-radius: 3px; -} -.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child, -.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child { - border-bottom-right-radius: 3px; -} -.panel > .panel-body + .table, -.panel > .panel-body + .table-responsive { - border-top: 1px solid #1c1e22; -} -.panel > .table > tbody:first-child > tr:first-child th, -.panel > .table > tbody:first-child > tr:first-child td { - border-top: 0; -} -.panel > .table-bordered, -.panel > .table-responsive > .table-bordered { - border: 0; -} -.panel > .table-bordered > thead > tr > th:first-child, -.panel > .table-responsive > .table-bordered > thead > tr > th:first-child, -.panel > .table-bordered > tbody > tr > th:first-child, -.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child, -.panel > .table-bordered > tfoot > tr > th:first-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child, -.panel > .table-bordered > thead > tr > td:first-child, -.panel > .table-responsive > .table-bordered > thead > tr > td:first-child, -.panel > .table-bordered > tbody > tr > td:first-child, -.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child, -.panel > .table-bordered > tfoot > tr > td:first-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child { - border-left: 0; -} -.panel > .table-bordered > thead > tr > th:last-child, -.panel > .table-responsive > .table-bordered > thead > tr > th:last-child, -.panel > .table-bordered > tbody > tr > th:last-child, -.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child, -.panel > .table-bordered > tfoot > tr > th:last-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child, -.panel > .table-bordered > thead > tr > td:last-child, -.panel > .table-responsive > .table-bordered > thead > tr > td:last-child, -.panel > .table-bordered > tbody > tr > td:last-child, -.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child, -.panel > .table-bordered > tfoot > tr > td:last-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child { - border-right: 0; -} -.panel > .table-bordered > thead > tr:first-child > td, -.panel > .table-responsive > .table-bordered > thead > tr:first-child > td, -.panel > .table-bordered > tbody > tr:first-child > td, -.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td, -.panel > .table-bordered > thead > tr:first-child > th, -.panel > .table-responsive > .table-bordered > thead > tr:first-child > th, -.panel > .table-bordered > tbody > tr:first-child > th, -.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th { - border-bottom: 0; -} -.panel > .table-bordered > tbody > tr:last-child > td, -.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td, -.panel > .table-bordered > tfoot > tr:last-child > td, -.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td, -.panel > .table-bordered > tbody > tr:last-child > th, -.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th, -.panel > .table-bordered > tfoot > tr:last-child > th, -.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th { - border-bottom: 0; -} -.panel > .table-responsive { - border: 0; - margin-bottom: 0; -} -.panel-group { - margin-bottom: 20px; -} -.panel-group .panel { - margin-bottom: 0; - border-radius: 4px; -} -.panel-group .panel + .panel { - margin-top: 5px; -} -.panel-group .panel-heading { - border-bottom: 0; -} -.panel-group .panel-heading + .panel-collapse > .panel-body { - border-top: 1px solid rgba(0, 0, 0, 0.6); -} -.panel-group .panel-footer { - border-top: 0; -} -.panel-group .panel-footer + .panel-collapse .panel-body { - border-bottom: 1px solid rgba(0, 0, 0, 0.6); -} -.panel-default { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-default > .panel-heading { - color: #c8c8c8; - background-color: #3e444c; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-default > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-default > .panel-heading .badge { - color: #3e444c; - background-color: #c8c8c8; -} -.panel-default > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.panel-primary { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-primary > .panel-heading { - color: #ffffff; - background-color: #7a8288; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-primary > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-primary > .panel-heading .badge { - color: #7a8288; - background-color: #ffffff; -} -.panel-primary > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.panel-success { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-success > .panel-heading { - color: #ffffff; - background-color: #62c462; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-success > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-success > .panel-heading .badge { - color: #62c462; - background-color: #ffffff; -} -.panel-success > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.panel-info { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-info > .panel-heading { - color: #ffffff; - background-color: #5bc0de; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-info > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-info > .panel-heading .badge { - color: #5bc0de; - background-color: #ffffff; -} -.panel-info > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.panel-warning { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-warning > .panel-heading { - color: #ffffff; - background-color: #f89406; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-warning > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-warning > .panel-heading .badge { - color: #f89406; - background-color: #ffffff; -} -.panel-warning > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.panel-danger { - border-color: rgba(0, 0, 0, 0.6); -} -.panel-danger > .panel-heading { - color: #ffffff; - background-color: #ee5f5b; - border-color: rgba(0, 0, 0, 0.6); -} -.panel-danger > .panel-heading + .panel-collapse > .panel-body { - border-top-color: rgba(0, 0, 0, 0.6); -} -.panel-danger > .panel-heading .badge { - color: #ee5f5b; - background-color: #ffffff; -} -.panel-danger > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: rgba(0, 0, 0, 0.6); -} -.embed-responsive { - position: relative; - display: block; - height: 0; - padding: 0; - overflow: hidden; -} -.embed-responsive .embed-responsive-item, -.embed-responsive iframe, -.embed-responsive embed, -.embed-responsive object { - position: absolute; - top: 0; - left: 0; - bottom: 0; - height: 100%; - width: 100%; - border: 0; -} -.embed-responsive.embed-responsive-16by9 { - padding-bottom: 56.25%; -} -.embed-responsive.embed-responsive-4by3 { - padding-bottom: 75%; -} -.well { - min-height: 20px; - padding: 19px; - margin-bottom: 20px; - background-color: #1c1e22; - border: 1px solid #0c0d0e; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); -} -.well blockquote { - border-color: #ddd; - border-color: rgba(0, 0, 0, 0.15); -} -.well-lg { - padding: 24px; - border-radius: 6px; -} -.well-sm { - padding: 9px; - border-radius: 3px; -} -.close { - float: right; - font-size: 21px; - font-weight: bold; - line-height: 1; - color: #000000; - text-shadow: 0 1px 0 #ffffff; - opacity: 0.2; - filter: alpha(opacity=20); -} -.close:hover, -.close:focus { - color: #000000; - text-decoration: none; - cursor: pointer; - opacity: 0.5; - filter: alpha(opacity=50); -} -button.close { - padding: 0; - cursor: pointer; - background: transparent; - border: 0; - -webkit-appearance: none; -} -.modal-open { - overflow: hidden; -} -.modal { - display: none; - overflow: hidden; - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1050; - -webkit-overflow-scrolling: touch; - outline: 0; -} -.modal.fade .modal-dialog { - -webkit-transform: translate3d(0, -25%, 0); - transform: translate3d(0, -25%, 0); - -webkit-transition: -webkit-transform 0.3s ease-out; - -moz-transition: -moz-transform 0.3s ease-out; - -o-transition: -o-transform 0.3s ease-out; - transition: transform 0.3s ease-out; -} -.modal.in .modal-dialog { - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); -} -.modal-open .modal { - overflow-x: hidden; - overflow-y: auto; -} -.modal-dialog { - position: relative; - width: auto; - margin: 10px; -} -.modal-content { - position: relative; - background-color: #2e3338; - border: 1px solid #999999; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); - box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); - background-clip: padding-box; - outline: 0; -} -.modal-backdrop { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1040; - background-color: #000000; -} -.modal-backdrop.fade { - opacity: 0; - filter: alpha(opacity=0); -} -.modal-backdrop.in { - opacity: 0.5; - filter: alpha(opacity=50); -} -.modal-header { - padding: 15px; - border-bottom: 1px solid #1c1e22; - min-height: 16.42857143px; -} -.modal-header .close { - margin-top: -2px; -} -.modal-title { - margin: 0; - line-height: 1.42857143; -} -.modal-body { - position: relative; - padding: 20px; -} -.modal-footer { - padding: 20px; - text-align: right; - border-top: 1px solid #1c1e22; -} -.modal-footer .btn + .btn { - margin-left: 5px; - margin-bottom: 0; -} -.modal-footer .btn-group .btn + .btn { - margin-left: -1px; -} -.modal-footer .btn-block + .btn-block { - margin-left: 0; -} -.modal-scrollbar-measure { - position: absolute; - top: -9999px; - width: 50px; - height: 50px; - overflow: scroll; -} -@media (min-width: 768px) { - .modal-dialog { - width: 600px; - margin: 30px auto; - } - .modal-content { - -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); - box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); - } - .modal-sm { - width: 300px; - } -} -@media (min-width: 992px) { - .modal-lg { - width: 900px; - } -} -.tooltip { - position: absolute; - z-index: 1070; - display: block; - visibility: visible; - font-size: 12px; - line-height: 1.4; - opacity: 0; - filter: alpha(opacity=0); -} -.tooltip.in { - opacity: 0.9; - filter: alpha(opacity=90); -} -.tooltip.top { - margin-top: -3px; - padding: 5px 0; -} -.tooltip.right { - margin-left: 3px; - padding: 0 5px; -} -.tooltip.bottom { - margin-top: 3px; - padding: 5px 0; -} -.tooltip.left { - margin-left: -3px; - padding: 0 5px; -} -.tooltip-inner { - max-width: 200px; - padding: 3px 8px; - color: #ffffff; - text-align: center; - text-decoration: none; - background-color: rgba(0, 0, 0, 0.9); - border-radius: 4px; -} -.tooltip-arrow { - position: absolute; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} -.tooltip.top .tooltip-arrow { - bottom: 0; - left: 50%; - margin-left: -5px; - border-width: 5px 5px 0; - border-top-color: rgba(0, 0, 0, 0.9); -} -.tooltip.top-left .tooltip-arrow { - bottom: 0; - left: 5px; - border-width: 5px 5px 0; - border-top-color: rgba(0, 0, 0, 0.9); -} -.tooltip.top-right .tooltip-arrow { - bottom: 0; - right: 5px; - border-width: 5px 5px 0; - border-top-color: rgba(0, 0, 0, 0.9); -} -.tooltip.right .tooltip-arrow { - top: 50%; - left: 0; - margin-top: -5px; - border-width: 5px 5px 5px 0; - border-right-color: rgba(0, 0, 0, 0.9); -} -.tooltip.left .tooltip-arrow { - top: 50%; - right: 0; - margin-top: -5px; - border-width: 5px 0 5px 5px; - border-left-color: rgba(0, 0, 0, 0.9); -} -.tooltip.bottom .tooltip-arrow { - top: 0; - left: 50%; - margin-left: -5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(0, 0, 0, 0.9); -} -.tooltip.bottom-left .tooltip-arrow { - top: 0; - left: 5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(0, 0, 0, 0.9); -} -.tooltip.bottom-right .tooltip-arrow { - top: 0; - right: 5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(0, 0, 0, 0.9); -} -.popover { - position: absolute; - top: 0; - left: 0; - z-index: 1060; - display: none; - max-width: 276px; - padding: 1px; - text-align: left; - background-color: #2e3338; - background-clip: padding-box; - border: 1px solid #999999; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - white-space: normal; -} -.popover.top { - margin-top: -10px; -} -.popover.right { - margin-left: 10px; -} -.popover.bottom { - margin-top: 10px; -} -.popover.left { - margin-left: -10px; -} -.popover-title { - margin: 0; - padding: 8px 14px; - font-size: 14px; - font-weight: normal; - line-height: 18px; - background-color: #2e3338; - border-bottom: 1px solid #22262a; - border-radius: 5px 5px 0 0; -} -.popover-content { - padding: 9px 14px; -} -.popover > .arrow, -.popover > .arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} -.popover > .arrow { - border-width: 11px; -} -.popover > .arrow:after { - border-width: 10px; - content: ""; -} -.popover.top > .arrow { - left: 50%; - margin-left: -11px; - border-bottom-width: 0; - border-top-color: #666666; - border-top-color: rgba(0, 0, 0, 0.25); - bottom: -11px; -} -.popover.top > .arrow:after { - content: " "; - bottom: 1px; - margin-left: -10px; - border-bottom-width: 0; - border-top-color: #2e3338; -} -.popover.right > .arrow { - top: 50%; - left: -11px; - margin-top: -11px; - border-left-width: 0; - border-right-color: #666666; - border-right-color: rgba(0, 0, 0, 0.25); -} -.popover.right > .arrow:after { - content: " "; - left: 1px; - bottom: -10px; - border-left-width: 0; - border-right-color: #2e3338; -} -.popover.bottom > .arrow { - left: 50%; - margin-left: -11px; - border-top-width: 0; - border-bottom-color: #666666; - border-bottom-color: rgba(0, 0, 0, 0.25); - top: -11px; -} -.popover.bottom > .arrow:after { - content: " "; - top: 1px; - margin-left: -10px; - border-top-width: 0; - border-bottom-color: #2e3338; -} -.popover.left > .arrow { - top: 50%; - right: -11px; - margin-top: -11px; - border-right-width: 0; - border-left-color: #666666; - border-left-color: rgba(0, 0, 0, 0.25); -} -.popover.left > .arrow:after { - content: " "; - right: 1px; - border-right-width: 0; - border-left-color: #2e3338; - bottom: -10px; -} -.carousel { - position: relative; -} -.carousel-inner { - position: relative; - overflow: hidden; - width: 100%; -} -.carousel-inner > .item { - display: none; - position: relative; - -webkit-transition: 0.6s ease-in-out left; - -o-transition: 0.6s ease-in-out left; - transition: 0.6s ease-in-out left; -} -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - line-height: 1; -} -.carousel-inner > .active, -.carousel-inner > .next, -.carousel-inner > .prev { - display: block; -} -.carousel-inner > .active { - left: 0; -} -.carousel-inner > .next, -.carousel-inner > .prev { - position: absolute; - top: 0; - width: 100%; -} -.carousel-inner > .next { - left: 100%; -} -.carousel-inner > .prev { - left: -100%; -} -.carousel-inner > .next.left, -.carousel-inner > .prev.right { - left: 0; -} -.carousel-inner > .active.left { - left: -100%; -} -.carousel-inner > .active.right { - left: 100%; -} -.carousel-control { - position: absolute; - top: 0; - left: 0; - bottom: 0; - width: 15%; - opacity: 0.5; - filter: alpha(opacity=50); - font-size: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); -} -.carousel-control.left { - background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); - background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1); -} -.carousel-control.right { - left: auto; - right: 0; - background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); - background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1); -} -.carousel-control:hover, -.carousel-control:focus { - outline: 0; - color: #ffffff; - text-decoration: none; - opacity: 0.9; - filter: alpha(opacity=90); -} -.carousel-control .icon-prev, -.carousel-control .icon-next, -.carousel-control .glyphicon-chevron-left, -.carousel-control .glyphicon-chevron-right { - position: absolute; - top: 50%; - z-index: 5; - display: inline-block; -} -.carousel-control .icon-prev, -.carousel-control .glyphicon-chevron-left { - left: 50%; - margin-left: -10px; -} -.carousel-control .icon-next, -.carousel-control .glyphicon-chevron-right { - right: 50%; - margin-right: -10px; -} -.carousel-control .icon-prev, -.carousel-control .icon-next { - width: 20px; - height: 20px; - margin-top: -10px; - font-family: serif; -} -.carousel-control .icon-prev:before { - content: '\2039'; -} -.carousel-control .icon-next:before { - content: '\203a'; -} -.carousel-indicators { - position: absolute; - bottom: 10px; - left: 50%; - z-index: 15; - width: 60%; - margin-left: -30%; - padding-left: 0; - list-style: none; - text-align: center; -} -.carousel-indicators li { - display: inline-block; - width: 10px; - height: 10px; - margin: 1px; - text-indent: -999px; - border: 1px solid #ffffff; - border-radius: 10px; - cursor: pointer; - background-color: #000 \9; - background-color: rgba(0, 0, 0, 0); -} -.carousel-indicators .active { - margin: 0; - width: 12px; - height: 12px; - background-color: #ffffff; -} -.carousel-caption { - position: absolute; - left: 15%; - right: 15%; - bottom: 20px; - z-index: 10; - padding-top: 20px; - padding-bottom: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); -} -.carousel-caption .btn { - text-shadow: none; -} -@media screen and (min-width: 768px) { - .carousel-control .glyphicon-chevron-left, - .carousel-control .glyphicon-chevron-right, - .carousel-control .icon-prev, - .carousel-control .icon-next { - width: 30px; - height: 30px; - margin-top: -15px; - font-size: 30px; - } - .carousel-control .glyphicon-chevron-left, - .carousel-control .icon-prev { - margin-left: -15px; - } - .carousel-control .glyphicon-chevron-right, - .carousel-control .icon-next { - margin-right: -15px; - } - .carousel-caption { - left: 20%; - right: 20%; - padding-bottom: 30px; - } - .carousel-indicators { - bottom: 20px; - } -} -.clearfix:before, -.clearfix:after, -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after, -.btn-toolbar:before, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after, -.nav:before, -.nav:after, -.navbar:before, -.navbar:after, -.navbar-header:before, -.navbar-header:after, -.navbar-collapse:before, -.navbar-collapse:after, -.pager:before, -.pager:after, -.panel-body:before, -.panel-body:after, -.modal-footer:before, -.modal-footer:after { - content: " "; - display: table; -} -.clearfix:after, -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:after, -.nav:after, -.navbar:after, -.navbar-header:after, -.navbar-collapse:after, -.pager:after, -.panel-body:after, -.modal-footer:after { - clear: both; -} -.center-block { - display: block; - margin-left: auto; - margin-right: auto; -} -.pull-right { - float: right !important; -} -.pull-left { - float: left !important; -} -.hide { - display: none !important; -} -.show { - display: block !important; -} -.invisible { - visibility: hidden; -} -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} -.hidden { - display: none !important; - visibility: hidden !important; -} -.affix { - position: fixed; - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); -} -@-ms-viewport { - width: device-width; -} -.visible-xs, -.visible-sm, -.visible-md, -.visible-lg { - display: none !important; -} -.visible-xs-block, -.visible-xs-inline, -.visible-xs-inline-block, -.visible-sm-block, -.visible-sm-inline, -.visible-sm-inline-block, -.visible-md-block, -.visible-md-inline, -.visible-md-inline-block, -.visible-lg-block, -.visible-lg-inline, -.visible-lg-inline-block { - display: none !important; -} -@media (max-width: 767px) { - .visible-xs { - display: block !important; - } - table.visible-xs { - display: table; - } - tr.visible-xs { - display: table-row !important; - } - th.visible-xs, - td.visible-xs { - display: table-cell !important; - } -} -@media (max-width: 767px) { - .visible-xs-block { - display: block !important; - } -} -@media (max-width: 767px) { - .visible-xs-inline { - display: inline !important; - } -} -@media (max-width: 767px) { - .visible-xs-inline-block { - display: inline-block !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm { - display: block !important; - } - table.visible-sm { - display: table; - } - tr.visible-sm { - display: table-row !important; - } - th.visible-sm, - td.visible-sm { - display: table-cell !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-block { - display: block !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-inline { - display: inline !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-inline-block { - display: inline-block !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md { - display: block !important; - } - table.visible-md { - display: table; - } - tr.visible-md { - display: table-row !important; - } - th.visible-md, - td.visible-md { - display: table-cell !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-block { - display: block !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-inline { - display: inline !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-inline-block { - display: inline-block !important; - } -} -@media (min-width: 1200px) { - .visible-lg { - display: block !important; - } - table.visible-lg { - display: table; - } - tr.visible-lg { - display: table-row !important; - } - th.visible-lg, - td.visible-lg { - display: table-cell !important; - } -} -@media (min-width: 1200px) { - .visible-lg-block { - display: block !important; - } -} -@media (min-width: 1200px) { - .visible-lg-inline { - display: inline !important; - } -} -@media (min-width: 1200px) { - .visible-lg-inline-block { - display: inline-block !important; - } -} -@media (max-width: 767px) { - .hidden-xs { - display: none !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .hidden-sm { - display: none !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-md { - display: none !important; - } -} -@media (min-width: 1200px) { - .hidden-lg { - display: none !important; - } -} -.visible-print { - display: none !important; -} -@media print { - .visible-print { - display: block !important; - } - table.visible-print { - display: table; - } - tr.visible-print { - display: table-row !important; - } - th.visible-print, - td.visible-print { - display: table-cell !important; - } -} -.visible-print-block { - display: none !important; -} -@media print { - .visible-print-block { - display: block !important; - } -} -.visible-print-inline { - display: none !important; -} -@media print { - .visible-print-inline { - display: inline !important; - } -} -.visible-print-inline-block { - display: none !important; -} -@media print { - .visible-print-inline-block { - display: inline-block !important; - } -} -@media print { - .hidden-print { - display: none !important; - } -} -.navbar { - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; - border: 1px solid rgba(0, 0, 0, 0.6); - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); -} -.navbar-inverse { - background-image: -webkit-linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-image: -o-linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-image: linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff8a9196', endColorstr='#ff70787d', GradientType=0); - filter: none; -} -.navbar-inverse .badge { - background-color: #5d6368; -} -.navbar-nav > li > a { - border-right: 1px solid rgba(0, 0, 0, 0.2); - border-left: 1px solid rgba(255, 255, 255, 0.1); -} -.navbar-nav > li > a:hover { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; - border-left-color: transparent; -} -.navbar .nav .open > a { - border-color: transparent; -} -.navbar-nav > li.active > a { - border-left-color: transparent; -} -.navbar-form { - margin-left: 5px; - margin-right: 5px; -} -.btn, -.btn:hover { - border-color: rgba(0, 0, 0, 0.6); - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); -} -.btn-default { - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.btn-default:hover { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; -} -.btn-primary { - background-image: -webkit-linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-image: -o-linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-image: linear-gradient(#8a9196, #7a8288 60%, #70787d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff8a9196', endColorstr='#ff70787d', GradientType=0); - filter: none; -} -.btn-primary:hover { - background-image: -webkit-linear-gradient(#404448, #4e5458 40%, #585e62); - background-image: -o-linear-gradient(#404448, #4e5458 40%, #585e62); - background-image: linear-gradient(#404448, #4e5458 40%, #585e62); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff404448', endColorstr='#ff585e62', GradientType=0); - filter: none; -} -.btn-success { - background-image: -webkit-linear-gradient(#78cc78, #62c462 60%, #53be53); - background-image: -o-linear-gradient(#78cc78, #62c462 60%, #53be53); - background-image: linear-gradient(#78cc78, #62c462 60%, #53be53); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff78cc78', endColorstr='#ff53be53', GradientType=0); - filter: none; -} -.btn-success:hover { - background-image: -webkit-linear-gradient(#2f7d2f, #379337 40%, #3da23d); - background-image: -o-linear-gradient(#2f7d2f, #379337 40%, #3da23d); - background-image: linear-gradient(#2f7d2f, #379337 40%, #3da23d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff2f7d2f', endColorstr='#ff3da23d', GradientType=0); - filter: none; -} -.btn-info { - background-image: -webkit-linear-gradient(#74cae3, #5bc0de 60%, #4ab9db); - background-image: -o-linear-gradient(#74cae3, #5bc0de 60%, #4ab9db); - background-image: linear-gradient(#74cae3, #5bc0de 60%, #4ab9db); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff74cae3', endColorstr='#ff4ab9db', GradientType=0); - filter: none; -} -.btn-info:hover { - background-image: -webkit-linear-gradient(#20829f, #2596b8 40%, #28a4c9); - background-image: -o-linear-gradient(#20829f, #2596b8 40%, #28a4c9); - background-image: linear-gradient(#20829f, #2596b8 40%, #28a4c9); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff20829f', endColorstr='#ff28a4c9', GradientType=0); - filter: none; -} -.btn-warning { - background-image: -webkit-linear-gradient(#faa123, #f89406 60%, #e48806); - background-image: -o-linear-gradient(#faa123, #f89406 60%, #e48806); - background-image: linear-gradient(#faa123, #f89406 60%, #e48806); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffaa123', endColorstr='#ffe48806', GradientType=0); - filter: none; -} -.btn-warning:hover { - background-image: -webkit-linear-gradient(#804d03, #9e5f04 40%, #b26a04); - background-image: -o-linear-gradient(#804d03, #9e5f04 40%, #b26a04); - background-image: linear-gradient(#804d03, #9e5f04 40%, #b26a04); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff804d03', endColorstr='#ffb26a04', GradientType=0); - filter: none; -} -.btn-danger { - background-image: -webkit-linear-gradient(#f17a77, #ee5f5b 60%, #ec4d49); - background-image: -o-linear-gradient(#f17a77, #ee5f5b 60%, #ec4d49); - background-image: linear-gradient(#f17a77, #ee5f5b 60%, #ec4d49); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff17a77', endColorstr='#ffec4d49', GradientType=0); - filter: none; -} -.btn-danger:hover { - background-image: -webkit-linear-gradient(#bb1813, #d71c16 40%, #e7201a); - background-image: -o-linear-gradient(#bb1813, #d71c16 40%, #e7201a); - background-image: linear-gradient(#bb1813, #d71c16 40%, #e7201a); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffbb1813', endColorstr='#ffe7201a', GradientType=0); - filter: none; -} -.btn-link, -.btn-link:hover { - border-color: transparent; -} -h1, -h2, -h3, -h4, -h5, -h6 { - text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.3); -} -.text-primary, -.text-primary:hover { - color: #7a8288; -} -.text-success, -.text-success:hover { - color: #62c462; -} -.text-danger, -.text-danger:hover { - color: #ee5f5b; -} -.text-warning, -.text-warning:hover { - color: #f89406; -} -.text-info, -.text-info:hover { - color: #5bc0de; -} -.table .success, -.table .warning, -.table .danger, -.table .info { - color: #fff; -} -.table-bordered tbody tr.success td, -.table-bordered tbody tr.warning td, -.table-bordered tbody tr.danger td, -.table-bordered tbody tr.success:hover td, -.table-bordered tbody tr.warning:hover td, -.table-bordered tbody tr.danger:hover td { - border-color: #1c1e22; -} -.table-responsive > .table { - background-color: #2e3338; -} -input, -textarea { - color: #272b30; -} -.has-warning .help-block, -.has-warning .control-label, -.has-warning .form-control-feedback { - color: #f89406; -} -.has-warning .form-control, -.has-warning .form-control:focus { - border-color: #f89406; -} -.has-warning .input-group-addon { - background-color: #272b30; - border: none; -} -.has-error .help-block, -.has-error .control-label, -.has-error .form-control-feedback { - color: #ee5f5b; -} -.has-error .form-control, -.has-error .form-control:focus { - border-color: #ee5f5b; -} -.has-error .input-group-addon { - background-color: #272b30; - border: none; -} -.has-success .help-block, -.has-success .control-label, -.has-success .form-control-feedback { - color: #62c462; -} -.has-success .form-control, -.has-success .form-control:focus { - border-color: #62c462; -} -.has-success .input-group-addon { - background-color: #272b30; - border: none; -} -legend { - color: #fff; -} -.input-group-addon { - border-color: rgba(0, 0, 0, 0.6); - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; - color: #ffffff; -} -.nav .open > a, -.nav .open > a:hover, -.nav .open > a:focus { - border-color: rgba(0, 0, 0, 0.6); -} -.nav-pills > li > a { - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; - border: 1px solid rgba(0, 0, 0, 0.6); - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); -} -.nav-pills > li > a:hover { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; - border: 1px solid rgba(0, 0, 0, 0.6); -} -.nav-pills > li.active > a, -.nav-pills > li.active > a:hover { - background-color: none; - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; - border: 1px solid rgba(0, 0, 0, 0.6); -} -.nav-pills > li.disabled > a, -.nav-pills > li.disabled > a:hover { - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.pagination > li > a, -.pagination > li > span { - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.pagination > li > a:hover, -.pagination > li > span:hover { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; -} -.pagination > li.active > a, -.pagination > li.active > span { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; -} -.pagination > li.disabled > a, -.pagination > li.disabled > a:hover, -.pagination > li.disabled > span, -.pagination > li.disabled > span:hover { - background-color: transparent; - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.pager > li > a { - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); -} -.pager > li > a:hover { - background-image: -webkit-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: -o-linear-gradient(#020202, #101112 40%, #191b1d); - background-image: linear-gradient(#020202, #101112 40%, #191b1d); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff020202', endColorstr='#ff191b1d', GradientType=0); - filter: none; -} -.pager > li.disabled > a, -.pager > li.disabled > a:hover { - background-color: transparent; - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.breadcrumb { - border: 1px solid rgba(0, 0, 0, 0.6); - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); - background-image: -webkit-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: -o-linear-gradient(#484e55, #3a3f44 60%, #313539); - background-image: linear-gradient(#484e55, #3a3f44 60%, #313539); - background-repeat: no-repeat; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff484e55', endColorstr='#ff313539', GradientType=0); - filter: none; -} -.alert .alert-link, -.alert a { - color: #fff; - text-decoration: underline; -} -.alert .close { - color: #000000; - text-decoration: none; -} -a.thumbnail:hover, -a.thumbnail:focus, -a.thumbnail.active { - border-color: #0c0d0e; -} -.jumbotron { - border: 1px solid rgba(0, 0, 0, 0.6); -} -.panel-primary .panel-heading, -.panel-success .panel-heading, -.panel-danger .panel-heading, -.panel-warning .panel-heading, -.panel-info .panel-heading { - border-color: #000; -} diff --git a/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.js b/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.js deleted file mode 100644 index 7c1561a8..00000000 --- a/src/MoonSharp.RemoteDebugger/Resources/bootstrap.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * Bootstrap v3.2.0 (http://getbootstrap.com) - * Copyright 2011-2014 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - */ -if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.2.0",d.prototype.close=function(b){function c(){f.detach().trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one("bsTransitionEnd",c).emulateTransitionEnd(150):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.2.0",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),d[e](null==f[b]?this.options[b]:f[b]),setTimeout(a.proxy(function(){"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b).on("keydown.bs.carousel",a.proxy(this.keydown,this)),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.2.0",c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},c.prototype.keydown=function(a){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.to=function(b){var c=this,d=this.getItemIndex(this.$active=this.$element.find(".item.active"));return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}if(e.hasClass("active"))return this.sliding=!1;var j=e[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:g});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,f&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(e)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:g});return a.support.transition&&this.$element.hasClass("slide")?(e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one("bsTransitionEnd",function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(1e3*d.css("transition-duration").slice(0,-1))):(d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger(m)),f&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b);!e&&f.toggle&&"show"==b&&(b=!b),e||d.data("bs.collapse",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};c.VERSION="3.2.0",c.DEFAULTS={toggle:!0},c.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},c.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var c=a.Event("show.bs.collapse");if(this.$element.trigger(c),!c.isDefaultPrevented()){var d=this.$parent&&this.$parent.find("> .panel > .in");if(d&&d.length){var e=d.data("bs.collapse");if(e&&e.transitioning)return;b.call(d,"hide"),e||d.data("bs.collapse",null)}var f=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[f](0),this.transitioning=1;var g=function(){this.$element.removeClass("collapsing").addClass("collapse in")[f](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return g.call(this);var h=a.camelCase(["scroll",f].join("-"));this.$element.one("bsTransitionEnd",a.proxy(g,this)).emulateTransitionEnd(350)[f](this.$element[0][h])}}},c.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(d,this)).emulateTransitionEnd(350):d.call(this)}}},c.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var d=a.fn.collapse;a.fn.collapse=b,a.fn.collapse.Constructor=c,a.fn.collapse.noConflict=function(){return a.fn.collapse=d,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(c){var d,e=a(this),f=e.attr("data-target")||c.preventDefault()||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),g=a(f),h=g.data("bs.collapse"),i=h?"toggle":e.data(),j=e.attr("data-parent"),k=j&&a(j);h&&h.transitioning||(k&&k.find('[data-toggle="collapse"][data-parent="'+j+'"]').not(e).addClass("collapsed"),e[g.hasClass("in")?"addClass":"removeClass"]("collapsed")),b.call(g,i)})}(jQuery),+function(a){"use strict";function b(b){b&&3===b.which||(a(e).remove(),a(f).each(function(){var d=c(a(this)),e={relatedTarget:this};d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown",e)),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown",e))}))}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.2.0",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('