annotate 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
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 class Box<T>: BoxBase, IGetter<T>, ISetter<T>
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
6 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
7 T m_value;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
8 IBinder<T> m_binder;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
9
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
10 public Box(T value,IBinder<T> binder) {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
11 m_value = value;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
12 m_binder = binder;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
13 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
14
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
15 public override bool IsReference {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
16 get {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
17 return true;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
18 }
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 public override Type HoldingType
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
22 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
23 get { return typeof(T); }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
24 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
25
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
26 #region IGetter implementation
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
27
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
28 public T Get ()
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
29 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
30 return m_value;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
31 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
32
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
33 #endregion
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
34
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
35 #region ISetter implementation
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
36
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
37 public void Set (T value)
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
38 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
39 m_value = value;
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
40 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
41
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
42 #endregion
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
43
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
44 public override T2 Convert<T2> ()
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
45 {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
46 if (m_binder == null)
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
47 throw new ArgumentNullException ();
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
48 return m_binder.Convert<T2> (m_value);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
49 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
50
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
51 public override void Invoke(IBinaryOperation op, BoxBase arg2,Frame frame) {
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
52 op.Invoke (m_value, ((IGetter<T>)arg2).Get (), m_binder, frame);
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
53 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
54 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
55 }
e113095f1de0 initial commit, proof of concept
cin
parents:
diff changeset
56