Example #1
0
        /// <summary>
        /// Replace all LHS partial access processes with full access processes by updating the RHS to be
        /// composite type initialized constructions on full variables. For example the command
        ///    let x.point.#E1# = y gp z
        /// is replaced by the two commands:
        ///    let temp = y gp z
        ///    let x = Multivector{x}(#E1# = temp)
        /// </summary>
        private void Optimize_ReplaceAllLHSPartialAccess()
        {
            _updateChainFlag = false;

            foreach (var commandInfo in _commandsInfoList.Where(commandInfo => commandInfo.IsPartialLhsDefinition))
            {
                //Assume command is 'let x.point.#E1# = y gp z'
                _updateChainFlag = true;

                //old_root_lvalue is 'x'
                var oldRootLvalue = commandInfo.AssociatedCommand.LhsValueAccess.RootSymbolAsLValue;

                //new_lvalue is 'temp'
                var newLvalue = DefineNewLocalVariable(commandInfo.AssociatedCommand.RhsExpression.ExpressionType);

                //Add command 'let temp = y gp z'
                _optimizedBlock.AddCommandBeforeCommand_Assign(
                    commandInfo.AssociatedCommand,
                    LanguageValueAccess.Create(newLvalue),
                    commandInfo.AssociatedCommand.RhsExpression
                    );

                //Update command 'let x.point.#E1# = y gp z' to become let x = Multivector{x}(#E1# = temp)
                commandInfo.AssociatedCommand.SetCommandSides(
                    LanguageValueAccess.Create(oldRootLvalue),
                    CreateConstructorExpression(commandInfo, newLvalue)
                    );
            }

            UpdateChains();
        }