Răsfoiți Sursa

Debugger changes and Xamarin first support

Xanathar 11 ani în urmă
părinte
comite
9137b62971
38 a modificat fișierele cu 1023 adăugiri și 47 ștergeri
  1. 24 2
      src/Flash/org.moonsharp.debugger.client/src/DebuggerViewLogic.as
  2. 26 4
      src/Flash/org.moonsharp.debugger.client/src/Main.mxml
  3. 1 1
      src/Flash/org.moonsharp.debugger.client/src/Version.as
  4. 7 0
      src/MoonSharp.Debugger/MainForm.cs
  5. 16 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/DynamicTests.cs
  6. 104 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs
  7. 87 15
      src/MoonSharp.Interpreter/DataTypes/Table.cs
  8. 3 1
      src/MoonSharp.Interpreter/Debugging/DebuggerAction.cs
  9. 1 0
      src/MoonSharp.Interpreter/Debugging/IDebugger.cs
  10. 18 4
      src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs
  11. 11 0
      src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs
  12. 1 0
      src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj
  13. 1 1
      src/MoonSharp.Interpreter/Properties/AssemblyInfo.cs
  14. 13 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/Platform.cs
  15. 1 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/Clr2Platform.cs
  16. 1 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/Clr4Platform.cs
  17. 1 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/MonoPlatform.cs
  18. 1 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/UnityPlatform.cs
  19. 1 1
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/UnityWebPlatform.cs
  20. 20 0
      src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/XamarinAndroidPlatform.cs
  21. 3 0
      src/MoonSharp.Interpreter/ScriptOptions.cs
  22. 43 9
      src/MoonSharp.RemoteDebugger/DebugServer.cs
  23. 2 2
      src/MoonSharp.RemoteDebugger/RemoteDebugger.cs
  24. BIN
      src/MoonSharp.RemoteDebugger/Resources/Main.swf
  25. 2 2
      src/MoonSharp/Program.cs
  26. 20 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android.sln
  27. 14 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android.userprefs
  28. 19 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Assets/AboutAssets.txt
  29. 121 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/MainActivity.cs
  30. 5 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Properties/AndroidManifest.xml
  31. 28 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Properties/AssemblyInfo.cs
  32. 44 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/AboutResources.txt
  33. 115 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/Resource.designer.cs
  34. BIN
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/drawable/Icon.png
  35. 16 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/layout/Main.axml
  36. 5 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/values/Strings.xml
  37. 48 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/XamarinLoader.cs
  38. 200 0
      src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/XamarinTestBed_Android.csproj

+ 24 - 2
src/Flash/org.moonsharp.debugger.client/src/DebuggerViewLogic.as

@@ -26,6 +26,8 @@ package
 		
 		
 		private var m_InstructionPtrHighlight : Highlight = null;
 		private var m_InstructionPtrHighlight : Highlight = null;
 		
 		
+		private var m_ErrorRx:String;
+		
 		
 		
 		public function DebuggerViewLogic(view : Main, loaderInfo: LoaderInfo)
 		public function DebuggerViewLogic(view : Main, loaderInfo: LoaderInfo)
 		{
 		{
@@ -128,6 +130,10 @@ package
 			{
 			{
 				refreshBreakpoints(xml);
 				refreshBreakpoints(xml);
 			}
 			}
+			else if (cmd == "error_rx")
+			{
+				m_ErrorRx = xml.@arg;	
+			}
 		}
 		}
 		
 		
 		public function getInstructionPtrHighlight():Highlight
 		public function getInstructionPtrHighlight():Highlight
@@ -264,14 +270,30 @@ package
 		}	
 		}	
 		
 		
 		
 		
-		public function toggleBreakpoint(src:int, line:int, col:int) : void
+		public function toggleBreakpoint(src:int, line:int, col:int, action:String) : void
 		{
 		{
-			var cmd:XML = <Command cmd="breakpoint" arg="toggle" />;
+			var cmd:XML = <Command cmd="breakpoint" />;
+			cmd.@arg = action;
 			cmd.@src = src;
 			cmd.@src = src;
 			cmd.@line = line;
 			cmd.@line = line;
 			cmd.@col = col;
 			cmd.@col = col;
 			m_Socket.send(cmd);		
 			m_Socket.send(cmd);		
 		}	
 		}	
 		
 		
+		public function getErrorRx():String
+		{
+			return m_ErrorRx;	
+		}
+		
+		public function setErrorRx(val:String):void
+		{
+			m_ErrorRx = val;	
+			var cmd:XML = <Command cmd="error_rx" />;
+			cmd.@arg = val;
+			m_Socket.send(cmd);
+		}
+		
+		
+		
 	}
 	}
 }
 }

+ 26 - 4
src/Flash/org.moonsharp.debugger.client/src/Main.mxml

@@ -51,9 +51,14 @@
 						<menuitem label="(R) - Run" data="run" icon="run" />
 						<menuitem label="(R) - Run" data="run" icon="run" />
 						<menuitem label="(P) - Pause" data="pause" icon="pause" />
 						<menuitem label="(P) - Pause" data="pause" icon="pause" />
 						<menuitem type="separator"/>
 						<menuitem type="separator"/>
+						<menuitem label="(G) - Go to current" data="step_current" icon="step_current" />
+					</menuitem>
+					<menuitem label="Breakpoints" data="top">
 						<menuitem label="(B) - Toggle breakpoint" data="breakpoint" icon="breakpoint" />
 						<menuitem label="(B) - Toggle breakpoint" data="breakpoint" icon="breakpoint" />
+						<menuitem label="Set breakpoint" data="set_breakpoint"  />
+						<menuitem label="Clear breakpoint" data="clear_breakpoint"  />
 						<menuitem type="separator"/>
 						<menuitem type="separator"/>
