Mercurial > pub > Jint1
diff Jint.Runtime/VM/Frame.cs @ 5:cb13da6e3349
simple loop test
author | cin |
---|---|
date | Mon, 28 Oct 2013 00:49:15 +0400 |
parents | 1ae5b10f7a10 |
children | a6329b092499 |
line wrap: on
line diff
--- a/Jint.Runtime/VM/Frame.cs Sun Oct 27 21:20:59 2013 +0400 +++ b/Jint.Runtime/VM/Frame.cs Mon Oct 28 00:49:15 2013 +0400 @@ -17,6 +17,11 @@ m_registers = new AbstractBox[size]; } + /// <summary> + /// Return register at the specified index. + /// </summary> + /// <param name="index">The index of the register</param> + /// <returns>The register.</returns> public AbstractBox this[int index] { get { return m_registers[index]; @@ -27,12 +32,12 @@ } /// <summary> - /// Extracts value stored in the registry specified by the index. + /// Extracts value stored in the register specified by the index. /// </summary> /// <remarks>This method doesn't do any cast, if the specified type isn't the same as the type of the stored value a type cast exception will occur.</remarks> - /// <typeparam name="T">The type of the value stored in the registry.</typeparam> - /// <param name="index">The index of the registry.</param> - /// <returns>The value stored in the registry.</returns> + /// <typeparam name="T">The type of the value stored in the register.</typeparam> + /// <param name="index">The index of the register.</param> + /// <returns>The value stored in the register.</returns> public T GetValue<T>(int index) { return ((Box<T>)m_registers[index]).holdingValue; } @@ -41,13 +46,13 @@ /// Stores a new value in the register specified by the index. /// </summary> /// <remarks> - /// If the previous value has the same type as the value being stored in the registry, - /// the new value will replace the old one, otherwise the registry will be reallocated to + /// If the previous value has the same type as the value being stored in the register, + /// the new value will replace the old one, otherwise the register will be reallocated to /// store the new value. /// </remarks> /// <typeparam name="T">The type of the value being stored</typeparam> - /// <param name="index">The index of the registry where the value will be stored</param> - /// <param name="value">The value to be stored in the registry</param> + /// <param name="index">The index of the register where the value will be stored</param> + /// <param name="value">The value to be stored in the register</param> public void SetValue<T>(int index, T value) { var reg = m_registers[index] as Box<T>; if (reg == null || reg.holdingType != typeof(T)) @@ -55,5 +60,14 @@ else reg.holdingValue = value; } + + public T GetConverted<T>(int index) { + var reg = m_registers[index]; + + if (reg.holdingType == typeof(T)) + return ((Box<T>)reg).holdingValue; + else + return reg.Convert<T>(); + } } }