changeset 0:e113095f1de0

initial commit, proof of concept
author cin
date Wed, 23 Oct 2013 13:24:57 +0400
parents
children 033ebe7432d5
files .hgignore Jint.Experimental/Jint.Experimental.csproj Jint.Experimental/Program.cs Jint.Experimental/Properties/AssemblyInfo.cs Jint.Runtime/AssemblyInfo.cs Jint.Runtime/ClassDescriptor.cs Jint.Runtime/ClassTransition.cs Jint.Runtime/Jint.Runtime.csproj Jint.Runtime/JsObject.cs Jint.Runtime/Main.cs Jint.Runtime/PropertyDescriptor.cs Jint.Runtime/PropertyFlags.cs Jint.Runtime/TransitionAction.cs Jint.Runtime/VM/Box.cs Jint.Runtime/VM/BoxBase.cs Jint.Runtime/VM/DummyConverter.cs Jint.Runtime/VM/Frame.cs Jint.Runtime/VM/IBinder.cs Jint.Runtime/VM/IConverter.cs Jint.Runtime/VM/IGetter.cs Jint.Runtime/VM/IReference.cs Jint.Runtime/VM/ISetter.cs Jint.Runtime/VM/IValueHolder.cs Jint.Runtime/VM/IntegerBinder.cs Jint.Runtime/VM/OpCodes/Add.cs Jint.Runtime/VM/OpCodes/BinaryOp.cs Jint.Runtime/VM/OpCodes/BinaryOperation.cs Jint.Runtime/VM/OpCodes/IBinaryOperation.cs Jint.Runtime/VM/OpCodes/IOpCode.cs Jint.Runtime/VM/OpCodes/IOperation.cs Jint.Runtime/VM/RuntimeContext.cs Jint.sln Jint.suo Jint.userprefs
diffstat 34 files changed, 826 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,5 @@
+syntax: glob
+Jint.Experimental/bin/
+Jint.Experimental/obj/
+Jint.Runtime/bin/
+Jint.Runtime/obj/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Experimental/Jint.Experimental.csproj	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,47 @@
+<?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)' == '' ">x86</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8AC3346E-5A4E-4B8C-A225-E4C47F912730}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Jint.Experimental</RootNamespace>
+    <AssemblyName>Jint.Experimental</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <ProjectReference Include="..\Jint.Runtime\Jint.Runtime.csproj">
+      <Project>{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}</Project>
+      <Name>Jint.Runtime</Name>
+    </ProjectReference>
+  </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Experimental/Program.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,18 @@
+using System;
+using Jint.Runtime.VM;
+
+namespace Jint.Experimental
+{
+	class MainClass
+	{
+		public static void Main (string[] args)
+		{
+			var ticks = Environment.TickCount;
+
+
+
+			Console.WriteLine ("register access: {0} ms", Environment.TickCount - ticks);
+
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Experimental/Properties/AssemblyInfo.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Jint.Experimental")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("sergey")]
+[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.*")]
+
+// 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("")]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/AssemblyInfo.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Jint.Runtime")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("sergey")]
+[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.*")]
+
+// 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("")]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/ClassDescriptor.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+
+
+namespace Jint.Runtime
+{
+	public class ClassDescriptor
+	{
+		int m_classId;
+		
+		Dictionary<string,PropertyDescriptor> m_props = new Dictionary<string, PropertyDescriptor>();
+		
+		
+		public int ClassId {
+			get { return m_classId; }
+		}
+		
+		public ClassDescriptor (int classId)
+		{
+			m_classId = classId;
+		}
+		
+		public bool TryGet (string name, out PropertyDescriptor descriptor)
+		{
+			return m_props.TryGetValue (name, out descriptor);
+		}
+		
+		public void DefineProperty(string name, PropertyDescriptor descriptor) {
+			
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/ClassTransition.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,13 @@
+using System;
+namespace Jint.Runtime
+{
+	public struct ClassTransition
+	{
+		public int classId;
+		
+		public TransitionAction action;
+		
+		public string propertyName;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/Jint.Runtime.csproj	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,65 @@
+<?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)' == '' ">x86</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Jint.Runtime</RootNamespace>
+    <AssemblyName>Jint.Runtime</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>True</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>False</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>True</Externalconsole>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>none</DebugType>
+    <Optimize>True</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>True</Externalconsole>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Main.cs" />
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="VM\Box.cs" />
+    <Compile Include="VM\BoxBase.cs" />
+    <Compile Include="VM\Frame.cs" />
+    <Compile Include="VM\OpCodes\Add.cs" />
+    <Compile Include="VM\ISetter.cs" />
+    <Compile Include="VM\IGetter.cs" />
+    <Compile Include="VM\IBinder.cs" />
+    <Compile Include="VM\IntegerBinder.cs" />
+    <Compile Include="VM\RuntimeContext.cs" />
+    <Compile Include="VM\OpCodes\IOperation.cs" />
+    <Compile Include="VM\OpCodes\IBinaryOperation.cs" />
+    <Compile Include="VM\OpCodes\BinaryOperation.cs" />
+    <Compile Include="VM\IReference.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties>
+        <Deployment.LinuxDeployData generateScript="False" />
+      </Properties>
+    </MonoDevelop>
+  </ProjectExtensions>
+  <ItemGroup>
+    <Folder Include="VM\" />
+    <Folder Include="VM\OpCodes\" />
+  </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/JsObject.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+
+namespace Jint.Runtime
+{
+	public class JsObject
+	{
+		ClassDescriptor m_classDescriptor;
+		List<object> m_data;
+		
+		public JsObject ()
+		{
+		}
+		
+		public object Get (string name)
+		{
+			PropertyDescriptor descriptor;
+			if (m_classDescriptor.TryGet (name, out descriptor))
+				return m_data.Count <= descriptor.index ? null : m_data [descriptor.index];
+			else
+				return null;			
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/Main.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,50 @@
+using System;
+using Jint.Runtime.VM.OpCodes;
+
+namespace Jint.Runtime
+{
+    using VM;
+    using System.IO;
+    class MainClass
+    {
+        public static void Main(string[] args)
+        {
+			var runtime = new RuntimeContext ();
+
+			var frame = new Frame (3,runtime);
+
+			frame.Set (0, 0);
+			frame.Set (1, 1);
+
+			var op = new Add (0,1,0);
+
+			var t = Environment.TickCount;
+
+			for(int i=0; i < 10000000; i++)
+				op.Invoke (frame);
+
+			var res = frame.Get<int> (0);
+
+			Console.WriteLine ("got: {0}, int {1} ms", res, Environment.TickCount - t );
+
+			t = Environment.TickCount;
+
+			object count = 0, inc = 1;
+			for (int i=0; i< 10000000; i++)
+				count = OpAdd(count,inc);
+
+			Console.WriteLine ("reference results: {0}, int {1} ms", count, Environment.TickCount - t );
+        }
+
+		public static object OpAdd(object arg1, object arg2) {
+			if (arg1.GetType () == arg2.GetType ()) {
+				return OpAddIntegers(arg1,arg2);
+			}
+			throw new Exception ();
+		}
+
+		public static object OpAddIntegers(object arg1, object arg2) {
+			return (int)arg1 + (int)arg2;
+		}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/PropertyDescriptor.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,11 @@
+using System;
+namespace Jint.Runtime
+{
+	public struct PropertyDescriptor
+	{
+		public PropertyFlags flags;
+		
+		public int index;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/PropertyFlags.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,14 @@
+using System;
+namespace Jint.Runtime
+{
+	[Flags]
+	public enum PropertyFlags
+	{
+		Read = 0x1,
+		
+		Write = 0x2,
+		
+		Enumerable = 0x4
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/TransitionAction.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,11 @@
+using System;
+namespace Jint.Runtime
+{
+	public enum TransitionAction
+	{
+		DefineProperty,
+		
+		DeleteProperty
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/Box.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,56 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public class Box<T>: BoxBase, IGetter<T>, ISetter<T>
+	{
+		T m_value;
+		IBinder<T> m_binder;
+
+		public Box(T value,IBinder<T> binder) {
+			m_value = value;
+			m_binder = binder;
+		}
+
+		public override bool IsReference {
+			get {
+				return true;
+			}
+		}
+
+        public override Type HoldingType
+        {
+            get { return typeof(T); }
+        }
+
+		#region IGetter implementation
+
+		public T Get ()
+		{
+			return m_value;
+		}
+
+		#endregion
+
+		#region ISetter implementation
+
+		public void Set (T value)
+		{
+			m_value = value;
+		}
+
+		#endregion
+
+		public override T2 Convert<T2> ()
+		{
+			if (m_binder == null)
+				throw new ArgumentNullException ();
+			return m_binder.Convert<T2> (m_value);
+		}
+
+		public override void Invoke(IBinaryOperation op, BoxBase arg2,Frame frame) {
+			op.Invoke (m_value, ((IGetter<T>)arg2).Get (), m_binder, frame);
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/BoxBase.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,15 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public abstract class BoxBase
+	{
+		public abstract bool IsReference { get; }
+        public abstract Type HoldingType { get; }
+		public abstract T Convert<T> ();
+
+		public abstract void Invoke(IBinaryOperation op,BoxBase arg2, Frame frame);
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/DummyConverter.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,19 @@
+using System;
+
+namespace Jint.Runtime
+{
+	public class DummyConverter: IConverter
+	{
+		#region IConverter implementation
+
+		public TDst Convert<TSrc, TDst> (TSrc src)
+		{
+			return (TDst)(object)src;
+		}
+
+		#endregion
+
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/Frame.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,59 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public class Frame
+	{
+		BoxBase[] m_data;
+		RuntimeContext m_runtimeContext;
+
+		public Frame (int size, RuntimeContext runtime)
+		{
+			if (size < 0)
+				throw new ArgumentOutOfRangeException ("size");
+			if (runtime == null)
+				throw new ArgumentNullException ("runtime");
+
+			m_data = new BoxBase[size];
+			m_runtimeContext = runtime;
+		}
+
+		public RuntimeContext Runtime {
+			get { return m_runtimeContext; }
+		}
+
+		public T Get<T> (int index)
+		{
+			var bbox = m_data [index];
+
+			if (bbox == null)
+				return default(T);
+
+			var box = bbox as IGetter<T>;
+			if (box != null)
+				return box.Get();
+			else
+				return bbox.Convert<T>();
+		}
+
+		public void Set<T> (int index, T value)
+		{
+			var bbox = m_data [index];
+			var box = bbox as ISetter<T>;
+			if (box != null)
+				box.Set (value);
+			else
+				m_data [index] = m_runtimeContext.BoxValue(value);
+		}
+
+		public BoxBase GetBox(int index) {
+			return m_data[index];
+		}
+
+		public void SetBox(int index, BoxBase box) {
+			m_data [index] = box;
+		}
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IBinder.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,17 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface IBinder<T>
+	{
+		bool Equals (T arg1, T arg2);
+		int Compare (T arg1, T arg2);
+		T2 Convert<T2> (T arg);
+
+		T OpAdd (T arg1, T arg2);
+		T OpSub (T arg1, T arg2);
+		T OpMul (T arg1, T arg2);
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IConverter.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime
+{
+	public interface IConverter
+	{
+		TDst Convert<TSrc,TDst> (TSrc src);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IGetter.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface IGetter<out T>
+	{
+		T Get();
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IReference.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,9 @@
+using System;
+
+namespace Jint.Runtime
+{
+	public interface IReference
+	{
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/ISetter.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface ISetter<in T>
+	{
+		void Set (T value);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IValueHolder.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,11 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface IValueHolder<T>
+	{
+		T Get<T>();
+		void Set<T>(T value);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/IntegerBinder.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,47 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public class IntegerBinder: IBinder<int>
+	{
+		#region IBinder implementation
+
+
+
+		#endregion
+
+		#region IBinder implementation
+
+		public bool Equals (int arg1, int arg2)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public int Compare (int arg1, int arg2)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public T2 Convert<T2> (int arg)
+		{
+			return (T2)Convert.ChangeType(arg,typeof(T2)) ;
+		}
+		public int OpAdd (int arg1, int arg2)
+		{
+			return arg1 + arg2;
+		}
+
+		public int OpSub (int arg1, int arg2)
+		{
+			return arg1 - arg2;
+		}
+
+		public int OpMul (int arg1, int arg2)
+		{
+			return arg1 * arg2;
+		}
+
+		#endregion
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/Add.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,18 @@
+using System;
+
+namespace Jint.Runtime.VM.OpCodes
+{
+	public class Add: BinaryOperation
+	{
+		public Add(int a1,int a2, int res) : base(a1,a2,res) {
+		}
+
+		#region IBinaryOp implementation
+		public override void Invoke<T> (T arg1, T arg2, IBinder<T> binder, Frame frame)
+		{
+			frame.Set(m_res, binder.OpAdd(arg1,arg2));
+		}
+		#endregion
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/BinaryOp.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,19 @@
+using System;
+
+namespace Jint.Runtime.VM.OpCodes
+{
+	public abstract class BinaryOp: IOpCode
+	{
+		#region IOpCode implementation
+
+		public void Invoke (Frame frame)
+		{
+
+		}
+
+		#endregion
+
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/BinaryOperation.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,44 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public abstract class BinaryOperation: IBinaryOperation
+	{
+		protected int m_arg1;
+		protected int m_arg2;
+		protected int m_res;
+
+		protected BinaryOperation(int arg1, int arg2, int res) {
+			m_arg1 = arg1;
+			m_arg2 = arg2;
+			m_res = res;
+		}
+
+		public virtual void Fallback(BoxBase arg1, BoxBase arg2, Frame frame) {
+			throw new InvalidOperationException ("Unable to perform a binary operation on the specified arguments");
+		}
+
+		#region IBinaryOperation implementation
+
+		public abstract void Invoke<T> (T arg1, T arg2, IBinder<T> binder, Frame frame);
+
+		#endregion
+
+		#region IOperation implementation
+
+		public void Invoke (Frame frame)
+		{
+			var box1 = frame.GetBox (m_arg1);
+			var box2 = frame.GetBox (m_arg2);
+
+			if (box1 != null && box2 != null && box1.HoldingType == box2.HoldingType) {
+				box1.Invoke (this, box2, frame);
+			} else {
+				Fallback (box1, box2, frame);
+			}
+		}
+
+		#endregion
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/IBinaryOperation.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface IBinaryOperation: IOperation
+	{
+		void Invoke<T> (T arg1, T arg2, IBinder<T> binder, Frame frame);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/IOpCode.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime.VM.OpCodes
+{
+	public interface IOpCode
+	{
+		void Invoke (Frame frame);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/OpCodes/IOperation.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,10 @@
+using System;
+
+namespace Jint.Runtime.VM
+{
+	public interface IOperation
+	{
+		void Invoke (Frame frame);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.Runtime/VM/RuntimeContext.cs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace Jint.Runtime.VM
+{
+	public class RuntimeContext
+	{
+		Dictionary<Type,object> m_binders;
+
+		public RuntimeContext ()
+		{
+			m_binders = new Dictionary<Type,object> ();
+			m_binders.Add (typeof(int), new IntegerBinder ());
+		}
+
+		public Box<T> BoxValue<T>(T value) {
+			return new Box<T> (value, GetBinder<T> ());
+		}
+
+		public IBinder<T> GetBinder<T>() {
+			return (IBinder<T>) m_binders [typeof(T)];
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.sln	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,35 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Runtime", "Jint.Runtime\Jint.Runtime.csproj", "{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Experimental", "Jint.Experimental\Jint.Experimental.csproj", "{8AC3346E-5A4E-4B8C-A225-E4C47F912730}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96947B34-64F4-4A7A-B432-19D7B6B36D14}"
+	ProjectSection(SolutionItems) = preProject
+		Performance1.psess = Performance1.psess
+		Performance2.psess = Performance2.psess
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x86 = Debug|x86
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}.Debug|x86.ActiveCfg = Debug|x86
+		{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}.Debug|x86.Build.0 = Debug|x86
+		{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}.Release|x86.ActiveCfg = Release|x86
+		{F3FDE0D1-748F-4DFE-9C1C-D17D7FD4E642}.Release|x86.Build.0 = Release|x86
+		{8AC3346E-5A4E-4B8C-A225-E4C47F912730}.Debug|x86.ActiveCfg = Debug|x86
+		{8AC3346E-5A4E-4B8C-A225-E4C47F912730}.Debug|x86.Build.0 = Debug|x86
+		{8AC3346E-5A4E-4B8C-A225-E4C47F912730}.Release|x86.ActiveCfg = Release|x86
+		{8AC3346E-5A4E-4B8C-A225-E4C47F912730}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = Jint.Runtime\Jint.Runtime.csproj
+	EndGlobalSection
+EndGlobal
Binary file Jint.suo has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jint.userprefs	Wed Oct 23 13:24:57 2013 +0400
@@ -0,0 +1,45 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|x86" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="Jint.Runtime/VM/IntegerBinder.cs">
+    <Files>
+      <File FileName="Jint.Runtime/VM/Frame.cs" Line="35" Column="8" />
+      <File FileName="Jint.Runtime/VM/BoxBase.cs" Line="5" Column="30" />
+      <File FileName="Jint.Runtime/VM/Box.cs" Line="24" Column="19" />
+      <File FileName="Jint.Runtime/VM/IConverter.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/OpCodes/Add.cs" Line="25" Column="24" />
+      <File FileName="Jint.Runtime/VM/OpCodes/IOpCode.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/ISetter.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/IGetter.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/Main.cs" Line="25" Column="4" />
+      <File FileName="Jint.Experimental/Program.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/IBinder.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/IntegerBinder.cs" Line="28" Column="4" />
+      <File FileName="Jint.Runtime/VM/OpCodes/BinaryOp.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/AssemblyInfo.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/RuntimeContext.cs" Line="1" Column="1" />
+      <File FileName="Jint.Runtime/VM/OpCodes/IBinaryOperation.cs" Line="5" Column="35" />
+      <File FileName="Jint.Runtime/VM/OpCodes/IOperation.cs" Line="3" Column="26" />
+      <File FileName="Jint.Runtime/VM/OpCodes/BinaryOperation.cs" Line="36" Column="12" />
+    </Files>
+    <Pads>
+      <Pad Id="ProjectPad">
+        <State expanded="True">
+          <Node name="Jint.Experimental" expanded="True" />
+          <Node name="Jint.Runtime" expanded="True">
+            <Node name="VM" expanded="True">
+              <Node name="OpCodes" expanded="True" />
+              <Node name="IntegerBinder.cs" selected="True" />
+            </Node>
+          </Node>
+        </State>
+      </Pad>
+      <Pad Id="ClassPad">
+        <State expanded="True" selected="True" />
+      </Pad>
+    </Pads>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>
\ No newline at end of file