Пример #1
0
        private static void CompileMemoryFunction(int level, bool debug, Node node, Node container, NanCodeWriter wr, Scope parameterNames)
        {
            // Check for special increment mode
            if (node.Text == "set" && Optimisations.IsSmallIncrement(node, out var incr, out var target))
            {
                wr.Increment(incr, target);
                return;
            }

            var child = new Node(false, -2)
            {
                Text = container.Children.First.Value.Text
            };
            var paramCount = container.Children.Count - 1;

            for (int i = paramCount; i > 0; i--)
            {
                child.AddLast(container.Children.ElementAt(i));
            }

            wr.Merge(Compile(child, level + 1, debug, parameterNames, null, Context.MemoryAccess));

            if (debug)
            {
                wr.Comment("// Memory function : " + node.Text);
            }

            wr.Memory(node.Text[0], child.Text, paramCount);
        }