Selaa lähdekoodia

quick optimizations

Xanathar 11 vuotta sitten
vanhempi
sitoutus
9b60ba87e1

+ 1 - 1
src/MoonSharp.Interpreter/Execution/DataTypes/Closure.cs

@@ -14,7 +14,7 @@ namespace MoonSharp.Interpreter.Execution
 		private static List<RValue> emptyClosure = new List<RValue>();
 
 
-		public Closure(int idx, SymbolRef[] symbols, RuntimeScope scope)
+		public Closure(int idx, LRef[] symbols, RuntimeScope scope)
 		{
 			ByteCodeLocation = idx;
 

+ 2 - 2
src/MoonSharp.Interpreter/Execution/DataTypes/RValue.cs

@@ -24,7 +24,7 @@ namespace MoonSharp.Interpreter.Execution
 		public string String { get; private set; }
 		public bool ReadOnly { get; internal set; }
 
-		internal SymbolRef Symbol { get; private set; }
+		internal LRef Symbol { get; private set; }
 
 
 
@@ -42,7 +42,7 @@ namespace MoonSharp.Interpreter.Execution
 		{
 			Assign(num);
 		}
-		public RValue(SymbolRef symbol)
+		public RValue(LRef symbol)
 		{
 			this.Symbol = symbol;
 			this.Type = DataType.Symbol;

+ 19 - 19
src/MoonSharp.Interpreter/Execution/Scopes/BuildTimeScope.cs

@@ -10,7 +10,7 @@ namespace MoonSharp.Interpreter.Execution
 	{
 		BuildTimeScopeFrame m_GlobalRuntimeScope = new BuildTimeScopeFrame(0, 0, true);
 
-		Dictionary<SymbolRef, RValue> m_PredefinedGlobals = new Dictionary<SymbolRef, RValue>();
+		Dictionary<LRef, RValue> m_PredefinedGlobals = new Dictionary<LRef, RValue>();
 
 		List<BuildTimeScopeFrame> m_Locals = new List<BuildTimeScopeFrame>();
 
@@ -24,7 +24,7 @@ namespace MoonSharp.Interpreter.Execution
 			foreach (var kvp in t.Pairs().Where(e => e.Key.Type == DataType.String))
 			{
 				int idx = m_GlobalRuntimeScope.Define(kvp.Key.String);
-				m_PredefinedGlobals.Add(SymbolRef.Global(kvp.Key.String, idx), kvp.Value);
+				m_PredefinedGlobals.Add(LRef.Global(kvp.Key.String, idx), kvp.Value);
 			}
 
 		}
@@ -64,14 +64,14 @@ namespace MoonSharp.Interpreter.Execution
 
 		RuntimeScopeFrame GetRuntimeFrameFromBuildFrame(BuildTimeScopeFrame frame, bool local)
 		{
-			List<SymbolRef> symbols = new List<SymbolRef>();
+			List<LRef> symbols = new List<LRef>();
 			for (int i = frame.StartIndex; i < frame.MaxIndex; i++)
 			{
-				SymbolRef s;
+				LRef s;
 				if (local)
-					s = SymbolRef.Local(frame.FindRev(i - frame.BaseIndex), i - frame.BaseIndex);
+					s = LRef.Local(frame.FindRev(i - frame.BaseIndex), i - frame.BaseIndex);
 				else
-					s = SymbolRef.Global(frame.FindRev(i - frame.BaseIndex), i - frame.BaseIndex);
+					s = LRef.Global(frame.FindRev(i - frame.BaseIndex), i - frame.BaseIndex);
 
 				symbols.Add(s);
 			}
@@ -88,13 +88,13 @@ namespace MoonSharp.Interpreter.Execution
 			return GetRuntimeFrameFromBuildFrame(frame, true);
 		}
 
-		public SymbolRef Find(string name)
+		public LRef Find(string name)
 		{
 			for (int i = m_Locals.Count - 1; i >= 0; i--)
 			{
 				int idx = m_Locals[i].Find(name);
 				if (idx >= 0)
-					return SymbolRef.Local(name, idx);
+					return LRef.Local(name, idx);
 
 				if (m_Locals[i].Breaking)
 					break;
@@ -112,7 +112,7 @@ namespace MoonSharp.Interpreter.Execution
 					{
 						int idx = m_Locals[i].Find(name);
 						if (idx >= 0)
-							return closure.CreateUpvalue(this, SymbolRef.Local(name, idx));
+							return closure.CreateUpvalue(this, LRef.Local(name, idx));
 
 						if (m_Locals[i].Breaking)
 							break;
@@ -122,39 +122,39 @@ namespace MoonSharp.Interpreter.Execution
 
 			int idxglob = m_GlobalRuntimeScope.Find(name);
 			if (idxglob >= 0)
-				return SymbolRef.Global(name, idxglob);
+				return LRef.Global(name, idxglob);
 
 			// Debug.WriteLine(string.Format("Attempted to find '{0}' failed", name));
-			return SymbolRef.Invalid();
+			return LRef.Invalid();
 		}
 
-		public SymbolRef DefineLocal(string name)
+		public LRef DefineLocal(string name)
 		{
-			var s = SymbolRef.Local(name, m_Locals[m_Locals.Count - 1].Define(name));
+			var s = LRef.Local(name, m_Locals[m_Locals.Count - 1].Define(name));
 			// Debug.WriteLine(string.Format("Define local  : {0}", s));
 			return s;
 		}
 
-		public SymbolRef TryDefineLocal(string name)
+		public LRef TryDefineLocal(string name)
 		{
 			int idx = m_Locals[m_Locals.Count - 1].Find(name);
 
 			if (idx >= 0)
-				return SymbolRef.Local(name, idx);
+				return LRef.Local(name, idx);
 
-			var s = SymbolRef.Local(name, m_Locals[m_Locals.Count - 1].Define(name));
+			var s = LRef.Local(name, m_Locals[m_Locals.Count - 1].Define(name));
 			// Debug.WriteLine(string.Format("Define local : {0}", s));
 			return s;
 		}
 
 
-		public SymbolRef DefineGlobal(string name)
+		public LRef DefineGlobal(string name)
 		{
 			int idxglob = m_GlobalRuntimeScope.Find(name);
 			if (idxglob >= 0)
-				return SymbolRef.Global(name, idxglob);
+				return LRef.Global(name, idxglob);
 
-			var s = SymbolRef.Global(name, m_GlobalRuntimeScope.Define(name));
+			var s = LRef.Global(name, m_GlobalRuntimeScope.Define(name));
 			// Debug.WriteLine(string.Format("Define global : {0}", s));
 			return s;
 		}

+ 1 - 1
src/MoonSharp.Interpreter/Execution/Scopes/IClosureBuilder.cs

@@ -8,7 +8,7 @@ namespace MoonSharp.Interpreter.Execution
 	public interface IClosureBuilder
 	{
 		object UpvalueCreationTag { get; set; }
-		SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol);
+		LRef CreateUpvalue(BuildTimeScope scope, LRef symbol);
 
 	}
 }

+ 1 - 1
src/MoonSharp.Interpreter/Execution/Scopes/SymbolRefType.cs → src/MoonSharp.Interpreter/Execution/Scopes/LRefType.cs

@@ -5,7 +5,7 @@ using System.Text;
 
 namespace MoonSharp.Interpreter.Execution
 {
-	public enum SymbolRefType
+	public enum LRefType
 	{
 		Invalid,
 		Global,

+ 23 - 23
src/MoonSharp.Interpreter/Execution/Scopes/RuntimeScope.cs

@@ -10,7 +10,7 @@ namespace MoonSharp.Interpreter.Execution
 	{
 		List<RValue> m_GlobalScope = new List<RValue>(131072); // start with a 512KB scope stack
 		List<RValue> m_ScopeStack = new List<RValue>(131072); // start with a 512KB scope stack
-		List<SymbolRef> m_DebugStack = new List<SymbolRef>(131072); // start with a 512KB scope stack
+		List<LRef> m_DebugStack = new List<LRef>(131072); // start with a 512KB scope stack
 		List<int> m_LocalBaseIndexes = new List<int>(16384);
 		List<List<RValue>> m_ClosureStack = new List<List<RValue>>();
 		List<RuntimeScopeFrame> m_ScopeFrames = new List<RuntimeScopeFrame>(2048);
@@ -79,77 +79,77 @@ namespace MoonSharp.Interpreter.Execution
 				PopFrame();
 		}
 
-		public RValue Get(SymbolRef symref)
+		public RValue Get(LRef symref)
 		{
-			switch (symref.Type)
+			switch (symref.i_Type)
 			{
-				case SymbolRefType.Global:
+				case LRefType.Global:
 					{
-						return m_GlobalScope[symref.Index] ?? RValue.Nil;
+						return m_GlobalScope[symref.i_Index] ?? RValue.Nil;
 					}
-				case SymbolRefType.Local:
+				case LRefType.Local:
 					{
 						int lastBaseIdx = m_LocalBaseIndexes[m_LocalBaseIndexes.Count - 1];
-						return m_ScopeStack[lastBaseIdx + symref.Index] ?? RValue.Nil;
+						return m_ScopeStack[lastBaseIdx + symref.i_Index] ?? RValue.Nil;
 					}
-				case SymbolRefType.Upvalue:
+				case LRefType.Upvalue:
 					{
 						List<RValue> closureValues = m_ClosureStack.Count > 0 ? m_ClosureStack[m_ClosureStack.Count - 1] : null;
 
 						if (closureValues != null)
 						{
-							return closureValues[symref.Index];
+							return closureValues[symref.i_Index];
 						}
 						else
 						{
-							throw new ScriptRuntimeException(null, "Invalid upvalue at resolution: {0}", symref.Name);
+							throw new ScriptRuntimeException(null, "Invalid upvalue at resolution: {0}", symref.i_Name);
 						}
 					}
-				case SymbolRefType.Invalid:
+				case LRefType.Invalid:
 				default:
 					{
-						throw new ScriptRuntimeException(null, "Invalid value at resolution: {0}", symref.Name);
+						throw new ScriptRuntimeException(null, "Invalid value at resolution: {0}", symref.i_Name);
 					}
 			}
 		}
 
 
-		public void Assign(SymbolRef symref, RValue value)
+		public void Assign(LRef symref, RValue value)
 		{
 			// Debug.WriteLine(string.Format("Assigning {0} = {1}", symref, value));
 
-			switch (symref.Type)
+			switch (symref.i_Type)
 			{
-				case SymbolRefType.Global:
+				case LRefType.Global:
 					{
-						m_GlobalScope[symref.Index] = value.CloneAsWritable();
+						m_GlobalScope[symref.i_Index] = value.CloneAsWritable();
 					}
 					break;
-				case SymbolRefType.Local:
+				case LRefType.Local:
 					{
 						int lastBaseIdx = m_LocalBaseIndexes[m_LocalBaseIndexes.Count - 1];
-						m_ScopeStack[lastBaseIdx + symref.Index].Assign(value);
+						m_ScopeStack[lastBaseIdx + symref.i_Index].Assign(value);
 						//m_ScopeStack[lastBaseIdx + symref.Index] = value.CloneAsWritable();
 					}
 					break;
-				case SymbolRefType.Upvalue:
+				case LRefType.Upvalue:
 					{
 						List<RValue> closureValues = m_ClosureStack.Count > 0 ? m_ClosureStack[m_ClosureStack.Count - 1] : null;
 
 						if (closureValues != null)
 						{
-							closureValues[symref.Index].Assign(value);
+							closureValues[symref.i_Index].Assign(value);
 						}
 						else
 						{
-							throw new ScriptRuntimeException(null, "Invalid upvalue at resolution: {0}", symref.Name);
+							throw new ScriptRuntimeException(null, "Invalid upvalue at resolution: {0}", symref.i_Name);
 						}
 					}
 					break;
-				case SymbolRefType.Invalid:
+				case LRefType.Invalid:
 				default:
 					{
-						throw new ScriptRuntimeException(null, "Invalid value at resolution: {0}", symref.Name);
+						throw new ScriptRuntimeException(null, "Invalid value at resolution: {0}", symref.i_Name);
 					}
 			}
 		}

+ 2 - 2
src/MoonSharp.Interpreter/Execution/Scopes/RuntimeScopeFrame.cs

@@ -7,12 +7,12 @@ namespace MoonSharp.Interpreter.Execution
 {
 	public class RuntimeScopeFrame
 	{
-		public List<SymbolRef> m_DebugSymbols { get; private set;}
+		public List<LRef> m_DebugSymbols { get; private set;}
 		public int Count { get; private set;}
 		public bool RestartOfBase { get; private set; }
 
 
-		public RuntimeScopeFrame(IEnumerable<SymbolRef> symbols, int count, bool restartOfBase)
+		public RuntimeScopeFrame(IEnumerable<LRef> symbols, int count, bool restartOfBase)
 		{
 			m_DebugSymbols = symbols.ToList();
 			Count = count;

+ 0 - 63
src/MoonSharp.Interpreter/Execution/Scopes/SymbolRef.cs

@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MoonSharp.Interpreter.Diagnostics;
-using System.Linq;
-using System.Text;
-
-namespace MoonSharp.Interpreter.Execution
-{
-	public class SymbolRef
-	{
-		public SymbolRefType Type { get; private set; }
-
-		public int Index { get; private set; }
-
-		public string Name { get; private set; }
-
-		public RValue TableRefObject { get; internal set; }
-		public RValue TableRefIndex { get; internal set; }
-
-
-		public static SymbolRef Global(string name, int index)
-		{
-			return new SymbolRef() { Index = index, Type = SymbolRefType.Global, Name = name };
-		}
-
-		public static SymbolRef Local(string name, int index)
-		{
-			return new SymbolRef() { Index = index, Type = SymbolRefType.Local, Name = name };
-		}
-
-		public static SymbolRef Upvalue(string name, int index)
-		{
-			return new SymbolRef() { Index = index, Type = SymbolRefType.Upvalue, Name = name };
-		}
-
-		public static SymbolRef Invalid()
-		{
-			return new SymbolRef() { Index = -1, Type = SymbolRefType.Invalid, Name = "!INV!" };
-		}
-
-		public static SymbolRef ObjIndex(RValue baseObject, RValue indexObject)
-		{
-			return new SymbolRef() { TableRefObject = baseObject, TableRefIndex = indexObject, Type = SymbolRefType.Index };
-		}
-
-		public bool IsValid()
-		{
-			return Index >= 0 && Type !=  SymbolRefType.Invalid;
-		}
-
-		private static void DebugPrint(SymbolRef s)
-		{
-			// Debug.WriteLine(string.Format("Defined: {0}", s));
-		}
-
-		public override string ToString()
-		{
-			return string.Format("{0}[{1}] : {2}", Type, Index, Name);
-		}
-
-
-	}
-}

+ 19 - 12
src/MoonSharp.Interpreter/Execution/VM/Chunk.cs

@@ -1,5 +1,8 @@
-using System;
+#define EMIT_DEBUG_OPS
+
+using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Text;
@@ -80,7 +83,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.Call, NumVal = argCount });
 		}
 
-		public Instruction Load(SymbolRef symref)
+		public Instruction Load(LRef symref)
 		{
 			return Emit(new Instruction() { OpCode = OpCode.Load, Symbol = symref });
 		}
@@ -100,7 +103,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.Store });
 		}
 
-		public Instruction Symbol(SymbolRef symref)
+		public Instruction Symbol(LRef symref)
 		{
 			return Emit(new Instruction() { OpCode = OpCode.Symbol, Symbol = symref });
 		}
@@ -125,14 +128,17 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.Bool });
 		}
 
