diff Jint.Runtime/VM2/Machine.cs @ 2:4aed85a1f558

implemented simple vm2
author cin
date Fri, 25 Oct 2013 15:52:16 +0400
parents 033ebe7432d5
children
line wrap: on
line diff
--- a/Jint.Runtime/VM2/Machine.cs	Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/VM2/Machine.cs	Fri Oct 25 15:52:16 2013 +0400
@@ -6,24 +6,36 @@
 	public class Machine
 	{
 		RuntimeContext m_context;
-		Stack<object[]> m_frames;
-		object[] m_frame;
+		//Stack<object[]> m_frames;
+		Box[] m_frame;
 
 
 		public Machine ()
 		{
+			m_context = new RuntimeContext ();
+		}
+
+		public void InitFrame(object[] values) {
+			m_frame = new Box[values.Length];
+			for(int i = 0; i< values.Length; i++)
+				m_frame[i] = m_context.PackValue(values[i]);
 		}
 
 		public void Execute(Instruction[] instructions) {
 			foreach (var op in instructions) {
-
+				m_frame [op.dest].value = m_frame [op.args [0]].impl [(int)op.code](MakeArgs(op.args));
 			}
 		}
 
 		private object[] MakeArgs(int[] regs) {
 			object[] args = new object[regs.Length];
 			for (int i=0; i< regs.Length; i++)
-				args = m_frame [regs [i]];
+				args[i] = m_frame [regs [i]].value;
+			return args;
+		}
+
+		public object Get(int index) {
+			return m_frame [index];
 		}
 	}
 }