Browse Source

Documentation / tutorials

Xanathar 11 years ago
parent
commit
7f5f6faa0a
25 changed files with 497 additions and 149 deletions
  1. 3 3
      src/MoonSharp.Debugger/MainForm.cs
  2. 2 2
      src/MoonSharp.Debugger/ValueBrowser.cs
  3. 106 0
      src/MoonSharp.Documentation/Content/Walkthrough.aml
  4. 7 49
      src/MoonSharp.Documentation/Content/Welcome.aml
  5. 1 15
      src/MoonSharp.Documentation/ContentLayout.content
  6. 14 1
      src/MoonSharp.Documentation/MoonSharp.Documentation.shfbproj
  7. 42 5
      src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs
  8. 45 1
      src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs
  9. 25 4
      src/MoonSharp.Interpreter/DataTypes/Closure.cs
  10. 53 1
      src/MoonSharp.Interpreter/DataTypes/DataType.cs
  11. 13 4
      src/MoonSharp.Interpreter/DataTypes/DynValue.cs
  12. 10 1
      src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs
  13. 4 0
      src/MoonSharp.Interpreter/DataTypes/InteropAccessMode.cs
  14. 69 13
      src/MoonSharp.Interpreter/DataTypes/Table.cs
  15. 17 1
      src/MoonSharp.Interpreter/DataTypes/TablePair.cs
  16. 10 0
      src/MoonSharp.Interpreter/DataTypes/WellKnownSymbols.cs
  17. 2 2
      src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs
  18. 2 2
      src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs
  19. 3 0
      src/MoonSharp.Interpreter/Interop/ConversionHelper.cs
  20. 3 3
      src/MoonSharp.Interpreter/Interop/EnumerableWrapper.cs
  21. 0 1
      src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj
  22. 0 30
      src/MoonSharp.Interpreter/MoonSharpInterpreter.cs
  23. 2 2
      src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs
  24. 63 8
      src/MoonSharp.Interpreter/Script.cs
  25. 1 1
      src/PerformanceComparison/PerformanceComparison.csproj

+ 3 - 3
src/MoonSharp.Debugger/MainForm.cs

@@ -30,7 +30,7 @@ namespace MoonSharp.Debugger
 		private void MainForm_Load(object sender, EventArgs e)
 		private void MainForm_Load(object sender, EventArgs e)
 		{
 		{
 			m_Ctx = SynchronizationContext.Current;
 			m_Ctx = SynchronizationContext.Current;
-			MoonSharpInterpreter.WarmUp();
+			Script.WarmUp();
 		}
 		}
 
 
 		private void openToolStripMenuItem_Click(object sender, EventArgs e)
 		private void openToolStripMenuItem_Click(object sender, EventArgs e)
@@ -352,7 +352,7 @@ namespace MoonSharp.Debugger
 			var v = lvVStack.SelectedItems.OfType<ListViewItem>().Select(lvi => lvi.Tag).Cast<DynValue>().FirstOrDefault();
 			var v = lvVStack.SelectedItems.OfType<ListViewItem>().Select(lvi => lvi.Tag).Cast<DynValue>().FirstOrDefault();
 
 
 			if (v != null && v.Type == DataType.Function)
 			if (v != null && v.Type == DataType.Function)
-				GotoBytecode(v.Function.ByteCodeLocation);
+				GotoBytecode(v.Function.EntryPointByteCodeLocation);
 		}
 		}
 
 
 		private void toolGoToCodeWatches_Click(object sender, EventArgs e)
 		private void toolGoToCodeWatches_Click(object sender, EventArgs e)
@@ -360,7 +360,7 @@ namespace MoonSharp.Debugger
 			var v = lvWatches.SelectedItems.OfType<ListViewItem>().Select(lvi => lvi.Tag).Cast<DynValue>().FirstOrDefault();
 			var v = lvWatches.SelectedItems.OfType<ListViewItem>().Select(lvi => lvi.Tag).Cast<DynValue>().FirstOrDefault();
 
 
 			if (v != null && v.Type == DataType.Function)
 			if (v != null && v.Type == DataType.Function)