-		public Instruction Debug(string str)
+		[Conditional("EMIT_DEBUG_OPS")]
+		public void Debug(string str)
 		{
-			return Emit(new Instruction() { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) });
+			Emit(new Instruction() { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) });
 		}
-		public Instruction Debug(Antlr4.Runtime.Tree.IParseTree parseTree)
+
+		[Conditional("EMIT_DEBUG_OPS")]
+		public void Debug(Antlr4.Runtime.Tree.IParseTree parseTree)
 		{
 			string str = parseTree.GetText();
-			return Emit(new Instruction() { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) });
+			Emit(new Instruction() { OpCode = OpCode.Debug, Name = str.Substring(0, Math.Min(32, str.Length)) });
 		}
 
 		public Instruction Enter(RuntimeScopeFrame runtimeScopeFrame)
@@ -150,12 +156,12 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.Exit, Frame = runtimeScopeFrame });
 		}
 
-		public Instruction Closure(SymbolRef[] symbols, int jmpnum)
+		public Instruction Closure(LRef[] symbols, int jmpnum)
 		{
 			return Emit(new Instruction() { OpCode = OpCode.Closure, SymbolList = symbols, NumVal = jmpnum });
 		}
 
-		public Instruction Args(SymbolRef[] symbols)
+		public Instruction Args(LRef[] symbols)
 		{
 			return Emit(new Instruction() { OpCode = OpCode.Args, SymbolList = symbols });
 		}
