Mercurial > pub > Jint1
diff Jint.Runtime/VM/RuntimeContext.cs @ 5:cb13da6e3349
simple loop test
author | cin |
---|---|
date | Mon, 28 Oct 2013 00:49:15 +0400 |
parents | aced2ae9957f |
children |
line wrap: on
line diff
--- a/Jint.Runtime/VM/RuntimeContext.cs Sun Oct 27 21:20:59 2013 +0400 +++ b/Jint.Runtime/VM/RuntimeContext.cs Mon Oct 28 00:49:15 2013 +0400 @@ -20,12 +20,21 @@ return new Box<T>(value, this); } - public void DefineBinaryOperation<T>(Codes code, BinaryOperation<T> op) { + object[] GetOrCreateOps(Type type) { object[] ops; - if (!m_impls.TryGetValue(typeof(T), out ops)) - ops = m_impls[typeof(T)] = new object[(int)Codes.MaxOp]; + if (!m_impls.TryGetValue(type, out ops)) + ops = m_impls[type] = new object[(int)Codes.MaxOp]; + return ops; + } + public void DefineBinaryOperation<T>(Codes code, BinaryOperation<T> op) { + object[] ops = GetOrCreateOps(typeof(T)); ops[(int)code] = op; } + + public void DefineCompareOperation<T>(CompareOperation<T> op) { + object[] ops = GetOrCreateOps(typeof(T)); + ops[(int)Codes.Cmp] = op; + } } }