-						<menuitem label="(G) - Go to current" data="step_current" icon="step_current" />
+						<menuitem label="(E) - Errors break regex..." data="error_rx"   />
 					</menuitem>
 					</menuitem>
 					<menuitem label="Watches" data="top">
 					<menuitem label="Watches" data="top">
 						<menuitem label="(Ins) - Add watches..." data="add" icon="add" />
 						<menuitem label="(Ins) - Add watches..." data="add" icon="add" />
@@ -238,7 +243,7 @@
 				event.preventDefault();
 				event.preventDefault();
 			}
 			}
 			
 			
-			protected function toggleBreakpoint() : void
+			protected function toggleBreakpoint(cmdType:String) : void
 			{
 			{
 				if (m_CurrentSrc == null) return;
 				if (m_CurrentSrc == null) return;
 				
 				
@@ -246,7 +251,7 @@
 				var line:int = m_CurrentSrc.inflateLocationLine(cursor);
 				var line:int = m_CurrentSrc.inflateLocationLine(cursor);
 				var col:int = m_CurrentSrc.inflateLocationColumn(cursor, line);
 				var col:int = m_CurrentSrc.inflateLocationColumn(cursor, line);
 				
 				
-				m_Debugger.toggleBreakpoint(m_CurrentSrc.getId(), line, col);
+				m_Debugger.toggleBreakpoint(m_CurrentSrc.getId(), line, col, cmdType);
 			}
 			}
 			
 			
 			protected function moveCaret(where : int) : void
 			protected function moveCaret(where : int) : void
@@ -280,7 +285,24 @@
 				else if (cmd == "run") m_Debugger.run();
 				else if (cmd == "run") m_Debugger.run();
 				else if (cmd == "pause") m_Debugger.pause();
 				else if (cmd == "pause") m_Debugger.pause();
 				else if (cmd == "step_current") refreshInstructionPtrHighlight(true);
 				else if (cmd == "step_current") refreshInstructionPtrHighlight(true);
-				else if (cmd == "breakpoint") toggleBreakpoint();
+				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") 
 				else if (cmd == "add") 
 				{
 				{
 					m_DisableKeys = true;
 					m_DisableKeys = true;

+ 1 - 1
src/Flash/org.moonsharp.debugger.client/src/Version.as

@@ -2,7 +2,7 @@ package
 {
 {
 	public final class Version
 	public final class Version
 	{
 	{
-		public static var Version : String = "0.7.0.2";
+		public static var Version : String = "0.8.0.0";
 		
 		
 		
 		
 		public function Version()
 		public function Version()

+ 7 - 0
src/MoonSharp.Debugger/MainForm.cs

@@ -428,5 +428,12 @@ namespace MoonSharp.Debugger
 		public void RefreshBreakpoints(IEnumerable<SourceRef> refs)
 		public void RefreshBreakpoints(IEnumerable<SourceRef> refs)
 		{
 		{
 		}
 		}
+
+
+		public bool SignalRuntimeException(ScriptRuntimeException ex)
+		{
+			Console_WriteLine("Error: {0}", ex.DecoratedMessage);
+			return true;
+		}
 	}
 	}
 }
 }

+ 16 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/DynamicTests.cs

@@ -85,5 +85,21 @@ namespace MoonSharp.Interpreter.Tests
 			//Assert.AreEqual(6, res.Number);
 			//Assert.AreEqual(6, res.Number);
 		}
 		}
 
 
+		[Test]
+		public void DynamicAccessFromCSharp()
+		{
+			string code = @"
+				t = { ciao = { 'hello' } }
+				";
+
+			Script script = new Script();
+			script.DoString(code);
+
+			DynValue v = script.CreateDynamicExpression("t.ciao[1] .. ' world'").Evaluate();
+
+			Assert.AreEqual(v.String, "hello world");
+		}
+
+
 	}
 	}
 }
 }

+ 104 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs

@@ -340,5 +340,109 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(DataType.Nil, res.Tuple[0].Type);
 			Assert.AreEqual(DataType.Nil, res.Tuple[0].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[1].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();
+			s.DoString(script);
+
+			Assert.AreEqual("hello", s.Globals["t", "ciao", 1]);
+		}
+
+
 	}
 	}
 }
 }

+ 87 - 15
src/MoonSharp.Interpreter/DataTypes/Table.cs

@@ -57,40 +57,112 @@ namespace MoonSharp.Interpreter
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
-		/// Gets or sets the <see cref="System.Object"/> with the specified key.
+		/// Gets or sets the <see cref="System.Object"/> with the specified key(s).
 		/// This will marshall CLR and MoonSharp objects in the best possible way.
 		/// This will marshall CLR and MoonSharp objects in the best possible way.
+		/// Multiple keys can be used to access subtables.
 		/// </summary>
 		/// </summary>
 		/// <value>
 		/// <value>
 		/// The <see cref="System.Object"/>.
 		/// The <see cref="System.Object"/>.
 		/// </value>
 		/// </value>
 		/// <param name="key">The key.</param>
 		/// <param name="key">The key.</param>
 		/// <returns></returns>
 		/// <returns></returns>
