Exemplo n.º 1
0
        /// <summary>
        /// Builds an array that containsthe given array elements.
        /// Registers the value with the scope manager, unless registerWithScopeManager is set to false.
        /// Increases the reference count for the array elements.
        /// </summary>
        /// <param name="elementType">The Q# type of the array elements</param>
        /// <param name="registerWithScopeManager">Whether or not to register the built tuple with the scope manager</param>
        /// <param name="arrayElements">The elements in the array</param>
        internal ArrayValue CreateArray(ResolvedType elementType, bool registerWithScopeManager, params IValue[] arrayElements)
        {
            var array        = new ArrayValue((uint)arrayElements.Length, elementType, this.sharedState, registerWithScopeManager);
            var itemPointers = array.GetArrayElementPointers();

            for (var i = 0; i < itemPointers.Length; ++i)
            {
                itemPointers[i].StoreValue(arrayElements[i]);
                this.sharedState.ScopeMgr.IncreaseReferenceCount(arrayElements[i]);
            }

            return(array);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds an array that contains the given array elements.
        /// Registers the value with the scope manager, unless registerWithScopeManager is set to false.
        /// </summary>
        /// <param name="arrayElements">The elements in the array</param>
        internal ArrayValue CreateArray(ResolvedType elementType, ImmutableArray <TypedExpression> arrayElements, bool registerWithScopeManager = true)
        {
            var array        = new ArrayValue((uint)arrayElements.Length, elementType, this.sharedState, registerWithScopeManager);
            var itemPointers = array.GetArrayElementPointers();

            var elements = arrayElements.Select(this.sharedState.BuildSubitem).ToArray();

            for (var i = 0; i < itemPointers.Length; ++i)
            {
                itemPointers[i].StoreValue(elements[i]);
            }

            return(array);
        }