-				GotoBytecode(v.Function.ByteCodeLocation);
+				GotoBytecode(v.Function.EntryPointByteCodeLocation);
 		}
 		}
 		private void toolGoToCodeXStack_Click(object sender, EventArgs e)
 		private void toolGoToCodeXStack_Click(object sender, EventArgs e)
 		{
 		{

+ 2 - 2
src/MoonSharp.Debugger/ValueBrowser.cs

@@ -132,7 +132,7 @@ namespace MoonSharp.Debugger
 		{
 		{
 			var F = V.Function;
 			var F = V.Function;
 			var C = F.ClosureContext;
 			var C = F.ClosureContext;
-			lvProps.Add("Bytecode Location", F.ByteCodeLocation.ToString("X8"));
+			lvProps.Add("Bytecode Location", F.EntryPointByteCodeLocation.ToString("X8"));
 
 
 			for (int i = 0; i < C.Count; i++)
 			for (int i = 0; i < C.Count; i++)
 			{
 			{
@@ -154,7 +154,7 @@ namespace MoonSharp.Debugger
 		{
 		{
 			var T = V.Table;
 			var T = V.Table;
 
 
-			foreach (var kvp in T.DebugPairs())
+			foreach (var kvp in T.Pairs)
 			{
 			{
 				listView.Add(kvp.Key, kvp.Value).Tag = kvp.Value;
 				listView.Add(kvp.Key, kvp.Value).Tag = kvp.Value;
 			}
 			}

+ 106 - 0
src/MoonSharp.Documentation/Content/Walkthrough.aml

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<topic id="18719b77-72b0-48dc-9fc1-3f27275c930b" revisionNumber="1">
+  <developerWalkthroughDocument
+    xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
+    xmlns:xlink="http://www.w3.org/1999/xlink">
+
+    <!--
+    <summary>
+      <para>Optional summary abstract</para>
+    </summary>
+    -->
+
+    <introduction>
+      <!-- Uncomment this to generate an outline of the section and sub-section
+           titles.  Specify a numeric value as the inner text to limit it to
+           a specific number of sub-topics when creating the outline.  Specify
+           zero (0) to limit it to top-level sections only.  -->
+      <!-- <autoOutline /> -->
+
+      <para>Required introduction</para>
+    </introduction>
+
+    <!-- <prerequisites><content>Optional prerequisites info</content></prerequisites> -->
+
+    <!-- One or more procedure or section with procedure -->
+    <procedure>
+      <title>Procedure title</title>
+      <steps class="ordered">
+        <step>
+          <content>
+            <para>First step</para>
+          </content>
+        </step>
+        <step>
+          <content>
+            <para>Second step</para>
+          </content>
+        </step>
+      </steps>
+      <!-- <conclusion>Optional conclusion</conclusion> -->
+    </procedure>
+
+    <!-- Optional additional procedure or section with procedure -->
+    <section address="Section1">
+      <title>Optional section title</title>
+      <content>
+        <procedure>
+          <title>Procedure #2</title>
+          <steps class="ordered">
+            <step>
+              <content>
+                <para>First step</para>
+              </content>
+            </step>
+            <step>
+              <content>
+                <para>Second step</para>
+              </content>
+            </step>
+          </steps>
+          <!-- <conclusion>Optional conclusion</conclusion> -->
+        </procedure>
+      </content>
+    </section>
+
+    <!-- Optional next steps info
+    <nextSteps>
+      <content><para>Next steps info goes here</para></content>
+    </nextSteps>
+    -->
+
+    <relatedTopics>
+      <!-- One or more of the following:
+           - A local link
+           - An external link
+           - A code entity reference
+
+      <link xlink:href="Other Topic's ID">Link text</link>
+      <externalLink>
+          <linkText>Link text</linkText>
+          <linkAlternateText>Optional alternate link text</linkAlternateText>
+          <linkUri>URI</linkUri>
+      </externalLink>
+      <codeEntityReference>API member ID</codeEntityReference>
+
+      Examples:
+
+      <link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
+
+      <externalLink>
+          <linkText>SHFB on CodePlex</linkText>
+          <linkAlternateText>Go to CodePlex</linkAlternateText>
+          <linkUri>http://shfb.codeplex.com</linkUri>
+      </externalLink>
+
+      <codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
+      <codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
+      <codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
+      <codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
+      <codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
+      <codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
+      <codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
+      -->
+    </relatedTopics>
+  </developerWalkthroughDocument>
+</topic>

+ 7 - 49
src/MoonSharp.Documentation/Content/Welcome.aml

@@ -2,54 +2,12 @@
 <topic id="06af6655-1018-45a9-9efb-b6a42cb4a88a" revisionNumber="1">
 <topic id="06af6655-1018-45a9-9efb-b6a42cb4a88a" revisionNumber="1">
 	<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
 	<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
 		<introduction>
 		<introduction>
-			<para>This is a sample conceptual topic.  You can use this as a starting point for adding more conceptual
-content to your help project.</para>
-		</introduction>
-
-		<section>
-			<title>Getting Started</title>
-			<content>
-				<para>To get started, add a documentation source to the project (a Visual Studio solution, project, or
-assembly and XML comments file).  See the <legacyBold>Getting Started</legacyBold> topics in the Sandcastle Help
-File Builder's help file for more information.  The following default items are included in this project:</para>
-
-				<list class="bullet">
-					<listItem>
-						<para><localUri>ContentLayout.content</localUri> - Use the content layout file to manage the
-conceptual content in the project and define its layout in the table of contents.</para>
-					</listItem>
-
-					<listItem>
-						<para>The <localUri>.\Media</localUri> folder - Place images in this folder that you will reference
-from conceptual content using <codeInline>medialLink</codeInline> or <codeInline>mediaLinkInline</codeInline>
-elements.  If you will not have any images in the file, you may remove this folder.</para>
-					</listItem>
-
-					<listItem>
-						<para>The <localUri>.\icons</localUri> folder - This contains a default logo for the help file.  You
-may replace it or remove it and the folder if not wanted.  If removed or if you change the file name, update
-the <ui>Transform Args</ui> project properties page by removing or changing the filename in the
-<codeInline>logoFile</codeInline> transform argument.  Note that unlike images referenced from conceptual topics,
-the logo file should have its <legacyBold>BuildAction</legacyBold> property set to <codeInline>Content</codeInline>.</para>
-					</listItem>
-
-					<listItem>
-						<para>The <localUri>.\Content</localUri> folder - Use this to store your conceptual topics.  You may
-name the files and organize them however you like.  One suggestion is to lay the files out on disk as you have
-them in the content layout file as shown in this project but the choice is yours.  Files can be added via the
-Solution Explorer or from within the content layout file editor.  Files must appear in the content layout file
-in order to be compiled into the help file.</para>
-					</listItem>
-				</list>
-
-				<para>See the <legacyBold>Conceptual Content</legacyBold> topics in the Sandcastle Help File Builder's
-help file for more information.  See the <legacyBold> Sandcastle MAML Guide</legacyBold> for details on Microsoft
-Assistance Markup Language (MAML) which is used to create these topics.</para>
-			</content>
-		</section>
-
-		<relatedTopics>
-			<link xlink:href="d36746c2-215f-4887-8f5b-488ef91019fc" />
-		</relatedTopics>
+      <para>This is the API reference for the MoonSharp.Interpreter assembly.</para>
+      <para>To get started, please visit <externalLink>
+        <linkText>the Moon# homepage</linkText>
+        <linkAlternateText>Moon# homepage</linkAlternateText>
+        <linkUri>http://www.moonsharp.org</linkUri>
+      </externalLink>.</para>
+    </introduction>
 	</developerConceptualDocument>
 	</developerConceptualDocument>
 </topic>
 </topic>

+ 1 - 15
src/MoonSharp.Documentation/ContentLayout.content

@@ -1,18 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <Topics>
 <Topics>
-  <Topic id="06af6655-1018-45a9-9efb-b6a42cb4a88a" visible="True" isDefault="true" isSelected="true" title="Welcome to the [TODO: Add project name]">
-    <HelpKeywords>
-      <HelpKeyword index="K" term="Welcome" />
-    </HelpKeywords>
-  </Topic>
-  <Topic id="d36746c2-215f-4887-8f5b-488ef91019fc" visible="True" isExpanded="true" title="Version History">
-    <HelpKeywords>
-      <HelpKeyword index="K" term="version, history" />
-    </HelpKeywords>
-    <Topic id="65b44451-a743-4eb6-a826-c04453ecd3cb" visible="True" title="Version 1.0.0.0">
-      <HelpKeywords>
-        <HelpKeyword index="K" term="version, 1.0.0.0" />
-      </HelpKeywords>
-    </Topic>
-  </Topic>
+  <Topic id="06af6655-1018-45a9-9efb-b6a42cb4a88a" visible="True" isDefault="true" isSelected="true" title="Moon#" tocTitle="Moon#" linkText="http://www.moonsharp.org" />
 </Topics>
 </Topics>

+ 14 - 1
src/MoonSharp.Documentation/MoonSharp.Documentation.shfbproj

@@ -15,7 +15,7 @@
     <!-- SHFB properties -->
     <!-- SHFB properties -->
     <FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
     <FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
     <OutputPath>.\Help\</OutputPath>
     <OutputPath>.\Help\</OutputPath>
-    <HtmlHelpName>MoonSharp.Documentation</HtmlHelpName>
+    <HtmlHelpName>MoonSharp.Reference.Documentation</HtmlHelpName>
     <Language>en-US</Language>
     <Language>en-US</Language>
     <TransformComponentArguments>
     <TransformComponentArguments>
       <Argument Key="logoFile" Value="Help.png" xmlns="" />
       <Argument Key="logoFile" Value="Help.png" xmlns="" />
@@ -37,6 +37,18 @@
       <DocumentationSource sourceFile="..\MoonSharp.Interpreter\bin\Release\MoonSharp.Interpreter.dll" xmlns="" />
       <DocumentationSource sourceFile="..\MoonSharp.Interpreter\bin\Release\MoonSharp.Interpreter.dll" xmlns="" />
       <DocumentationSource sourceFile="..\MoonSharp.Interpreter\bin\Release\MoonSharp.Interpreter.xml" xmlns="" />
       <DocumentationSource sourceFile="..\MoonSharp.Interpreter\bin\Release\MoonSharp.Interpreter.xml" xmlns="" />
     </DocumentationSources>
     </DocumentationSources>
+    <MaximumGroupParts>2</MaximumGroupParts>
+    <NamespaceGrouping>False</NamespaceGrouping>
+    <SyntaxFilters>Standard</SyntaxFilters>
+    <SdkLinkTarget>Blank</SdkLinkTarget>
+    <RootNamespaceContainer>False</RootNamespaceContainer>
+    <PresentationStyle>VS2013</PresentationStyle>
+    <Preliminary>False</Preliminary>
+    <NamingMethod>Guid</NamingMethod>
+    <HelpTitle>Moon# Reference Guide</HelpTitle>
+    <ContentPlacement>AboveNamespaces</ContentPlacement>
+    <FeedbackEMailLinkText>info%40moonsharp.org</FeedbackEMailLinkText>
+    <FeedbackEMailAddress>info%40moonsharp.org</FeedbackEMailAddress>
   </PropertyGroup>
   </PropertyGroup>
   <!-- There are no properties for these groups.  AnyCPU needs to appear in order for Visual Studio to perform
   <!-- There are no properties for these groups.  AnyCPU needs to appear in order for Visual Studio to perform
 			 the build.  The others are optional common platform types that may appear. -->
 			 the build.  The others are optional common platform types that may appear. -->
@@ -65,6 +77,7 @@
   <ItemGroup>
   <ItemGroup>
     <None Include="Content\VersionHistory\v1.0.0.0.aml" />
     <None Include="Content\VersionHistory\v1.0.0.0.aml" />
     <None Include="Content\VersionHistory\VersionHistory.aml" />
     <None Include="Content\VersionHistory\VersionHistory.aml" />
+    <None Include="Content\Walkthrough.aml" />
     <None Include="Content\Welcome.aml" />
     <None Include="Content\Welcome.aml" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 42 - 5
src/MoonSharp.Interpreter/DataTypes/CallbackArguments.cs

@@ -5,38 +5,75 @@ using System.Text;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// This class is a container for arguments received by a CallbackFunction
+	/// </summary>
 	public class CallbackArguments
 	public class CallbackArguments
 	{
 	{
 		IList<DynValue> m_Args;
 		IList<DynValue> m_Args;
 
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="CallbackArguments"/> class.
+		/// </summary>
+		/// <param name="args">The arguments.</param>
 		public CallbackArguments(IList<DynValue> args)
 		public CallbackArguments(IList<DynValue> args)
 		{
 		{
 			m_Args = args;
 			m_Args = args;
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the count of arguments
+		/// </summary>
 		public int Count
 		public int Count
 		{
 		{
 			get { return m_Args.Count; }
 			get { return m_Args.Count; }
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the <see cref="DynValue"/> at the specified index, or Nil if not found (mimicing Lua behavior)
+		/// </summary>
 		public DynValue this[int index]
 		public DynValue this[int index]
 		{
 		{
-			get 
+			get
 			{
 			{
-				if (index < m_Args.Count)
-					return m_Args[index];
-
-				return DynValue.Nil;
+				return RawGet(index) ?? DynValue.Nil;
 			}
 			}
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the <see cref="DynValue"/> at the specified index, or null.
+		/// </summary>
+		public DynValue RawGet(int index)
+		{
+			if (index < m_Args.Count)
+				return m_Args[index];
+
+			return null;
+		}
+
+
+		/// <summary>
+		/// Gets the list of arguments
+		/// </summary>
 		public IList<DynValue> List { get { return m_Args; } }
 		public IList<DynValue> List { get { return m_Args; } }
 
 
+		/// <summary>
+		/// Converts the arguments to an array
+		/// </summary>
 		public DynValue[] ToArray()
 		public DynValue[] ToArray()
 		{
 		{
 			return List.ToArray();
 			return List.ToArray();
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the specified argument as as an argument of the specified type. If not possible,
+		/// an exception is raised.
+		/// </summary>
+		/// <param name="argNum">The argument number.</param>
+		/// <param name="funcName">Name of the function.</param>
+		/// <param name="type">The type desired.</param>
+		/// <param name="allowNil">if set to <c>true</c> nil values are allowed.</param>
+		/// <returns></returns>
 		public DynValue AsType(int argNum, string funcName, DataType type, bool allowNil = false)
 		public DynValue AsType(int argNum, string funcName, DataType type, bool allowNil = false)
 		{
 		{
 			if (allowNil && this[argNum].Type == DataType.Nil)
 			if (allowNil && this[argNum].Type == DataType.Nil)

+ 45 - 1
src/MoonSharp.Interpreter/DataTypes/CallbackFunction.cs

@@ -7,22 +7,41 @@ using MoonSharp.Interpreter.Interop;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// This class wraps 
+	/// </summary>
 	public sealed class CallbackFunction
 	public sealed class CallbackFunction
 	{
 	{
 		Func<ScriptExecutionContext, CallbackArguments, DynValue> m_CallBack;
 		Func<ScriptExecutionContext, CallbackArguments, DynValue> m_CallBack;
-		public Table Closure { get; set; }
 		private static InteropAccessMode m_DefaultAccessMode = InteropAccessMode.LazyOptimized;
 		private static InteropAccessMode m_DefaultAccessMode = InteropAccessMode.LazyOptimized;
 
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="CallbackFunction"/> class.
+		/// </summary>
+		/// <param name="callBack">The callback function to be called.</param>
 		public CallbackFunction(Func<ScriptExecutionContext, CallbackArguments, DynValue> callBack)
 		public CallbackFunction(Func<ScriptExecutionContext, CallbackArguments, DynValue> callBack)
 		{
 		{
 			m_CallBack = callBack;
 			m_CallBack = callBack;
 		}
 		}
 
 
+		/// <summary>
+		/// Invokes the callback function
+		/// </summary>
+		/// <param name="executionContext">The execution context.</param>
+		/// <param name="args">The arguments.</param>
+		/// <returns></returns>
 		public DynValue Invoke(ScriptExecutionContext executionContext, IList<DynValue> args)
 		public DynValue Invoke(ScriptExecutionContext executionContext, IList<DynValue> args)
 		{
 		{
 			return m_CallBack(executionContext, new  CallbackArguments(args));
 			return m_CallBack(executionContext, new  CallbackArguments(args));
 		}
 		}
 
 
+		/// <summary>
+		/// Gets or sets the default access mode used when marshalling delegates
+		/// </summary>
+		/// <value>
+		/// The default access mode. Default, HideMembers and BackgroundOptimized are NOT supported.
+		/// </value>
+		/// <exception cref="System.ArgumentException">Default, HideMembers and BackgroundOptimized are NOT supported.</exception>
 		public static InteropAccessMode DefaultAccessMode
 		public static InteropAccessMode DefaultAccessMode
 		{
 		{
 			get { return m_DefaultAccessMode; }
 			get { return m_DefaultAccessMode; }
@@ -35,6 +54,13 @@ namespace MoonSharp.Interpreter
 			}
 			}
 		}
 		}
 
 
+		/// <summary>
+		/// Creates a CallbackFunction from a delegate.
+		/// </summary>
+		/// <param name="script">The script.</param>
+		/// <param name="del">The delegate.</param>
+		/// <param name="accessMode">The access mode.</param>
+		/// <returns></returns>
 		public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default)
 		public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default)
 		{
 		{
 			if (accessMode == InteropAccessMode.Default)
 			if (accessMode == InteropAccessMode.Default)
@@ -45,13 +71,31 @@ namespace MoonSharp.Interpreter
 		}
 		}
 
 
 
 
+		/// <summary>
+		/// Creates a CallbackFunction from a MethodInfo relative to a static function.
+		/// </summary>
+		/// <param name="script">The script.</param>
+		/// <param name="mi">The MethodInfo object.</param>
+		/// <param name="accessMode">The access mode.</param>
+		/// <returns></returns>
+		/// <exception cref="System.ArgumentException">The method is not static.</exception>
 		public static CallbackFunction FromMethodInfo(Script script, System.Reflection.MethodInfo mi, InteropAccessMode accessMode = InteropAccessMode.Default)
 		public static CallbackFunction FromMethodInfo(Script script, System.Reflection.MethodInfo mi, InteropAccessMode accessMode = InteropAccessMode.Default)
 		{
 		{
+			if (!mi.IsStatic)
+				throw new ArgumentException("MethodInfo");
+
+
 			if (accessMode == InteropAccessMode.Default)
 			if (accessMode == InteropAccessMode.Default)
 				accessMode = m_DefaultAccessMode;
 				accessMode = m_DefaultAccessMode;
 
 
 			UserDataMethodDescriptor descr = new UserDataMethodDescriptor(mi, accessMode);
 			UserDataMethodDescriptor descr = new UserDataMethodDescriptor(mi, accessMode);
 			return new CallbackFunction(descr.GetCallback(script, null));
 			return new CallbackFunction(descr.GetCallback(script, null));
 		}
 		}
+
+		/// <summary>
+		/// Gets or sets a Table used as additional data to the callback function (available in the execution context).
+		/// </summary>
+		public Table Closure { get; set; }
+
 	}
 	}
 }
 }

+ 25 - 4
src/MoonSharp.Interpreter/DataTypes/Closure.cs

@@ -2,28 +2,49 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
-using MoonSharp.Interpreter.DataTypes;
 using MoonSharp.Interpreter.Execution;
 using MoonSharp.Interpreter.Execution;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// A class representing a script function
+	/// </summary>
 	public class Closure : IScriptPrivateResource
 	public class Closure : IScriptPrivateResource
 	{
 	{
-		public int ByteCodeLocation { get; private set; }
-
+		/// <summary>
+		/// Gets the entry point location in bytecode .
+		/// </summary>
+		public int EntryPointByteCodeLocation { get; private set; }
+
+		/// <summary>
+		/// Gets the ClosureContext for upvalues of this function
+		/// </summary>
 		public ClosureContext ClosureContext { get; private set; }
 		public ClosureContext ClosureContext { get; private set; }
 
 
+		/// <summary>
+		/// Gets the script owning this function
+		/// </summary>
 		public Script OwnerScript { get; private set; }
 		public Script OwnerScript { get; private set; }
 
 
 
 
+		/// <summary>
+		/// Shortcut for an empty closure
+		/// </summary>
 		private static ClosureContext emptyClosure = new ClosureContext();
 		private static ClosureContext emptyClosure = new ClosureContext();
 
 
 
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="Closure"/> class.
+		/// </summary>
+		/// <param name="script">The script.</param>
+		/// <param name="idx">The index.</param>
+		/// <param name="symbols">The symbols.</param>
+		/// <param name="resolvedLocals">The resolved locals.</param>
 		internal Closure(Script script, int idx, SymbolRef[] symbols, IEnumerable<DynValue> resolvedLocals)
 		internal Closure(Script script, int idx, SymbolRef[] symbols, IEnumerable<DynValue> resolvedLocals)
 		{
 		{
 			OwnerScript = script;
 			OwnerScript = script;
 
 
-			ByteCodeLocation = idx;
+			EntryPointByteCodeLocation = idx;
 
 
 			if (symbols.Length > 0)
 			if (symbols.Length > 0)
 				ClosureContext = new ClosureContext(symbols, resolvedLocals);
 				ClosureContext = new ClosureContext(symbols, resolvedLocals);

+ 53 - 1
src/MoonSharp.Interpreter/DataTypes/DataType.cs

@@ -6,34 +6,86 @@ using System.Text;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// Enumeration of possible data types in Moon#
+	/// </summary>
 	public enum DataType
 	public enum DataType
 	{
 	{
-		// standard Lua types
+		/// <summary>
+		/// A nil value, as in Lua
+		/// </summary>
 		Nil,
 		Nil,
+		/// <summary>
+		/// A Lua boolean
+		/// </summary>
 		Boolean,
 		Boolean,
+		/// <summary>
+		/// A Lua number
+		/// </summary>
 		Number,
 		Number,
+		/// <summary>
+		/// A Lua string
+		/// </summary>
 		String,
 		String,
+		/// <summary>
+		/// A Lua function
+		/// </summary>
 		Function,
 		Function,
 
 
+		/// <summary>
+		/// A Lua table
+		/// </summary>
 		Table,
 		Table,
+		/// <summary>
+		/// A set of multiple values
+		/// </summary>
 		Tuple,
 		Tuple,
+		/// <summary>
+		/// A userdata reference - that is a wrapped CLR object
+		/// </summary>
 		UserData,
 		UserData,
+		/// <summary>
+		/// A coroutine handle
+		/// </summary>
 		Thread,
 		Thread,
 
 
+		/// <summary>
+		/// A callback function
+		/// </summary>
 		ClrFunction,
 		ClrFunction,
+		/// <summary>
+		/// A request to execute a tail call
+		/// </summary>
 		TailCallRequest,
 		TailCallRequest,
 
 
+		/// <summary>
+		/// Indicates the maximum index of types supporting metatables
+		/// </summary>
 		MaxMetaTypes = Table
 		MaxMetaTypes = Table
 	}
 	}
 
 
+	/// <summary>
+	/// Extension methods to DataType
+	/// </summary>
 	public static class LuaTypeExtensions
 	public static class LuaTypeExtensions
 	{
 	{
+		/// <summary>
+		/// Determines whether this data type can have type metatables.
+		/// </summary>
+		/// <param name="type">The type.</param>
+		/// <returns></returns>
 		public static bool CanHaveTypeMetatables(this DataType type)
 		public static bool CanHaveTypeMetatables(this DataType type)
 		{
 		{
 			return (int)type < (int)DataType.MaxMetaTypes;
 			return (int)type < (int)DataType.MaxMetaTypes;
 		}
 		}
 
 
 
 
+		/// <summary>
+		/// Converts the DataType to the string returned by the "type(...)" Lua function
+		/// </summary>
+		/// <param name="type">The type.</param>
+		/// <returns></returns>
+		/// <exception cref="ScriptRuntimeException">The DataType is not a Lua type</exception>
 		public static string ToLuaTypeString(this DataType type)
 		public static string ToLuaTypeString(this DataType type)
 		{
 		{
 			switch (type)
 			switch (type)

+ 13 - 4
src/MoonSharp.Interpreter/DataTypes/DynValue.cs

@@ -214,7 +214,7 @@ namespace MoonSharp.Interpreter
 		/// By executing script in this way, a callback function ensures it's not on the stack anymore and thus a number
 		/// 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.
 		/// of functionality (state savings, coroutines, etc) keeps working at full power.
 		/// </summary>
 		/// </summary>
-		/// <param name="tailFn">The data for the tail call.</param>
+		/// <param name="tailCallData">The data for the tail call.</param>
 		/// <returns></returns>
 		/// <returns></returns>
 		public static DynValue NewTailCallReq(TailCallData tailCallData)
 		public static DynValue NewTailCallReq(TailCallData tailCallData)
 		{
 		{
@@ -388,7 +388,7 @@ namespace MoonSharp.Interpreter
 				case DataType.String:
 				case DataType.String:
 					return "\"" + String + "\"";
 					return "\"" + String + "\"";
 				case DataType.Function:
 				case DataType.Function:
-					return string.Format("(Function {0:X8})", Function.ByteCodeLocation);
+					return string.Format("(Function {0:X8})", Function.EntryPointByteCodeLocation);
 				case DataType.ClrFunction:
 				case DataType.ClrFunction:
 					return string.Format("(Function CLR)", Function);
 					return string.Format("(Function CLR)", Function);
 				case DataType.Table:
 				case DataType.Table:
@@ -627,11 +627,20 @@ namespace MoonSharp.Interpreter
 		}
 		}
 
 
 
 
-		public static DynValue FromObject(Script s, object obj)
+		/// <summary>
+		/// Creates a new DynValue from a CLR object
+		/// </summary>
+		/// <param name="script">The script.</param>
+		/// <param name="obj">The object.</param>
+		/// <returns></returns>
+		public static DynValue FromObject(Script script, object obj)
 		{
 		{
-			return MoonSharp.Interpreter.Interop.ConversionHelper.ClrObjectToComplexMoonSharpValue(s, obj);
+			return MoonSharp.Interpreter.Interop.ConversionHelper.ClrObjectToComplexMoonSharpValue(script, obj);
 		}
 		}
 
 
+		/// <summary>
+		/// Converts this Moon# DynValue to a CLR object.
+		/// </summary>
 		public object ToObject()
 		public object ToObject()
 		{
 		{
 			return MoonSharp.Interpreter.Interop.ConversionHelper.MoonSharpValueToClrObject(this);
 			return MoonSharp.Interpreter.Interop.ConversionHelper.MoonSharpValueToClrObject(this);

+ 10 - 1
src/MoonSharp.Interpreter/DataTypes/IScriptPrivateResource.cs

@@ -3,10 +3,19 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
-namespace MoonSharp.Interpreter.DataTypes
+namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// Common interface for all resources which are uniquely bound to a script.
+	/// </summary>
 	public interface IScriptPrivateResource
 	public interface IScriptPrivateResource
 	{
 	{
+		/// <summary>
+		/// Gets the script owning this resource.
+		/// </summary>
+		/// <value>
+		/// The script owning this resource.
+		/// </value>
 		Script OwnerScript { get; }
 		Script OwnerScript { get; }
 	}
 	}
 }
 }

+ 4 - 0
src/MoonSharp.Interpreter/DataTypes/InteropAccessMode.cs

@@ -5,6 +5,10 @@ using System.Text;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// Enumerations of the possible strategies to marshal CLR objects to Moon# userdata and functions.
+	/// See also : <seealso cref="CallbackFunction"/> and <seealso cref="UserData"/> .
+	/// </summary>
 	public enum InteropAccessMode
 	public enum InteropAccessMode
 	{
 	{
 		/// <summary>
 		/// <summary>

+ 69 - 13
src/MoonSharp.Interpreter/DataTypes/Table.cs

@@ -4,11 +4,13 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using MoonSharp.Interpreter.DataStructs;
 using MoonSharp.Interpreter.DataStructs;
-using MoonSharp.Interpreter.DataTypes;
 using MoonSharp.Interpreter.Execution;
 using MoonSharp.Interpreter.Execution;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// A class representing a Lua table.
+	/// </summary>
 	public class Table : IScriptPrivateResource
 	public class Table : IScriptPrivateResource
 	{
 	{
 		readonly LinkedList<TablePair> m_Values;
 		readonly LinkedList<TablePair> m_Values;
@@ -20,6 +22,10 @@ namespace MoonSharp.Interpreter
 		int m_InitArray = 0;
 		int m_InitArray = 0;
 		int m_CachedLength = -1;
 		int m_CachedLength = -1;
 
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="Table"/> class.
+		/// </summary>
+		/// <param name="owner">The owner script.</param>
 		public Table(Script owner)
 		public Table(Script owner)
 		{
 		{
 			m_Values = new LinkedList<TablePair>();
 			m_Values = new LinkedList<TablePair>();
@@ -29,11 +35,17 @@ namespace MoonSharp.Interpreter
 			m_Owner = owner;
 			m_Owner = owner;
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the script owning this resource.
+		/// </summary>
 		public Script OwnerScript
 		public Script OwnerScript
 		{
 		{
 			get { return m_Owner; }
 			get { return m_Owner; }
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the integral key from a double.
+		/// </summary>
 		private int GetIntegralKey(double d)
 		private int GetIntegralKey(double d)
 		{
 		{
 			int v = ((int)d);
 			int v = ((int)d);
@@ -44,6 +56,15 @@ namespace MoonSharp.Interpreter
 			return -1;
 			return -1;
 		}
 		}
 
 
+		/// <summary>
+		/// Gets or sets the <see cref="System.Object"/> with the specified key.
+		/// This will marshall CLR and Moon# objects in the best possible way.
+		/// </summary>
+		/// <value>
+		/// The <see cref="System.Object"/>.
+		/// </value>
+		/// <param name="key">The key.</param>
+		/// <returns></returns>
 		public object this[object key]
 		public object this[object key]
 		{
 		{
 			get
 			get
@@ -72,6 +93,11 @@ namespace MoonSharp.Interpreter
 
 
 
 
 
 
+		/// <summary>
+		/// Sets the value associated to the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <param name="value">The value.</param>
 		public void Set(DynValue key, DynValue value)
 		public void Set(DynValue key, DynValue value)
 		{
 		{
 			if (key.IsNilOrNan())
 			if (key.IsNilOrNan())
@@ -106,6 +132,11 @@ namespace MoonSharp.Interpreter
 				CollectDeadKeys();
 				CollectDeadKeys();
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the value associated with the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <returns></returns>
 		public DynValue Get(DynValue key)
 		public DynValue Get(DynValue key)
 		{
 		{
 			if (key.Type == DataType.Number)
 			if (key.Type == DataType.Number)
@@ -132,6 +163,11 @@ namespace MoonSharp.Interpreter
 			return DynValue.Nil;
 			return DynValue.Nil;
 		}
 		}
 
 
+		/// <summary>
+		///  Sets the value associated to the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <param name="value">The value.</param>
 		public void Set(string key, DynValue value)
 		public void Set(string key, DynValue value)
 		{
 		{
 			CheckValueOwner(value);
 			CheckValueOwner(value);
@@ -140,12 +176,22 @@ namespace MoonSharp.Interpreter
 				CollectDeadKeys();
 				CollectDeadKeys();
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the value associated with the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <returns></returns>
 		public DynValue Get(string key)
 		public DynValue Get(string key)
 		{
 		{
 			return GetValueOrNil(m_StringMap.Find(key));
 			return GetValueOrNil(m_StringMap.Find(key));
 		}
 		}
 
 
 
 
+		/// <summary>
+		/// Gets the value associated with the specified key, without bringing to Nil the non-existant values.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <returns></returns>
 		public DynValue RawGet(string key)
 		public DynValue RawGet(string key)
 		{
 		{
 			var linkedListNode = m_StringMap.Find(key);
 			var linkedListNode = m_StringMap.Find(key);
@@ -156,6 +202,11 @@ namespace MoonSharp.Interpreter
 			return null;
 			return null;
 		}
 		}
 
 
+		/// <summary>
+		/// Sets the value associated to the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <param name="value">The value.</param>
 		public void Set(int key, DynValue value)
 		public void Set(int key, DynValue value)
 		{
 		{
 			CheckValueOwner(value);
 			CheckValueOwner(value);
@@ -169,6 +220,11 @@ namespace MoonSharp.Interpreter
 				m_CachedLength = -1;
 				m_CachedLength = -1;
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the value associated with the specified key.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <returns></returns>
 		public DynValue Get(int key)
 		public DynValue Get(int key)
 		{
 		{
 			return GetValueOrNil(m_ArrayMap.Find(key));
 			return GetValueOrNil(m_ArrayMap.Find(key));
@@ -179,6 +235,9 @@ namespace MoonSharp.Interpreter
 			// +++ value.AssertOwner(m_Owner);
 			// +++ value.AssertOwner(m_Owner);
 		}
 		}
 
 
+		/// <summary>
+		/// Collects the dead keys.
+		/// </summary>
 		private void CollectDeadKeys()
 		private void CollectDeadKeys()
 		{
 		{
 			for (LinkedListNode<TablePair> node = m_Values.First; node != null; node = node.Next)
 			for (LinkedListNode<TablePair> node = m_Values.First; node != null; node = node.Next)
@@ -207,11 +266,10 @@ namespace MoonSharp.Interpreter
 			}
 			}
 		}
 		}
 
 
-		public IEnumerable<TablePair> DebugPairs()
-		{
-			return m_Values;
-		}
 
 
+		/// <summary>
+		/// Returns the next pair from a value
+		/// </summary>
 		public TablePair NextKey(DynValue v)
 		public TablePair NextKey(DynValue v)
 		{
 		{
 			if (v.Type == DataType.Nil)
 			if (v.Type == DataType.Nil)
@@ -249,13 +307,11 @@ namespace MoonSharp.Interpreter
 
 
 			return linkedListNode.Next.Value;
 			return linkedListNode.Next.Value;
 		}
 		}
-		
-		public bool HasStringSymbol(string symbol)
-		{
-			return m_StringMap.ContainsKey(symbol);
-		}
 
 
 
 
+		/// <summary>
+		/// Gets the length of the "array part".
+		/// </summary>
 		public int Length
 		public int Length
 		{
 		{
 			get 
 			get 
@@ -293,14 +349,14 @@ namespace MoonSharp.Interpreter
 
 
 
 
 		/// <summary>
 		/// <summary>
-		/// Enumerates the key value pairs.
+		/// Enumerates the key/value pairs.
 		/// </summary>
 		/// </summary>
 		/// <returns></returns>
 		/// <returns></returns>
-		public IEnumerable<KeyValuePair<DynValue, DynValue>> Pairs
+		public IEnumerable<TablePair> Pairs
 		{
 		{
 			get
 			get
 			{
 			{
-				return m_Values.Select(n => new KeyValuePair<DynValue, DynValue>(n.Key, n.Value));
+				return m_Values.Select(n => new TablePair(n.Key, n.Value));
 			}
 			}
 		}
 		}
 
 

+ 17 - 1
src/MoonSharp.Interpreter/DataTypes/TablePair.cs

@@ -5,18 +5,26 @@ using System.Text;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// A class representing a key/value pair for Table use
+	/// </summary>
 	public struct TablePair
 	public struct TablePair
 	{
 	{
 		private static TablePair s_NilNode = new TablePair(DynValue.Nil, DynValue.Nil);
 		private static TablePair s_NilNode = new TablePair(DynValue.Nil, DynValue.Nil);
-
 		private DynValue key, value;
 		private DynValue key, value;
 
 
+		/// <summary>
+		/// Gets the key.
+		/// </summary>
 		public DynValue Key 
 		public DynValue Key 
 		{
 		{
 			get { return key; }
 			get { return key; }
 			private set { Key = key; }
 			private set { Key = key; }
 		}
 		}
 
 
+		/// <summary>
+		/// Gets or sets the value.
+		/// </summary>
 		public DynValue Value
 		public DynValue Value
 		{
 		{
 			get { return value; }
 			get { return value; }
@@ -24,12 +32,20 @@ namespace MoonSharp.Interpreter
 		}
 		}
 
 
 
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="TablePair"/> struct.
+		/// </summary>
+		/// <param name="key">The key.</param>
+		/// <param name="val">The value.</param>
 		public TablePair(DynValue key, DynValue val) 
 		public TablePair(DynValue key, DynValue val) 
 		{
 		{
 			this.key = key;
 			this.key = key;
 			this.value = val;
 			this.value = val;
 		}
 		}
 
 
+		/// <summary>
+		/// Gets the nil pair
+		/// </summary>
 		public static TablePair Nil { get { return s_NilNode; } }
 		public static TablePair Nil { get { return s_NilNode; } }
 	}
 	}
 }
 }

+ 10 - 0
src/MoonSharp.Interpreter/DataTypes/WellKnownSymbols.cs

@@ -5,9 +5,19 @@ using System.Text;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// Constants of well known "symbols" in the Moon# grammar
+	/// </summary>
 	public static class WellKnownSymbols
 	public static class WellKnownSymbols
 	{
 	{
+		/// <summary>
+		/// The variadic argument symbol ("...")
+		/// </summary>
 		public const string VARARGS = "...";
 		public const string VARARGS = "...";
+
+		/// <summary>
+		/// The environment symbol ("_ENV")
+		/// </summary>
 		public const string ENV = "_ENV";
 		public const string ENV = "_ENV";
 	}
 	}
 }
 }

+ 2 - 2
src/MoonSharp.Interpreter/Execution/VM/Processor/Processor.cs

@@ -42,12 +42,12 @@ namespace MoonSharp.Interpreter.Execution.VM
 			m_ExecutionStack.Push(new CallStackItem()
 			m_ExecutionStack.Push(new CallStackItem()
 			{
 			{
 				BasePointer = m_ValueStack.Count,
 				BasePointer = m_ValueStack.Count,
-				Debug_EntryPoint = function.Function.ByteCodeLocation,
+				Debug_EntryPoint = function.Function.EntryPointByteCodeLocation,
 				ReturnAddress = -1,
 				ReturnAddress = -1,
 				ClosureScope = function.Function.ClosureContext,
 				ClosureScope = function.Function.ClosureContext,
 			});
 			});
 
 
-			return Processing_Loop(function.Function.ByteCodeLocation);
+			return Processing_Loop(function.Function.EntryPointByteCodeLocation);
 		}
 		}
 
 
 
 

+ 2 - 2
src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs

@@ -564,12 +564,12 @@ namespace MoonSharp.Interpreter.Execution.VM
 				{
 				{
 					BasePointer = m_ValueStack.Count,
 					BasePointer = m_ValueStack.Count,
 					ReturnAddress = instructionPtr,
 					ReturnAddress = instructionPtr,
-					Debug_EntryPoint = fn.Function.ByteCodeLocation,
+					Debug_EntryPoint = fn.Function.EntryPointByteCodeLocation,
 					ClosureScope = fn.Function.ClosureContext,
 					ClosureScope = fn.Function.ClosureContext,
 					ErrorHandler = handler,
 					ErrorHandler = handler,
 					Continuation = continuation 
 					Continuation = continuation 
 				});
 				});
-				return fn.Function.ByteCodeLocation;
+				return fn.Function.EntryPointByteCodeLocation;
 			}
 			}
 			else
 			else
 			{
 			{

+ 3 - 0
src/MoonSharp.Interpreter/Interop/ConversionHelper.cs

@@ -85,6 +85,9 @@ namespace MoonSharp.Interpreter.Interop
 
 
 			if (v != null) return v;
 			if (v != null) return v;
 
 
+			if (obj is Closure)
+				return DynValue.NewClosure((Closure)obj);
+
 			if (obj is Delegate)
 			if (obj is Delegate)
 				return DynValue.NewCallback(CallbackFunction.FromDelegate(script, (Delegate)obj));
 				return DynValue.NewCallback(CallbackFunction.FromDelegate(script, (Delegate)obj));
 
 

+ 3 - 3
src/MoonSharp.Interpreter/Interop/EnumerableWrapper.cs

@@ -7,7 +7,7 @@ using MoonSharp.Interpreter.Execution;
 
 
 namespace MoonSharp.Interpreter.Interop
 namespace MoonSharp.Interpreter.Interop
 {
 {
-	public class EnumerableWrapper
+	internal class EnumerableWrapper
 	{
 	{
 		IEnumerator m_Enumerator;
 		IEnumerator m_Enumerator;
 		Script m_Script;
 		Script m_Script;
@@ -63,7 +63,7 @@ namespace MoonSharp.Interpreter.Interop
 			return iterator.GetNext(prev);
 			return iterator.GetNext(prev);
 		}
 		}
 
 
-		public static DynValue ConvertIterator(Script script, IEnumerator enumerator)
+		internal static DynValue ConvertIterator(Script script, IEnumerator enumerator)
 		{
 		{
 			EnumerableWrapper ei = new EnumerableWrapper(script, enumerator);
 			EnumerableWrapper ei = new EnumerableWrapper(script, enumerator);
 
 
@@ -73,7 +73,7 @@ namespace MoonSharp.Interpreter.Interop
 				DynValue.Nil);
 				DynValue.Nil);
 		}
 		}
 
 
-		public static DynValue ConvertTable(Table table)
+		internal static DynValue ConvertTable(Table table)
 		{
 		{
 			return ConvertIterator(table.OwnerScript, table.Values.GetEnumerator());
 			return ConvertIterator(table.OwnerScript, table.Values.GetEnumerator());
 		}
 		}

+ 0 - 1
src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj

@@ -192,7 +192,6 @@
     </Compile>
     </Compile>
     <Compile Include="Tree\Expressions\AdjustmentExpression.cs" />
     <Compile Include="Tree\Expressions\AdjustmentExpression.cs" />
     <Compile Include="Tree\IVariable.cs" />
     <Compile Include="Tree\IVariable.cs" />
-    <Compile Include="MoonSharpInterpreter.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Tree\Expressions\ExprListExpression.cs" />
     <Compile Include="Tree\Expressions\ExprListExpression.cs" />
     <Compile Include="Tree\Expressions\FunctionDefinitionExpression.cs" />
     <Compile Include="Tree\Expressions\FunctionDefinitionExpression.cs" />

+ 0 - 30
src/MoonSharp.Interpreter/MoonSharpInterpreter.cs

@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Antlr4.Runtime;
-using MoonSharp.Interpreter.Diagnostics;
-using MoonSharp.Interpreter.Execution;
-using MoonSharp.Interpreter.Grammar;
-using MoonSharp.Interpreter.Tree;
-using MoonSharp.Interpreter.Tree.Statements;
-
-namespace MoonSharp.Interpreter
-{
-	public static class MoonSharpInterpreter
-	{
-		public enum MoonSharpExecutionProfile
-		{
-			MoonSharp,
-			LuaCompatibility,
-			LuaStrict
-		}
-
-
-		public static void WarmUp()
-		{
-			//LoadFromString("return 1;");
-		}
-	}
-}

+ 2 - 2
src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs

@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
 // set of attributes. Change these attribute values to modify the information
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 // associated with an assembly.
 [assembly: AssemblyTitle("MoonSharp.Interpreter")]
 [assembly: AssemblyTitle("MoonSharp.Interpreter")]
-[assembly: AssemblyDescription("Interpreter for the MoonSharp language")]
+[assembly: AssemblyDescription("Interpreter for the Moon# language")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("http://www.moonsharp.org")]
 [assembly: AssemblyCompany("http://www.moonsharp.org")]
 [assembly: AssemblyProduct("MoonSharp.Interpreter")]
 [assembly: AssemblyProduct("MoonSharp.Interpreter")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.2.0.0")]
+[assembly: AssemblyVersion("0.3.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]

+ 63 - 8
src/MoonSharp.Interpreter/Script.cs

@@ -17,8 +17,7 @@ namespace MoonSharp.Interpreter
 {
 {
 	/// <summary>
 	/// <summary>
 	/// This class implements a Moon# scripting session. Multiple Script objects can coexist in the same program but cannot share
 	/// This class implements a Moon# scripting session. Multiple Script objects can coexist in the same program but cannot share
-	/// data among themselves except through the _UNIVERSE table. Data accessed through the _UNIVERSE table is thread safe, so
-	/// Script objects can execute in different threads with no issue, as long as all their callbacks are aware and compatible.
+	/// data among themselves unless some mechanism is put in place.
 	/// </summary>
 	/// </summary>
 	public class Script
 	public class Script
 	{
 	{
@@ -92,7 +91,10 @@ namespace MoonSharp.Interpreter
 		/// </summary>
 		/// </summary>
 		/// <param name="code">The code.</param>
 		/// <param name="code">The code.</param>
 		/// <param name="globalTable">The global table to bind to this chunk.</param>
 		/// <param name="globalTable">The global table to bind to this chunk.</param>
-		/// <returns>A DynValue containing a function which will execute the loaded code.</returns>
+		/// <param name="funcFriendlyName">Name of the function used to report errors, etc.</param>
+		/// <returns>
+		/// A DynValue containing a function which will execute the loaded code.
+		/// </returns>
 		public DynValue LoadFunction(string code, Table globalTable = null, string funcFriendlyName = null)
 		public DynValue LoadFunction(string code, Table globalTable = null, string funcFriendlyName = null)
 		{
 		{
 			string chunkName = string.Format("<string:{0:X4}>", m_Sources.Count);
 			string chunkName = string.Format("<string:{0:X4}>", m_Sources.Count);
@@ -120,7 +122,10 @@ namespace MoonSharp.Interpreter
 		/// </summary>
 		/// </summary>
 		/// <param name="code">The code.</param>
 		/// <param name="code">The code.</param>
 		/// <param name="globalTable">The global table to bind to this chunk.</param>
 		/// <param name="globalTable">The global table to bind to this chunk.</param>
-		/// <returns>A DynValue containing a function which will execute the loaded code.</returns>
+		/// <param name="codeFriendlyName">Name of the code - used to report errors, etc.</param>
+		/// <returns>
+		/// A DynValue containing a function which will execute the loaded code.
+		/// </returns>
 		public DynValue LoadString(string code, Table globalTable = null, string codeFriendlyName = null)
 		public DynValue LoadString(string code, Table globalTable = null, string codeFriendlyName = null)
 		{
 		{
 			string chunkName = string.Format("<string:{0:X4}>", m_Sources.Count);
 			string chunkName = string.Format("<string:{0:X4}>", m_Sources.Count);
@@ -171,7 +176,6 @@ namespace MoonSharp.Interpreter
 		/// </summary>
 		/// </summary>
 		/// <param name="code">The code.</param>
 		/// <param name="code">The code.</param>
 		/// <param name="globalContext">The global context.</param>
 		/// <param name="globalContext">The global context.</param>
-		/// <param name="coroutine">The coroutine index, or -1 to use the first free (or current) coroutine index.</param>
 		/// <returns>
 		/// <returns>
 		/// A DynValue containing the result of the processing of the loaded chunk.
 		/// A DynValue containing the result of the processing of the loaded chunk.
 		/// </returns>
 		/// </returns>
@@ -186,7 +190,6 @@ namespace MoonSharp.Interpreter
 		/// </summary>
 		/// </summary>
 		/// <param name="filename">The filename.</param>
 		/// <param name="filename">The filename.</param>
 		/// <param name="globalContext">The global context.</param>
 		/// <param name="globalContext">The global context.</param>
-		/// <param name="coroutine">The coroutine index, or -1 to use the first free (or current) coroutine index.</param>
 		/// <returns>
 		/// <returns>
 		/// A DynValue containing the result of the processing of the loaded chunk.
 		/// A DynValue containing the result of the processing of the loaded chunk.
 		/// </returns>
 		/// </returns>
@@ -236,7 +239,16 @@ namespace MoonSharp.Interpreter
 		/// <summary>
 		/// <summary>
 		/// Calls the specified function.
 		/// Calls the specified function.
 		/// </summary>
 		/// </summary>
-		/// <param name="coroutine">The coroutine on which to execute, or -1 to use the first-free (or current) coroutine.</param>
+		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
+		/// <returns></returns>
+		public DynValue Call(DynValue function)
+		{
+			return m_MainRoutine.Call(function, new DynValue[0]);
+		}
+
+		/// <summary>
+		/// Calls the specified function.
+		/// </summary>
 		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
 		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
 		/// <param name="args">The arguments to pass to the function.</param>
 		/// <param name="args">The arguments to pass to the function.</param>
 		/// <returns></returns>
 		/// <returns></returns>
@@ -245,6 +257,39 @@ namespace MoonSharp.Interpreter
 			return m_MainRoutine.Call(function, args);
 			return m_MainRoutine.Call(function, args);
 		}
 		}
 
 
+		/// <summary>
+		/// Calls the specified function.
+		/// </summary>
+		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
+		/// <param name="args">The arguments to pass to the function.</param>
+		/// <returns></returns>
+		public DynValue Call(DynValue function, params object[] args)
+		{
+			return m_MainRoutine.Call(function, args.Select(v => DynValue.FromObject(this, v)).ToArray());
+		}
+
+
+		/// <summary>
+		/// Calls the specified function.
+		/// </summary>
+		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
+		/// <returns></returns>
+		public DynValue Call(object function)
+		{
+			return Call(DynValue.FromObject(this, function));
+		}
+
+		/// <summary>
+		/// Calls the specified function.
+		/// </summary>
+		/// <param name="function">The Lua/Moon# function to be called - callbacks are not supported.</param>
+		/// <param name="args">The arguments to pass to the function.</param>
+		/// <returns></returns>
+		public DynValue Call(object function, params object[] args)
+		{
+			return Call(DynValue.FromObject(this, function), args);
+		}
+
 		/// <summary>
 		/// <summary>
 		/// Gets the main chunk function.
 		/// Gets the main chunk function.
 		/// </summary>
 		/// </summary>
@@ -258,7 +303,6 @@ namespace MoonSharp.Interpreter
 		/// Attaches a debugger.
 		/// Attaches a debugger.
 		/// </summary>
 		/// </summary>
 		/// <param name="debugger">The debugger object.</param>
 		/// <param name="debugger">The debugger object.</param>
-		/// </param>
 		public void AttachDebugger(IDebugger debugger)
 		public void AttachDebugger(IDebugger debugger)
 		{
 		{
 			m_Debugger = debugger;
 			m_Debugger = debugger;
@@ -275,7 +319,9 @@ namespace MoonSharp.Interpreter
 		/// Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html
 		/// Loads a module as per the "require" Lua function. http://www.lua.org/pil/8.1.html
 		/// </summary>
 		/// </summary>
 		/// <param name="modname">The module name</param>
 		/// <param name="modname">The module name</param>
+		/// <param name="globalContext">The global context.</param>
 		/// <returns></returns>
 		/// <returns></returns>
+		/// <exception cref="ScriptRuntimeException">Raised if module is not found</exception>
 		public DynValue RequireModule(string modname, Table globalContext = null)
 		public DynValue RequireModule(string modname, Table globalContext = null)
 		{
 		{
 			Table globals = globalContext ?? m_GlobalTable;
 			Table globals = globalContext ?? m_GlobalTable;
@@ -340,5 +386,14 @@ namespace MoonSharp.Interpreter
 		/// </summary>
 		/// </summary>
 		public Action<string> DebugPrint { get; set; }
 		public Action<string> DebugPrint { get; set; }
 
 
+
+		/// <summary>
+		/// Warms up the parser/lexer structures so that Moon# operations start faster.
+		/// </summary>
+		public static void WarmUp()
+		{
+			Script s = new Script(CoreModules.Basic);
+			s.LoadString("return 1;");
+		}
 	}
 	}
 }
 }

+ 1 - 1
src/PerformanceComparison/PerformanceComparison.csproj

@@ -30,7 +30,7 @@
     <OutputPath>bin\Debug\</OutputPath>
     <OutputPath>bin\Debug\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
+    <WarningLevel>0</WarningLevel>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
     <PlatformTarget>AnyCPU</PlatformTarget>