Mercurial > pub > Jint1
view Jint.Runtime/VM/RuntimeContext.cs @ 4:1ae5b10f7a10
Code cleanup, minor refactoring
author | cin |
---|---|
date | Sun, 27 Oct 2013 21:20:59 +0400 |
parents | aced2ae9957f |
children | cb13da6e3349 |
line wrap: on
line source
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Jint.Runtime.VM.OpCodes; namespace Jint.Runtime.VM { class RuntimeContext { Dictionary<Type, object[]> m_impls; public RuntimeContext() { m_impls = new Dictionary<Type, object[]>(); } public object[] GetImpl(Type type) { return m_impls[type]; } public Box<T> BoxValue<T>(T value) { return new Box<T>(value, this); } public void DefineBinaryOperation<T>(Codes code, BinaryOperation<T> op) { object[] ops; if (!m_impls.TryGetValue(typeof(T), out ops)) ops = m_impls[typeof(T)] = new object[(int)Codes.MaxOp]; ops[(int)code] = op; } } }