@@ -175,7 +181,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.ToNum });
 		}
 
-		public Instruction SymStorN(SymbolRef symb)
+		public Instruction SymStorN(LRef symb)
 		{
 			return Emit(new Instruction() { OpCode = OpCode.SymStorN, Symbol = symb });
 		}
@@ -224,9 +230,10 @@ namespace MoonSharp.Interpreter.Execution.VM
 			return Emit(new Instruction() { OpCode = OpCode.IterUpd });
 		}
 
-		public Instruction Reverse(int p)
+		public void Reverse(int p)
 		{
-			return Emit(new Instruction() { OpCode = OpCode.Reverse, NumVal = p });
+			if (p > 1)
+				Emit(new Instruction() { OpCode = OpCode.Reverse, NumVal = p });
 		}
 	}
 }

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

@@ -8,8 +8,8 @@ namespace MoonSharp.Interpreter.Execution.VM
 	public class Instruction
 	{
 		public OpCode OpCode;
-		public SymbolRef Symbol;
-		public SymbolRef[] SymbolList;
+		public LRef Symbol;
+		public LRef[] SymbolList;
 		public string Name;
 		public RValue Value;
 		public int NumVal;

+ 15 - 17
src/MoonSharp.Interpreter/Execution/VM/VmExecutor.cs

@@ -95,17 +95,17 @@ namespace MoonSharp.Interpreter.Execution.VM
 				Instruction i = m_CurChunk.Code[m_InstructionPtr];
 
 
-				if (m_DoDebug)
-				{
-					DebugInterface(i);
-				}
-
-				if (System.Diagnostics.Debugger.IsAttached && m_StepEnabled)
-				{
-					ConsoleKeyInfo cki = Console.ReadKey();
-					if (cki.Key == ConsoleKey.Escape)
-						m_StepEnabled = false;
-				}
+				//if (m_DoDebug)
+				//{
+				//	DebugInterface(i);
+				//}
+
+				//if (System.Diagnostics.Debugger.IsAttached && m_StepEnabled)
+				//{
+				//	ConsoleKeyInfo cki = Console.ReadKey();
+				//	if (cki.Key == ConsoleKey.Escape)
+				//		m_StepEnabled = false;
+				//}
 
 				++m_InstructionPtr;
 
@@ -443,8 +443,6 @@ namespace MoonSharp.Interpreter.Execution.VM
 			for (int i = 0; i < I.SymbolList.Length; i++)
 			{
 				m_Scope.Assign(I.SymbolList[i], m_ValueStack.Peek(i + 1));
-
-				Console.WriteLine("ARGS: {0} <- {1}", I.SymbolList[i], m_ValueStack.Peek(i + 1));
 			}
 		}
 
