Beispiel #1
0
        protected virtual string TranslateDelayAssignment(Computation.Assignment node, Context context)
        {
            string eq = InstructionTranslator.QuickTranslate((Context)context.Base().Push(node.State, node.Equation));

            StringBuilder ret = new StringBuilder();

            var ds = (DelayedState)node.State;

            uint size = (uint)System.Math.Round(ds.Delay / Cdn.RawC.Options.Instance.DelayTimeStep);

            DataTable.DataItem counter = context.Program.DelayedCounters[new DelayedState.Size(size)];
            DataTable          table   = context.Program.DelayHistoryTable(ds);

            ret.AppendFormat("{0}[{1}] = {2}[{3}[{4}]];",
                             context.This(node.Item.Table),
                             node.Item.AliasOrIndex,
                             context.This(table),
                             context.This(context.Program.DelayedCounters),
                             counter.DataIndex);

            ret.AppendLine();
            ret.AppendFormat("{0}[{1}[{2}]] = {3};",
                             context.This(table),
                             context.This(context.Program.DelayedCounters),
                             counter.DataIndex,
                             eq);

            return(ret.ToString());
        }
Beispiel #2
0
        protected virtual string Translate(Computation.Assignment node, Context context)
        {
            if (node.State is DelayedState)
            {
                // Assignments to delayed states are handled differently
                return(TranslateDelayAssignment(node, context));
            }

            var ctx = (Context)context.Base();

            ctx.Push(node.State, node.Equation);

            return(TranslateAssignment(node.Item.AliasOrIndex, ctx));
        }