-		public object this[object key]
+		public object this[object key, params object[] subkeys]
 		{
 		{
 			get
 			get
 			{
 			{
-				if (key is string)
-					return Get((string)key).ToObject();
-				else if (key is int)
-					return Get((int)key).ToObject();
+				Table t = ResolveMultipleKeys(ref key, subkeys);
+				return t.GetAsObject(key);
+			}
 
 
-				DynValue dynkey = DynValue.FromObject(this.OwnerScript, key);
-				return Get(dynkey).ToObject();
+			set
+			{
+				Table t = ResolveMultipleKeys(ref key, subkeys);
+				t.SetAsObject(key, value);
+			}
+		}
+
+		/// <summary>
+		/// Gets or sets the <see cref="System.Object"/> with the specified key(s).
+		/// This will marshall CLR and MoonSharp 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]
+		{
+			get
+			{
+				return this.GetAsObject(key);
 			}
 			}
 
 
 			set
 			set
 			{
 			{
-				DynValue dynval = DynValue.FromObject(this.OwnerScript, value);
+				this.SetAsObject(key, value);
+			}
+		}
 
 
-				if (key is string)
-					Set((string)key, dynval);
-				else if (key is int)
-					Set((int)key, dynval);
-				else
-					Set(DynValue.FromObject(this.OwnerScript, key), dynval);
+		private Table ResolveMultipleKeys(ref object key, object[] subkeys)
+		{
+			if (subkeys.Length == 0)
+				return this;
+
+			Table t = this;
+			int i = -1;
+
+			do
+			{
+				DynValue vt = t.GetWithObjectKey(key);
+
+				if (vt.Type != DataType.Table)
+					throw new ScriptRuntimeException("Key '{0}' did not point to a table");
+
+				t = vt.Table;
+				key = subkeys[++i];
 			}
 			}
+			while (i < subkeys.Length - 1);
+
+			return t;
+		}
+
+		public DynValue GetWithObjectKey(object key)
+		{
+			if (key is string)
+				return Get((string)key);
+			else if (key is int)
+				return Get((int)key);
+
+			DynValue dynkey = DynValue.FromObject(this.OwnerScript, key);
+			return Get(dynkey);
+		}
+
+
+		public object GetAsObject(object key)
+		{
+			if (key is string)
+				return Get((string)key).ToObject();
+			else if (key is int)
+				return Get((int)key).ToObject();
+
+			DynValue dynkey = DynValue.FromObject(this.OwnerScript, key);
+			return Get(dynkey).ToObject();
 		}
 		}
 
 
+		public void SetAsObject(object key, object value)
+		{
+			DynValue dynval = DynValue.FromObject(this.OwnerScript, value);
+
+			if (key is string)
+				Set((string)key, dynval);
+			else if (key is int)
+				Set((int)key, dynval);
+			else
+				Set(DynValue.FromObject(this.OwnerScript, key), dynval);
+		}
+
+
+
 
 
 
 
 		/// <summary>
 		/// <summary>

+ 3 - 1
src/MoonSharp.Interpreter/Debugging/DebuggerAction.cs

@@ -17,6 +17,8 @@ namespace MoonSharp.Interpreter.Debugging
 			StepOut,
 			StepOut,
 			Run,
 			Run,
 			ToggleBreakpoint,
 			ToggleBreakpoint,
+			SetBreakpoint,
+			ClearBreakpoint,
 			Refresh,
 			Refresh,
 			HardRefresh,
 			HardRefresh,
 			None,
 			None,
