示例#1
0
        private void Build(DBlock node, Hints hints, CompilerContext ctx)
        {
            var hasPush = hints.Has(Push);
            var hasLast = hints.Has(Last);

            hints = hints.Remove(Last);

            if (node.Nodes?.Count == 0)
            {
                if (hints.Has(Push))
                {
                    cw.PushNil();
                }
                return;
            }

            //Start a compile time lexical scope
            if (!hints.Has(NoScope))
            {
                StartScope(fun: false, loc: node.Location);
            }

            for (var i = 0; i < node.Nodes.Count; i++)
            {
                var n    = node.Nodes[i];
                var last = i == node.Nodes.Count - 1;
                var nh   = hasPush && last ? hints : hints.Remove(Push);
                nh = hasLast && last?nh.Append(Last) : nh;

                Build(n, nh, ctx);
            }

            if (!hints.Has(NoScope))
            {
                EndScope();
            }
        }
示例#2
0
 public DyCodeModel(DBlock root, DImport[] imports, string fileName) =>
 (Root, Imports, FileName) = (root, imports, fileName);