annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
1 using System;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
2
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
3 namespace Jint.Runtime.VM
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
4 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
5 public abstract class BinaryOperation: IBinaryOperation
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
6 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
7 protected int m_arg1;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
8 protected int m_arg2;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
9 protected int m_res;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
10
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
11 protected BinaryOperation(int arg1, int arg2, int res) {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
12 m_arg1 = arg1;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
13 m_arg2 = arg2;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
14 m_res = res;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
15 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
16
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
17 public virtual void Fallback(BoxBase arg1, BoxBase arg2, Frame frame) {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
18 throw new InvalidOperationException ("Unable to perform a binary operation on the specified arguments");
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
19 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
20
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
21 #region IBinaryOperation implementation
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
22
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
23 public abstract void Invoke<T> (T arg1, T arg2, IBinder<T> binder, Frame frame);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
24
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
25 #endregion
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
26
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
27 #region IOperation implementation
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
28
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
29 public void Invoke (Frame frame)
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
30 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
31 var box1 = frame.GetBox (m_arg1);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
32 var box2 = frame.GetBox (m_arg2);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
33
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
34 if (box1 != null && box2 != null && box1.HoldingType == box2.HoldingType) {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
35 box1.Invoke (this, box2, frame);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
36 } else {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
37 Fallback (box1, box2, frame);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
38 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
39 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
40
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
41 #endregion
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
42 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
43 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
44