@@ -39,7 +41,7 @@ namespace MoonSharp.Interpreter.Debugging
 
 
 		public override string ToString()
 		public override string ToString()
 		{
 		{
-			if (Action == ActionType.ToggleBreakpoint)
+			if (Action == ActionType.ToggleBreakpoint || Action == ActionType.SetBreakpoint || Action == ActionType.ClearBreakpoint)
 			{
 			{
 				return string.Format("{0} {1}:({2},{3})", Action, SourceID, SourceLine, SourceCol);
 				return string.Format("{0} {1}:({2},{3})", Action, SourceID, SourceLine, SourceCol);
 			}
 			}

+ 1 - 0
src/MoonSharp.Interpreter/Debugging/IDebugger.cs

@@ -11,6 +11,7 @@ namespace MoonSharp.Interpreter.Debugging
 		void SetSourceCode(SourceCode sourceCode);
 		void SetSourceCode(SourceCode sourceCode);
 		void SetByteCode(string[] byteCode);
 		void SetByteCode(string[] byteCode);
 		bool IsPauseRequested();
 		bool IsPauseRequested();
+		bool SignalRuntimeException(ScriptRuntimeException ex);
 		DebuggerAction GetAction(int ip, SourceRef sourceref);
 		DebuggerAction GetAction(int ip, SourceRef sourceref);
 		void SignalExecutionEnded();
 		void SignalExecutionEnded();
 		void Update(WatchType watchType, IEnumerable<WatchItem> items);
 		void Update(WatchType watchType, IEnumerable<WatchItem> items);

+ 18 - 4
src/MoonSharp.Interpreter/Execution/VM/Processor/Processor_Debugger.cs

@@ -77,7 +77,15 @@ namespace MoonSharp.Interpreter.Execution.VM
 						m_Debug.DebuggerCurrentActionTarget = -1;
 						m_Debug.DebuggerCurrentActionTarget = -1;
 						return;
 						return;
 					case DebuggerAction.ActionType.ToggleBreakpoint:
 					case DebuggerAction.ActionType.ToggleBreakpoint:
-						ToggleBreakPoint(action);
+						ToggleBreakPoint(action, null);
+						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);
 						RefreshDebugger(true, instructionPtr);
 						break;
 						break;
 					case DebuggerAction.ActionType.Refresh:
 					case DebuggerAction.ActionType.Refresh:
@@ -95,7 +103,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 
 
 
 
 
 
-		private bool ToggleBreakPoint(DebuggerAction action)
+		private bool ToggleBreakPoint(DebuggerAction action, bool? state)
 		{
 		{
 			SourceCode src = m_Script.GetSourceCode(action.SourceID);
 			SourceCode src = m_Script.GetSourceCode(action.SourceID);
 
 
@@ -111,7 +119,10 @@ namespace MoonSharp.Interpreter.Execution.VM
 
 
 					System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on contains", srf, srf.Type));
 					System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on contains", srf, srf.Type));
 
 
-					srf.Breakpoint = !srf.Breakpoint;
+					if (state == null)
+						srf.Breakpoint = !srf.Breakpoint;
+					else
+						srf.Breakpoint = state.Value;
 
 
 					if (srf.Breakpoint)
 					if (srf.Breakpoint)
 					{
 					{
@@ -147,7 +158,10 @@ namespace MoonSharp.Interpreter.Execution.VM
 				{
 				{
 					System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on distance {2}", nearest, nearest.Type, minDistance));
 					System.Diagnostics.Debug.WriteLine(string.Format("BRK: found {0} for {1} on distance {2}", nearest, nearest.Type, minDistance));
 
 
-					nearest.Breakpoint = !nearest.Breakpoint;
+					if (state == null)
+						nearest.Breakpoint = !nearest.Breakpoint;
+					else
+						nearest.Breakpoint = state.Value;
 
 
 					if (nearest.Breakpoint)
 					if (nearest.Breakpoint)
 					{
 					{

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

@@ -234,6 +234,17 @@ namespace MoonSharp.Interpreter.Execution.VM
 
 
 				if (!(ex is ScriptRuntimeException)) throw;
 				if (!(ex is ScriptRuntimeException)) 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++)
 				for (int i = 0; i < m_ExecutionStack.Count; i++)
 				{
 				{
 					var c = m_ExecutionStack.Peek(i);
 					var c = m_ExecutionStack.Peek(i);

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

@@ -208,6 +208,7 @@
     <Compile Include="RuntimeAbstraction\PlatformImplementations\MonoPlatform.cs" />
     <Compile Include="RuntimeAbstraction\PlatformImplementations\MonoPlatform.cs" />
     <Compile Include="RuntimeAbstraction\PlatformImplementations\UnityPlatform.cs" />
     <Compile Include="RuntimeAbstraction\PlatformImplementations\UnityPlatform.cs" />
     <Compile Include="RuntimeAbstraction\PlatformImplementations\UnityWebPlatform.cs" />
     <Compile Include="RuntimeAbstraction\PlatformImplementations\UnityWebPlatform.cs" />
+    <Compile Include="RuntimeAbstraction\PlatformImplementations\XamarinAndroidPlatform.cs" />
     <Compile Include="Script.cs" />
     <Compile Include="Script.cs" />
     <Compile Include="DataTypes\Table.cs" />
     <Compile Include="DataTypes\Table.cs" />
     <Compile Include="Execution\VM\ByteCode.cs" />
     <Compile Include="Execution\VM\ByteCode.cs" />

+ 1 - 1
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("An interpreter for the Lua 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")]

+ 13 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/Platform.cs

@@ -25,7 +25,19 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 				}
 				}
 				else
 				else
 				{
 				{
-					s_Current = new MonoPlatform();
+					bool onXamarinDroid = AppDomain.CurrentDomain
+						.GetAssemblies()
+						.SelectMany(a => a.GetTypes())
+						.Any(t => t.FullName.StartsWith("Android.App."));
+
+					if (onXamarinDroid)
+					{
+						s_Current = new XamarinAndroidPlatform();
+					}
+					else
+					{
+						s_Current = new MonoPlatform();
+					}
 				}
 				}
 			}
 			}
 			else if (onUnity)
 			else if (onUnity)

+ 1 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/Clr2Platform.cs

@@ -9,7 +9,7 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 	{
 	{
 		public override string Name
 		public override string Name
 		{
 		{
-			get { return "Clr2"; }
+			get { return "clr-2"; }
 		}
 		}
 
 
 		public override string GetEnvironmentVariable(string variable)
 		public override string GetEnvironmentVariable(string variable)

+ 1 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/Clr4Platform.cs

@@ -9,7 +9,7 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 	{
 	{
 		public override string Name
 		public override string Name
 		{
 		{
-			get { return "Clr4"; }
+			get { return "clr-4"; }
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/MonoPlatform.cs

@@ -9,7 +9,7 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 	{
 	{
 		public override string Name
 		public override string Name
 		{
 		{
-			get { return "Mono"; }
+			get { return "mono"; }
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/UnityPlatform.cs

@@ -9,7 +9,7 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 	{
 	{
 		public override string Name
 		public override string Name
 		{
 		{
-			get { return "Unity"; }
+			get { return "unity"; }
 		}
 		}
 
 
 
 

+ 1 - 1
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/UnityWebPlatform.cs

@@ -9,7 +9,7 @@ namespace MoonSharp.Interpreter.RuntimeAbstraction
 	{
 	{
 		public override string Name
 		public override string Name
 		{
 		{
-			get { return "UnityWeb"; }
+			get { return "unity-web"; }
 		}
 		}
 
 
 		public override string GetEnvironmentVariable(string variable)
 		public override string GetEnvironmentVariable(string variable)

+ 20 - 0
src/MoonSharp.Interpreter/RuntimeAbstraction/PlatformImplementations/XamarinAndroidPlatform.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MoonSharp.Interpreter.RuntimeAbstraction
+{
+	class XamarinAndroidPlatform : MonoPlatform
+	{
+		public override string Name
+		{
+			get { return "xamarin-android"; }
+		}
+
+		public override CoreModules FilterSupportedCoreModules(CoreModules module)
+		{
+			return module & (~(CoreModules.IO | CoreModules.OS_System));
+		}
+	}
+}

+ 3 - 0
src/MoonSharp.Interpreter/ScriptOptions.cs

@@ -6,6 +6,9 @@ using MoonSharp.Interpreter.Loaders;
 
 
 namespace MoonSharp.Interpreter
 namespace MoonSharp.Interpreter
 {
 {
+	/// <summary>
+	/// This class contains options to customize behaviour of Script objects.
+	/// </summary>
 	public class ScriptOptions
 	public class ScriptOptions
 	{
 	{
 		internal ScriptOptions()
 		internal ScriptOptions()

+ 43 - 9
src/MoonSharp.RemoteDebugger/DebugServer.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading;
 using System.Threading;
 using System.Xml;
 using System.Xml;
 using MoonSharp.Interpreter;
 using MoonSharp.Interpreter;
@@ -26,9 +27,11 @@ namespace MoonSharp.RemoteDebugger
 		bool m_HostBusySent = false;
 		bool m_HostBusySent = false;
 		private bool m_RequestPause = false;
 		private bool m_RequestPause = false;
 		string[] m_CachedWatches = new string[(int)WatchType.MaxValue];
 		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)
+		public DebugServer(string appName, Script script, int port, Utf8TcpServerOptions options, bool freeRunAfterAttach)
 		{
 		{
 			m_AppName = appName;
 			m_AppName = appName;
 
 
@@ -36,6 +39,7 @@ namespace MoonSharp.RemoteDebugger
 			m_Server.Start();
 			m_Server.Start();
 			m_Server.DataReceived += m_Server_DataReceived;
 			m_Server.DataReceived += m_Server_DataReceived;
 			m_Script = script;
 			m_Script = script;
+			m_FreeRunAfterAttach = freeRunAfterAttach;
 		}
 		}
 
 
 		public string AppName { get { return m_AppName; } }
 		public string AppName { get { return m_AppName; } }
@@ -111,9 +115,10 @@ namespace MoonSharp.RemoteDebugger
 				{
 				{
 					xw.Attribute("app", m_AppName)
 					xw.Attribute("app", m_AppName)
 						.Attribute("moonsharpver", Assembly.GetAssembly(typeof(Script)).GetName().Version.ToString());
 						.Attribute("moonsharpver", Assembly.GetAssembly(typeof(Script)).GetName().Version.ToString());
-
 				}
 				}
 			});
 			});
+
+			SendOption("error_rx", m_ErrorRegEx.ToString());
 		}
 		}
 
 
 		public void Update(WatchType watchType, IEnumerable<WatchItem> items)
 		public void Update(WatchType watchType, IEnumerable<WatchItem> items)
@@ -198,6 +203,12 @@ namespace MoonSharp.RemoteDebugger
 		{
 		{
 			try
 			try
 			{
 			{
+				if (m_FreeRunAfterAttach)
+				{
+					m_FreeRunAfterAttach = false;
+					return new DebuggerAction() { Action = DebuggerAction.ActionType.Run };
+				}
+
 				m_InGetActionLoop = true;
 				m_InGetActionLoop = true;
 				m_RequestPause = false;
 				m_RequestPause = false;
 
 
@@ -239,7 +250,8 @@ namespace MoonSharp.RemoteDebugger
 						return da;
 						return da;
 					}
 					}
 
 
-					if (da.Action == DebuggerAction.ActionType.ToggleBreakpoint)
+					if (da.Action == DebuggerAction.ActionType.ToggleBreakpoint || da.Action == DebuggerAction.ActionType.SetBreakpoint
+						|| da.Action == DebuggerAction.ActionType.ClearBreakpoint)
 						return da;
 						return da;
 
 
 					if (da.Age < TimeSpan.FromMilliseconds(100))
 					if (da.Age < TimeSpan.FromMilliseconds(100))
@@ -334,6 +346,10 @@ namespace MoonSharp.RemoteDebugger
 					case "pause":
 					case "pause":
 						m_RequestPause = true;
 						m_RequestPause = true;
 						break;
 						break;
+					case "error_rx":
+						m_ErrorRegEx = new Regex(arg.Trim());
+						SendOption("error_rx", m_ErrorRegEx.ToString());
+						break;
 					case "addwatch":
 					case "addwatch":
 						lock (m_Lock)
 						lock (m_Lock)
 							m_WatchesChanging.UnionWith(arg.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()));
 							m_WatchesChanging.UnionWith(arg.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()));
@@ -351,9 +367,14 @@ namespace MoonSharp.RemoteDebugger
 						QueueRefresh();
 						QueueRefresh();
 						break;
 						break;
 					case "breakpoint":
 					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()
 						QueueAction(new DebuggerAction()
 						{
 						{
-							Action = DebuggerAction.ActionType.ToggleBreakpoint,
+							Action = action,
 							SourceID = int.Parse(xdoc.DocumentElement.GetAttribute("src")),
 							SourceID = int.Parse(xdoc.DocumentElement.GetAttribute("src")),
 							SourceLine = int.Parse(xdoc.DocumentElement.GetAttribute("line")),
 							SourceLine = int.Parse(xdoc.DocumentElement.GetAttribute("line")),
 							SourceCol = int.Parse(xdoc.DocumentElement.GetAttribute("col")),
 							SourceCol = int.Parse(xdoc.DocumentElement.GetAttribute("col")),
@@ -375,6 +396,18 @@ namespace MoonSharp.RemoteDebugger
 			QueueAction(new DebuggerAction() { Action = DebuggerAction.ActionType.HardRefresh });
 			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)
 		private void SendMessage(string text)
 		{
 		{
 			Send(xw =>
 			Send(xw =>
@@ -414,10 +447,11 @@ namespace MoonSharp.RemoteDebugger
 			});
 			});
 		}
 		}
 
 
-
-
-
-
-
+		public bool SignalRuntimeException(ScriptRuntimeException ex)
+		{
+			SendMessage(string.Format("Error: {0}", ex.DecoratedMessage));
+			m_RequestPause = m_ErrorRegEx.IsMatch(ex.Message);
+			return IsPauseRequested();
+		}
 	}
 	}
 }
 }

+ 2 - 2
src/MoonSharp.RemoteDebugger/RemoteDebugger.cs

@@ -58,11 +58,11 @@ namespace MoonSharp.RemoteDebugger
 			}
 			}
 		}
 		}
 
 
-		public void Attach(Script S, string scriptName)
+		public void Attach(Script S, string scriptName, bool freeRunAfterAttach = false)
 		{
 		{
 			lock (m_Lock)
 			lock (m_Lock)
 			{
 			{
-				DebugServer d = new DebugServer(scriptName, S, m_RpcPortMax, m_Options.NetworkOptions);
+				DebugServer d = new DebugServer(scriptName, S, m_RpcPortMax, m_Options.NetworkOptions, freeRunAfterAttach);
 				S.AttachDebugger(d);
 				S.AttachDebugger(d);
 				m_DebugServers.Add(d);
 				m_DebugServers.Add(d);
 			}
 			}

BIN
src/MoonSharp.RemoteDebugger/Resources/Main.swf


+ 2 - 2
src/MoonSharp/Program.cs

@@ -118,7 +118,7 @@ namespace MoonSharp
 			if (p == "debug" && m_Debugger == null)
 			if (p == "debug" && m_Debugger == null)
 			{
 			{
 				m_Debugger = new RemoteDebuggerService();
 				m_Debugger = new RemoteDebuggerService();
-				m_Debugger.Attach(S, "MoonSharp REPL interpreter");
+				m_Debugger.Attach(S, "MoonSharp REPL interpreter", false);
 				Process.Start(m_Debugger.HttpUrlStringLocalHost);
 				Process.Start(m_Debugger.HttpUrlStringLocalHost);
 			}
 			}
 			if (p.StartsWith("run"))
 			if (p.StartsWith("run"))
@@ -128,7 +128,7 @@ namespace MoonSharp
 			}
 			}
 			if (p == "!")
 			if (p == "!")
 			{
 			{
-				//ParseCommand(S, "debug");
+				ParseCommand(S, "debug");
 				ParseCommand(S, @"run c:\temp\test.lua");
 				ParseCommand(S, @"run c:\temp\test.lua");
 			}
 			}
 		}
 		}

+ 20 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android.sln

@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamarinTestBed_Android", "XamarinTestBed_Android\XamarinTestBed_Android.csproj", "{7E437BCC-8483-45C1-8F90-BCE931749061}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{7E437BCC-8483-45C1-8F90-BCE931749061}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7E437BCC-8483-45C1-8F90-BCE931749061}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7E437BCC-8483-45C1-8F90-BCE931749061}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7E437BCC-8483-45C1-8F90-BCE931749061}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = XamarinTestBed_Android\XamarinTestBed_Android.csproj
+	EndGlobalSection
+EndGlobal

+ 14 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android.userprefs

@@ -0,0 +1,14 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" ActiveRuntime="MS.NET" PreferredExecutionTarget="Android.3230994d2d6010bd" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="XamarinTestBed_Android\MainActivity.cs">
+    <Files>
+      <File FileName="XamarinTestBed_Android\MainActivity.cs" Line="22" Column="22" />
+      <File FileName="XamarinTestBed_Android\XamarinLoader.cs" Line="1" Column="1" />
+    </Files>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+  <MonoDevelop.Ide.ItemProperties.XamarinTestBed__Android MonoForAntroid.PreferredDevice="Nexus 4" AndroidDeviceId-Debug="emulator-5554" />
+</Properties>

+ 19 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Assets/AboutAssets.txt

@@ -0,0 +1,19 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories) and given a Build Action of "AndroidAsset".
+
+These files will be deployed with your package and will be accessible using Android's
+AssetManager, like this:
+
+public class ReadAsset : Activity
+{
+	protected override void OnCreate (Bundle bundle)
+	{
+		base.OnCreate (bundle);
+
+		InputStream input = Assets.Open ("my_asset.txt");
+	}
+}
+
+Additionally, some Android functions will automatically load asset files:
+
+Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");

+ 121 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/MainActivity.cs

@@ -0,0 +1,121 @@
+using System;
+
+using Android.App;
+using Android.Content;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+using Android.OS;
+using System.Threading;
+using System.Linq;
+using MoonSharp.Interpreter;
+using MoonSharp.Interpreter.Tests;
+
+namespace XamarinTestBed_Android
+{
+	[Activity (Label = "MoonSharp Xamarin Tests", MainLauncher = true, Icon = "@drawable/icon")]
+	public class MainActivity : Activity
+	{
+		Thread m_Thread;
+		object m_Lock = new object();
+		bool m_LastWasLine = true;
+		TextView textView;
+
+		// Use this for initialization
+		void Start()
+		{
+			Script.DefaultOptions.ScriptLoader = new XamarinLoader (Assets);
+			m_Thread = new Thread(() => DoTests());
+			m_Thread.Name = "Tests";
+			m_Thread.IsBackground = false;
+			m_Thread.Start();
+		}
+
+		void DoTests()
+		{
+			textView.Post (() => textView.Text = "");
+
+			MoonSharp.Interpreter.Tests.TestRunner tr = new MoonSharp.Interpreter.Tests.TestRunner(Log);
+			tr.Test();
+		}
+
+		void Log(TestResult r)
+		{
+			if (r.Type == TestResultType.Fail)
+			{
+				string message = (r.Exception is ScriptRuntimeException) ? ((ScriptRuntimeException)r.Exception).DecoratedMessage : r.Exception.Message;
+
+				// Console_WriteLine("[FAIL] | {0} - {1} - {2}", r.TestName, message, r.Exception);
+				Console_WriteLine("[FAIL] | {0} - {1} ", r.TestName, message);
+			}
+			else if (r.Type == TestResultType.Ok)
+			{
+				Console_Write(".");
+			}
+			else if (r.Type == TestResultType.Skipped)
+			{
+				Console_Write("s");
+			}
+			else
+			{
+				Console_WriteLine("{0}", r.Message);
+			}
+		}
+
+
+		private void Console_Write(string message)
+		{
+			lock (m_Lock)
+			{
+				textView.Post (() => textView.Text += message);
+				m_LastWasLine = false;
+			}
+		}
+
+		private void Console_WriteLine(string message, params object[] args)
+		{
+			lock (m_Lock)
+			{
+				if (!m_LastWasLine)
+				{
+					textView.Post (() => textView.Text += "\n");
+					m_LastWasLine = true;
+				}
+
+				string msg = (string.Format (message, args) + "\n");
+
+				textView.Post (() => textView.Text += msg);
+			}
+		}
+
+		protected override void OnCreate (Bundle bundle)
+		{
+			base.OnCreate (bundle);
+
+
+			bool onXamarin = AppDomain.CurrentDomain
+				.GetAssemblies()
+				.SelectMany(a => a.GetTypes())
+				.Any(t => t.FullName.StartsWith("Android.App."));
+
+
+			System.Diagnostics.Debug.WriteLine (onXamarin ? "FOUND!" : "NOT FOUND! :(");
+
+
+
+			// Set our view from the "main" layout resource
+			SetContentView (Resource.Layout.Main);
+
+			// Get our button from the layout resource,
+			// and attach an event to it
+			Button button = FindViewById<Button> (Resource.Id.myButton);
+			textView = FindViewById<TextView> (Resource.Id.textView1);
+			
+			button.Click += delegate {
+				Start();
+			};
+		}
+	}
+}
+
+

+ 5 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Properties/AndroidManifest.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="XamarinTestBed_Android.XamarinTestBed_Android">
+	<uses-sdk android:targetSdkVersion="11" android:minSdkVersion="11" />
+	<application android:label="XamarinTestBed_Android"></application>
+</manifest>

+ 28 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Properties/AssemblyInfo.cs

@@ -0,0 +1,28 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using Android.App;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("XamarinTestBed_Android")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("Marco.Mastropaolo")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.0")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

+ 44 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/AboutResources.txt

@@ -0,0 +1,44 @@
+Images, layout descriptions, binary blobs and string dictionaries can be included 
+in your application as resource files.  Various Android APIs are designed to 
+operate on the resource IDs instead of dealing with images, strings or binary blobs 
+directly.
+
+For example, a sample Android app that contains a user interface layout (main.axml),
+an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 
+would keep its resources in the "Resources" directory of the application:
+
+Resources/
+    drawable/
+        icon.png
+
+    layout/
+        main.axml
+
+    values/
+        strings.xml
+
+In order to get the build system to recognize Android resources, set the build action to
+"AndroidResource".  The native Android APIs do not operate directly with filenames, but 
+instead operate on resource IDs.  When you compile an Android application that uses resources, 
+the build system will package the resources for distribution and generate a class called "R" 
+(this is an Android convention) that contains the tokens for each one of the resources 
+included. For example, for the above Resources layout, this is what the R class would expose:
+
+public class R {
+    public class drawable {
+        public const int icon = 0x123;
+    }
+
+    public class layout {
+        public const int main = 0x456;
+    }
+
+    public class strings {
+        public const int first_string = 0xabc;
+        public const int second_string = 0xbcd;
+    }
+}
+
+You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 
+to reference the layout/main.axml file, or R.strings.first_string to reference the first 
+string in the dictionary file values/strings.xml.

+ 115 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/Resource.designer.cs

@@ -0,0 +1,115 @@
+#pragma warning disable 1591
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     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.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+[assembly: global::Android.Runtime.ResourceDesignerAttribute("XamarinTestBed_Android.Resource", IsApplication=true)]
+
+namespace XamarinTestBed_Android
+{
+	
+	
+	[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
+	public partial class Resource
+	{
+		
+		static Resource()
+		{
+			global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+		}
+		
+		public static void UpdateIdValues()
+		{
+		}
+		
+		public partial class Attribute
+		{
+			
+			static Attribute()
+			{
+				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+			}
+			
+			private Attribute()
+			{
+			}
+		}
+		
+		public partial class Drawable
+		{
+			
+			// aapt resource value: 0x7f020000
+			public const int Icon = 2130837504;
+			
+			static Drawable()
+			{
+				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+			}
+			
+			private Drawable()
+			{
+			}
+		}
+		
+		public partial class Id
+		{
+			
+			// aapt resource value: 0x7f050000
+			public const int myButton = 2131034112;
+			
+			// aapt resource value: 0x7f050001
+			public const int textView1 = 2131034113;
+			
+			static Id()
+			{
+				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+			}
+			
+			private Id()
+			{
+			}
+		}
+		
+		public partial class Layout
+		{
+			
+			// aapt resource value: 0x7f030000
+			public const int Main = 2130903040;
+			
+			static Layout()
+			{
+				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+			}
+			
+			private Layout()
+			{
+			}
+		}
+		
+		public partial class String
+		{
+			
+			// aapt resource value: 0x7f040001
+			public const int app_name = 2130968577;
+			
+			// aapt resource value: 0x7f040000
+			public const int hello = 2130968576;
+			
+			static String()
+			{
+				global::Android.Runtime.ResourceIdManager.UpdateIdValues();
+			}
+			
+			private String()
+			{
+			}
+		}
+	}
+}
+#pragma warning restore 1591

BIN
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/drawable/Icon.png


+ 16 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/layout/Main.axml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent">
+    <Button
+        android:id="@+id/myButton"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="Start Tests" />
+    <TextView
+        android:text="Ready."
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/textView1" />
+</LinearLayout>

+ 5 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/Resources/values/Strings.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<string name="hello">Hello World, Click Me!</string>
+	<string name="app_name">XamarinTestBed_Android</string>
+</resources>

+ 48 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/XamarinLoader.cs

@@ -0,0 +1,48 @@
+using System;
+using MoonSharp.Interpreter.Loaders;
+using Android.Content.Res;
+using System.IO;
+
+namespace XamarinTestBed_Android
+{
+	public class XamarinLoader : ClassicLuaScriptLoader
+	{
+		AssetManager m_Assets;
+
+		public XamarinLoader (AssetManager assets)
+		{
+			m_Assets = assets;
+		}
+
+		protected override bool FileExists (string file)
+		{
+			try
+			{
+				file = Path.GetFileName(file);
+
+				Stream input = m_Assets.Open (file);
+				input.Close();
+				return true;
+			}
+			catch 
+			{
+				return false;
+			}
+		}
+
+		public override string LoadFile (string file, MoonSharp.Interpreter.Table globalContext)
+		{
+			file = Path.GetFileName(file.Replace('\\', '/'));
+
+			System.Diagnostics.Debug.WriteLine ("Attempting to load " + file);
+
+			using(Stream input = m_Assets.Open (file))
+				using(StreamReader reader = new StreamReader (input))
+					return reader.ReadToEnd();
+		}
+
+
+
+	}
+}
+

+ 200 - 0
src/Xamarin/XamarinTestBed_Android/XamarinTestBed_Android/XamarinTestBed_Android.csproj

@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ProjectGuid>{7E437BCC-8483-45C1-8F90-BCE931749061}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>XamarinTestBed_Android</RootNamespace>
+    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
+    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
+    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
+    <AndroidApplication>True</AndroidApplication>
+    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
+    <AndroidResgenClass>Resource</AndroidResgenClass>
+    <AssemblyName>XamarinTestBed_Android</AssemblyName>
+    <TargetFrameworkVersion>v4.4</TargetFrameworkVersion>
+    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AndroidLinkMode>None</AndroidLinkMode>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Core" />
+    <Reference Include="Mono.Android" />
+    <Reference Include="Antlr4.Runtime.net35">
+      <HintPath>..\..\..\MoonSharpTests\bin\Debug\Antlr4.Runtime.net35.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.framework">
+      <HintPath>..\..\..\MoonSharpTests\bin\Debug\nunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="MoonSharp.Interpreter.Tests">
+      <HintPath>..\..\..\MoonSharpTests\bin\Debug\MoonSharp.Interpreter.Tests.dll</HintPath>
+    </Reference>
+    <Reference Include="MoonSharp.Interpreter">
+      <HintPath>..\..\..\MoonSharpTests\bin\Debug\MoonSharp.Interpreter.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MainActivity.cs" />
+    <Compile Include="Resources\Resource.designer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="XamarinLoader.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\AboutResources.txt" />
+    <None Include="Properties\AndroidManifest.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <AndroidResource Include="Resources\layout\Main.axml" />
+    <AndroidResource Include="Resources\values\Strings.xml" />
+    <AndroidResource Include="Resources\drawable\Icon.png" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
+  <ItemGroup>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\000-sanity.t">
+      <Link>Assets\000-sanity.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\001-if.t">
+      <Link>Assets\001-if.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\002-table.t">
+      <Link>Assets\002-table.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\011-while.t">
+      <Link>Assets\011-while.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\012-repeat.t">
+      <Link>Assets\012-repeat.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\014-fornum.t">
+      <Link>Assets\014-fornum.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\015-forlist.t">
+      <Link>Assets\015-forlist.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\101-boolean.t">
+      <Link>Assets\101-boolean.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\102-function.t">
+      <Link>Assets\102-function.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\103-nil.t">
+      <Link>Assets\103-nil.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\104-number.t">
+      <Link>Assets\104-number.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\105-string.t">
+      <Link>Assets\105-string.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\106-table.t">
+      <Link>Assets\106-table.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\107-thread.t">
+      <Link>Assets\107-thread.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\108-userdata.t">
+      <Link>Assets\108-userdata.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\200-examples.t">
+      <Link>Assets\200-examples.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\201-assign.t">
+      <Link>Assets\201-assign.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\202-expr.t">
+      <Link>Assets\202-expr.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\203-lexico.t">
+      <Link>Assets\203-lexico.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\204-grammar.t">
+      <Link>Assets\204-grammar.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\211-scope.t">
+      <Link>Assets\211-scope.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\212-function.t">
+      <Link>Assets\212-function.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\213-closure.t">
+      <Link>Assets\213-closure.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\214-coroutine.t">
+      <Link>Assets\214-coroutine.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\221-table.t">
+      <Link>Assets\221-table.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\222-constructor.t">
+      <Link>Assets\222-constructor.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\223-iterator.t">
+      <Link>Assets\223-iterator.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\231-metatable.t">
+      <Link>Assets\231-metatable.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\232-object.t">
+      <Link>Assets\232-object.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\301-basic.t">
+      <Link>Assets\301-basic.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\304-string.t">
+      <Link>Assets\304-string.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\305-table.t">
+      <Link>Assets\305-table.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\306-math.t">
+      <Link>Assets\306-math.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\307-bit.t">
+      <Link>Assets\307-bit.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\308-io.t">
+      <Link>Assets\308-io.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\309-os.t">
+      <Link>Assets\309-os.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\310-debug.t">
+      <Link>Assets\310-debug.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\314-regex.t">
+      <Link>Assets\314-regex.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\320-stdin.t">
+      <Link>Assets\320-stdin.t</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\Modules\Test\Builder.lua">
+      <Link>Assets\Builder.lua</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="..\..\..\MoonSharpTests\bin\Debug\TestMore\Modules\Test\More.lua">
+      <Link>Assets\More.lua</Link>
+    </AndroidAsset>
+    <AndroidAsset Include="Assets\AboutAssets.txt" />
+  </ItemGroup>
+</Project>