@@ -621,11 +619,11 @@ namespace MoonSharp.Interpreter.Execution.VM
 		}
 
 
-		private void Internal_Assign(SymbolRef l, RValue r)
+		private void Internal_Assign(LRef l, RValue r)
 		{
-			if (l.Type == SymbolRefType.Index)
+			if (l.i_Type == LRefType.Index)
 			{
-				l.TableRefObject.Table[l.TableRefIndex] = r;
+				l.i_TableRefObject.Table[l.i_TableRefIndex] = r;
 			}
 			else
 			{
@@ -672,7 +670,7 @@ namespace MoonSharp.Interpreter.Execution.VM
 			}
 			else
 			{
-				SymbolRef s = SymbolRef.ObjIndex(baseValue, indexValue);
+				LRef s = LRef.ObjIndex(baseValue, indexValue);
 				m_ValueStack.Push(new RValue(s));
 			}
 		}

+ 2 - 2
src/MoonSharp.Interpreter/MoonSharp.Interpreter.csproj

@@ -72,10 +72,10 @@
     <Compile Include="Execution\Scopes\BuildTimeScope.cs" />
     <Compile Include="Execution\Scopes\BuildTimeScopeFrame.cs" />
     <Compile Include="Execution\Scopes\IClosureBuilder.cs" />
