コード例 #1
0
        public void Dump(object arg)
        {
            Printer.Output("Dump of globals:");

            if (ctx.ExecutionContext == null)
            {
                Printer.Output("...none");
                return;
            }

            foreach (var rv in DyMachine.DumpVariables(ctx.ExecutionContext))
            {
                Printer.Output($"{rv.Name} = {Printer.Format(rv.Value, ctx.ExecutionContext)}");
            }
        }
コード例 #2
0
    public void Dump(object _)
    {
        Printer.LineFeed();
        Printer.Output("Dump of globals:");

        if (ctx.RuntimeContext is null)
        {
            Printer.Output("<none>");
            return;
        }

        var xs    = DyMachine.DumpVariables(ctx.RuntimeContext).ToList();
        var vals  = new string[xs.Count];
        var types = new string[xs.Count];

        var(keyLen, valLen) = (0, 0);
        var etx = DyMachine.CreateExecutionContext(ctx.RuntimeContext);

        for (var i = 0; i < xs.Count; i++)
        {
            var rv = xs[i];
            vals[i]  = Printer.Format(rv.Value, etx, notype: true, maxLen: 32);
            types[i] = rv.Value.TypeName;

            if (keyLen < rv.Name.Length)
            {
                keyLen = rv.Name.Length;
            }
            if (valLen < vals[i].Length)
            {
                valLen = vals[i].Length;
            }
        }

        for (var i = 0; i < xs.Count; i++)
        {
            var rv = xs[i];
            Printer.Output($"{rv.Name}{new string(' ', keyLen - rv.Name.Length)} | {vals[i]}{new string(' ', valLen - vals[i].Length)} | {types[i]}");
        }
    }
コード例 #3
0
ファイル: TestRunner.cs プロジェクト: buybackoff/dyalect
        private static IList <FunSet> Compile(IEnumerable <string> files, BuilderOptions buildOptions, out List <BuildMessage> warns)
        {
            var funColl = new List <FunSet>();

            warns = new List <BuildMessage>();

            foreach (var file in files)
            {
                var linker = new DyLinker(FileLookup.Create(Path.GetDirectoryName(file)), buildOptions);
                var cres   = linker.Make(SourceBuffer.FromFile(file));
                var funs   = new FunSet();
                funs.Funs     = new Dictionary <string, DyFunction>(StringComparer.OrdinalIgnoreCase);
                funs.FileName = file;

                if (!cres.Success)
                {
                    throw new DyBuildException(cres.Messages);
                }

                warns.AddRange(cres.Messages.Where(m => m.Type == BuildMessageType.Warning));
                var ctx = DyMachine.CreateExecutionContext(cres.Value);
                funs.Context = ctx;
                DyMachine.Execute(ctx);

                foreach (var v in DyMachine.DumpVariables(ctx))
                {
                    if (v.Value is DyFunction fn)
                    {
                        funs.Funs.Remove(v.Name);
                        funs.Funs.Add(v.Name, fn);
                    }
                }

                funColl.Add(funs);
            }

            return(funColl);
        }