private void AddOutputVariable(GMacCbOutputVariable outputVar) { SteExpression rhsExpr; //An atomic expression or an undefined symbol is found for the variable's RHS side if (FollowExpression(outputVar.RhsExpr, out rhsExpr) || rhsExpr.IsAtomic) { outputVar.RhsExpr = rhsExpr; _outputVars.Add(outputVar); return; } //A compound expression is found for the variable's RHS side rhsExpr = ReshapePlus(rhsExpr); var rhsExprNewArgs = new SteExpression[rhsExpr.ArgumentsCount]; for (var i = 0; i < rhsExpr.ArgumentsCount; i++) { rhsExprNewArgs[i] = ReduceSubExpression(rhsExpr[i]); } outputVar.RhsExpr = SteExpressionUtils.CreateFunction(rhsExpr.HeadText, rhsExprNewArgs); _outputVars.Add(outputVar); }
/// <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; } }
private void AddOutputVariable(GMacCbOutputVariable outputVar) { if (outputVar.RhsTempVariables.Any()) { var rhsTemVarsList = outputVar .GetUsedTempVariables() .Where( rhsTempVar => _computedVariablesDictionary.ContainsKey(rhsTempVar.LowLevelName) == false ); foreach (var rhsTempVar in rhsTemVarsList) { _computedVariablesDictionary.Add(rhsTempVar.LowLevelName, rhsTempVar); } } _computedVariablesDictionary.Add(outputVar.LowLevelName, outputVar); }
private DotNode AddOutputExpression(GMacCbOutputVariable computedVar) { var dict = computedVar.RhsExpr.Arguments.ToDictionary( item => item.ToString(), item => item.ToString() ); return (Graph .AddNode(computedVar.LowLevelName) .SetLabel( Graph.Table( "Output", Graph.SimpleTable( computedVar.LowLevelName, computedVar.ValueAccessName, computedVar.RhsExpr.HeadText ), Graph.SimpleTable(dict) ) )); }