annotate Jint.Runtime/VM/RuntimeContext.cs @ 3:aced2ae9957f

temp commit, new virtual machine concept (strongly typed version of VM2).
author cin
date Sun, 27 Oct 2013 17:23:25 +0400
parents e113095f1de0
children cb13da6e3349
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
1 using System;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
2 using System.Collections.Generic;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
3 using System.Linq;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
4 using System.Text;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
5 using Jint.Runtime.VM.OpCodes;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
6
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
7 namespace Jint.Runtime.VM {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
8 class RuntimeContext {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
9 Dictionary<Type, object[]> m_impls;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
10
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
11 public RuntimeContext() {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
12 m_impls = new Dictionary<Type, object[]>();
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
13 }
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
14
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
15 public object[] GetImpl(Type type) {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
16 return m_impls[type];
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
17 }
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
18
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
19 public Box<T> BoxValue<T>(T value) {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
20 return new Box<T>(value, this);
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
21 }
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
22
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
23 public void DefineBinaryOperation<T>(Codes code, BinaryOperation<T> op) {
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
24 object[] ops;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
25 if (!m_impls.TryGetValue(typeof(T), out ops))
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
26 ops = m_impls[typeof(T)] = new object[(int)Codes.MaxOp];
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
27
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
28 ops[(int)code] = op;
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
29 }
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
30 }
aced2ae9957f temp commit, new virtual machine concept (strongly typed version of VM2).
cin
parents: 0
diff changeset
31 }