Mercurial > pub > Jint1
comparison Jint.Runtime/VM/OpCodes/BinaryOperation.cs @ 0:e113095f1de0
initial commit, proof of concept
author | cin |
---|---|
date | Wed, 23 Oct 2013 13:24:57 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e113095f1de0 |
---|---|
1 using System; | |
2 | |
3 namespace Jint.Runtime.VM | |
4 { | |
5 public abstract class BinaryOperation: IBinaryOperation | |
6 { | |
7 protected int m_arg1; | |
8 protected int m_arg2; | |
9 protected int m_res; | |
10 | |
11 protected BinaryOperation(int arg1, int arg2, int res) { | |
12 m_arg1 = arg1; | |
13 m_arg2 = arg2; | |
14 m_res = res; | |
15 } | |
16 | |
17 public virtual void Fallback(BoxBase arg1, BoxBase arg2, Frame frame) { | |
18 throw new InvalidOperationException ("Unable to perform a binary operation on the specified arguments"); | |
19 } | |
20 | |
21 #region IBinaryOperation implementation | |
22 | |
23 public abstract void Invoke<T> (T arg1, T arg2, IBinder<T> binder, Frame frame); | |
24 | |
25 #endregion | |
26 | |
27 #region IOperation implementation | |
28 | |
29 public void Invoke (Frame frame) | |
30 { | |
31 var box1 = frame.GetBox (m_arg1); | |
32 var box2 = frame.GetBox (m_arg2); | |
33 | |
34 if (box1 != null && box2 != null && box1.HoldingType == box2.HoldingType) { | |
35 box1.Invoke (this, box2, frame); | |
36 } else { | |
37 Fallback (box1, box2, frame); | |
38 } | |
39 } | |
40 | |
41 #endregion | |
42 } | |
43 } | |
44 |