comparison Jint.Runtime/VM/Box.cs @ 0:e113095f1de0

initial commit, proof of concept
author cin
date Wed, 23 Oct 2013 13:24:57 +0400
parents
children aced2ae9957f
comparison
equal deleted inserted replaced
-1:000000000000 0:e113095f1de0
1 using System;
2
3 namespace Jint.Runtime.VM
4 {
5 public class Box<T>: BoxBase, IGetter<T>, ISetter<T>
6 {
7 T m_value;
8 IBinder<T> m_binder;
9
10 public Box(T value,IBinder<T> binder) {
11 m_value = value;
12 m_binder = binder;
13 }
14
15 public override bool IsReference {
16 get {
17 return true;
18 }
19 }
20
21 public override Type HoldingType
22 {
23 get { return typeof(T); }
24 }
25
26 #region IGetter implementation
27
28 public T Get ()
29 {
30 return m_value;
31 }
32
33 #endregion
34
35 #region ISetter implementation
36
37 public void Set (T value)
38 {
39 m_value = value;
40 }
41
42 #endregion
43
44 public override T2 Convert<T2> ()
45 {
46 if (m_binder == null)
47 throw new ArgumentNullException ();
48 return m_binder.Convert<T2> (m_value);
49 }
50
51 public override void Invoke(IBinaryOperation op, BoxBase arg2,Frame frame) {
52 op.Invoke (m_value, ((IGetter<T>)arg2).Get (), m_binder, frame);
53 }
54 }
55 }
56