-    <Compile Include="Execution\Scopes\SymbolRefType.cs" />
+    <Compile Include="Execution\Scopes\LRefType.cs" />
     <Compile Include="Execution\Scopes\RuntimeScope.cs" />
     <Compile Include="Execution\Scopes\RuntimeScopeFrame.cs" />
-    <Compile Include="Execution\Scopes\SymbolRef.cs" />
+    <Compile Include="Execution\Scopes\LRef.cs" />
     <Compile Include="Execution\ScriptLoadingContext.cs" />
     <Compile Include="Execution\DataTypes\DataType.cs" />
     <Compile Include="Execution\DataTypes\RValue.cs" />

+ 6 - 6
src/MoonSharp.Interpreter/Tree/Expressions/FunctionDefinitionExpression.cs

@@ -10,10 +10,10 @@ namespace MoonSharp.Interpreter.Tree.Expressions
 {
 	class FunctionDefinitionExpression : Expression, IClosureBuilder
 	{
-		SymbolRef[] m_ParamNames;
+		LRef[] m_ParamNames;
 		Statement m_Statement;
 		RuntimeScopeFrame m_StackFrame;
-		List<SymbolRef> m_Closure = new List<SymbolRef>();
+		List<LRef> m_Closure = new List<LRef>();
 		public object UpvalueCreationTag { get; set; }
 
 		public FunctionDefinitionExpression(LuaParser.AnonfunctiondefContext context, ScriptLoadingContext lcontext, bool pushSelfParam = false)
@@ -21,18 +21,18 @@ namespace MoonSharp.Interpreter.Tree.Expressions
 		{
 		}
 
-		public SymbolRef CreateUpvalue(BuildTimeScope scope, SymbolRef symbol)
+		public LRef CreateUpvalue(BuildTimeScope scope, LRef symbol)
 		{
 			for (int i = 0; i < m_Closure.Count; i++)
 			{
-				if (m_Closure[i].Name == symbol.Name)
+				if (m_Closure[i].i_Name == symbol.i_Name)
 				{
-					return SymbolRef.Upvalue(symbol.Name, i);
+					return LRef.Upvalue(symbol.i_Name, i);
 				}
 			}
 
 			m_Closure.Add(symbol);
-			return SymbolRef.Upvalue(symbol.Name, m_Closure.Count - 1);
+			return LRef.Upvalue(symbol.i_Name, m_Closure.Count - 1);
 		}
 
 		public FunctionDefinitionExpression(LuaParser.FuncbodyContext context, ScriptLoadingContext lcontext, bool pushSelfParam = false)

+ 2 - 2
src/MoonSharp.Interpreter/Tree/Expressions/SymbolRefExpression.cs

@@ -10,7 +10,7 @@ namespace MoonSharp.Interpreter.Tree.Expressions
 {
 	class SymbolRefExpression : Expression, IVariable
 	{
-		SymbolRef m_Ref;
+		LRef m_Ref;
 
 		public SymbolRefExpression(ITerminalNode terminalNode, ScriptLoadingContext lcontext)
 			: base(terminalNode, lcontext)
@@ -29,7 +29,7 @@ namespace MoonSharp.Interpreter.Tree.Expressions
 			RValue v = scope.Get(m_Ref);
 
 			if (v == null)
-				throw new ScriptRuntimeException(this.TreeNode, "Undefined symbol: {0}", m_Ref.Name);
+				throw new ScriptRuntimeException(this.TreeNode, "Undefined symbol: {0}", m_Ref.i_Name);
 
 			return v;
 		}

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Statement.cs

@@ -62,7 +62,7 @@ namespace MoonSharp.Interpreter.Tree
 			return ExecutionFlow.None;
 		}
 
-		protected ExecutionFlow ExecuteStatementInBlockScope(Statement s, RuntimeScope scope, RuntimeScopeFrame stackframe, SymbolRef symb = null, RValue varvalue = null)
+		protected ExecutionFlow ExecuteStatementInBlockScope(Statement s, RuntimeScope scope, RuntimeScopeFrame stackframe, LRef symb = null, RValue varvalue = null)
 		{
 			scope.PushFrame(stackframe);
 

+ 2 - 2
src/MoonSharp.Interpreter/Tree/Statements/ForEachLoopStatement.cs

@@ -11,7 +11,7 @@ namespace MoonSharp.Interpreter.Tree.Statements
 	class ForEachLoopStatement : Statement
 	{
 		RuntimeScopeFrame m_StackFrame;
-		SymbolRef[] m_Names;
+		LRef[] m_Names;
 		Expression m_RValues;
 		Statement m_Block;
 
@@ -58,7 +58,7 @@ namespace MoonSharp.Interpreter.Tree.Statements
 			bc.Enter(m_StackFrame);
 
 			// push all iterating variables - stack : iterator-tuple, iter-var-symbols
-			foreach (SymbolRef s in m_Names)
+			foreach (LRef s in m_Names)
 				bc.Symbol(s);
 
 			// expand the tuple - stack : iterator-tuple, iter-var-symbols, f, var, s

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Statements/ForLoopStatement.cs

@@ -14,7 +14,7 @@ namespace MoonSharp.Interpreter.Tree.Statements
 		//for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end'
 		RuntimeScopeFrame m_StackFrame;
 		Statement m_InnerBlock;
-		SymbolRef m_VarName;
+		LRef m_VarName;
 		Expression m_Start, m_End, m_Step;
 
 		public ForLoopStatement(LuaParser.Stat_forloopContext context, ScriptLoadingContext lcontext)

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Statements/FunctionDefinitionStatement.cs

@@ -10,7 +10,7 @@ namespace MoonSharp.Interpreter.Tree.Statements
 {
 	class FunctionDefinitionStatement : Statement
 	{
-		SymbolRef m_FuncName;
+		LRef m_FuncName;
 		List<string> m_TableAccessors;
 		string m_MethodName;
 

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Statements/LocalAssignmentStatement.cs

@@ -11,7 +11,7 @@ namespace MoonSharp.Interpreter.Tree.Statements
 {
 	class LocalAssignmentStatement : Statement
 	{
-		SymbolRef[] m_Names;
+		LRef[] m_Names;
 		Expression[] m_RValues;
 
 		public LocalAssignmentStatement(LuaParser.Stat_localassignmentContext context, ScriptLoadingContext lcontext)