public InteractiveContext(DyaOptions options) { Options = options; BuildOptions = CreateBuildOptions(options); var nofn = options.FileNames is null || options.FileNames.Length == 0 || string.IsNullOrWhiteSpace(options.FileNames[0]); var lookup = FileLookup.Create(BuildOptions, nofn ? Environment.CurrentDirectory ! : Path.GetDirectoryName(options.FileNames ![0]) !, options.Paths);
public InteractiveContext(DyaOptions options) { Options = options; BuildOptions = CreateBuildOptions(options); var lookup = FileLookup.Create( options.FileNames == null || options.FileNames.Length == 0 || string.IsNullOrWhiteSpace(options.FileNames[0]) ? Environment.CurrentDirectory : Path.GetDirectoryName(options.FileNames[0]), options.Paths); Linker = new DyIncrementalLinker(lookup, BuildOptions, options.UserArguments); }
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); }