コード例 #1
0
        /// <summary>
        /// Test if the given temp item is required to be added
        /// </summary>
        /// <param name="item"></param>
        private void TryAddTempVariable(LlDataItem item)
        {
            //If this temp item is not in the list of required items for computation just ignore it
            if (_activeItemsList.Contains(item.ItemName) == false)
            {
                return;
            }

            var rhsExpr =
                item.AssignedRhsSymbolicScalar.ToTextExpressionTree();

            //Create the temp variable and add it to the target language block
            var tempVar =
                new GMacCbTempVariable(
                    item.ItemName,
                    rhsExpr,
                    false
                    )
            {
                ComputationOrder = _computationOrder--
            };

            CodeBlock.ComputedVariables.Add(tempVar);

            //This item is required for computation.
            //All its RHS items must be added to the list of active items
            _activeItemsList.AddRange(rhsExpr.GetLowLevelVariablesNames());

            if (String.Compare(item.ItemName, _lastUsedVarName, StringComparison.Ordinal) > 0)
            {
                _lastUsedVarName = item.ItemName;
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a single output variable to the code block
        /// </summary>
        /// <param name="item"></param>
        private void AddOutputVariable(LlDataItem item)
        {
            //Find the correct RHS for this output variable
            var rhsExpr =
                BybassSingleTempVariableRhsExpr(
                    item.AssignedRhsSymbolicScalar.ToTextExpressionTree()
                    );

            //Create the output variable and add it to the target language block
            var outputVar =
                new GMacCbOutputVariable(
                    item.ItemName,
                    item.ItemId,
                    item.AssociatedValueAccess,
                    rhsExpr
                    )
            {
                ComputationOrder = _computationOrder--
            };

            CodeBlock.ComputedVariables.Add(outputVar);

            //This item is required for computation.
            //All its RHS items must be added to the list of active items
            _activeItemsList.AddRange(rhsExpr.GetLowLevelVariablesNames());

            if (String.Compare(item.ItemName, _lastUsedVarName, StringComparison.Ordinal) > 0)
            {
                _lastUsedVarName = item.ItemName;
            }
        }