public void Dispatch(CmdLine cmd) { var args = cmd.Parts; if (args.IsEmpty) { return; } var name = first(args).Content; var a0 = args.Length >= 2 ? args[1].Content : EmptyString; var a1 = args.Length >= 3 ? args[2].Content : EmptyString; var a2 = args.Length >= 4 ? args[3].Content : EmptyString; var a3 = args.Length >= 5 ? args[4].Content : EmptyString; switch (name) { case RunScriptCmd.CmdName: Builder.RunScript(FS.path(a0)).RunDirect(Wf); break; default: Wf.Error(string.Format("Processor for {0} not found", name)); break; } }
public Index <ApiCatalogEntry> LoadCatalog() { var dir = Db.CaptureContextRoot(); var files = dir.Files(FS.Csv).Where(f => f.FileName.StartsWith(ApiCatalogEntry.TableId)).OrderBy(f => f.Name); var rows = root.list <ApiCatalogEntry>(); if (files.Length != 0) { var src = files[files.Length - 1]; var flow = Wf.Running(Msg.LoadingApiCatalog.Format(src)); using var reader = src.Reader(); reader.ReadLine(); var line = reader.ReadLine(); while (line != null) { var outcome = parse(line, out var row); if (outcome) { rows.Add(row); } else { Wf.Error(outcome.Message); return(sys.empty <ApiCatalogEntry>()); } line = reader.ReadLine(); } Wf.Ran(flow, Msg.LoadedApiCatalog.Format(rows.Count, src)); } return(rows.ToArray()); }
protected override Reactor Init(out int state) { state = 32; Builder = Wf.CmdBuilder(); Db = Wf.Db(); return(this); }
public Index <BitMaskInfo> Emit(FS.FilePath dst) { var flow = Wf.EmittingTable <BitMaskInfo>(dst); var masks = Load(); Emit(masks.View, dst); return(masks); }
public ReadOnlySpan <ProcessSegment> LocateSegments(AddressBank src, ReadOnlySpan <ApiMemberInfo> methods, FS.FolderPath dir) { var count = methods.Length; var flow = Wf.Running(Msg.LocatingSegments.Format(count)); var buffer = sys.alloc <MethodSegment>(count); var locations = root.hashset <ProcessSegment>(); var segments = src.Segments; ref var dst = ref first(buffer);
public ReadOnlySpan <SymLiteral> EmitApiClasses(FS.FilePath dst) { var flow = Wf.EmittingTable <SymLiteral>(dst); var literals = Query.ApiClassLiterals(); var count = Tables.emit(literals, dst); Wf.EmittedTable(flow, count); return(literals); }
public Index <SymbolDetail> EmitSymDetails <E>() where E : unmanaged, Enum { var dst = Db.Table <SymbolDetail>(typeof(E).Name); var flow = Wf.EmittingTable <SymbolDetail>(dst); var symbols = Symbols <E>().View; var count = symbols.Length; var buffer = alloc <SymbolDetail>(count); ref var target = ref first(buffer);
public Index <ApiCatalogEntry> RebaseMembers(ApiMembers src, FS.FilePath dst) { var flow = Wf.EmittingTable <ApiCatalogEntry>(dst); var records = rebase(src.BaseAddress, src.View); var count = Tables.emit <ApiCatalogEntry>(records.View, dst); Wf.EmittedTable <ApiCatalogEntry>(flow, count, dst); return(records); }
public void CreateLink(Timestamp ts) { var outcome = Archives.Link(ts); if (Wf.Check(outcome, out var data)) { Wf.Status(string.Format("Created symlink {0} -> {1}", data.Source, data.Target)); } }
ApiCodeBlock LoadBlock(ApiHexRow src) { if (src.Uri.IsEmpty) { Wf.Warn(string.Format("The operation uri for method based at {0} is empty", src.Address)); } return(new ApiCodeBlock(src.Address, src.Uri, src.Data)); }
public ApiHostCatalog HostCatalog(IApiHost src) { var flow = Wf.Running(Msg.CreatingHostCatalog.Format(src.HostUri)); var members = ApiJit.JitHost(src); var result = members.Length == 0 ? ApiHostCatalog.Empty : new ApiHostCatalog(src, members); Wf.Ran(flow, Msg.CreatedHostCatalog.Format(src.HostUri, members.Count)); return(result); }
public uint Load(FS.FilePath src, List <ApiExtractBlock> dst) { var lines = src.ReadLines().View; var count = lines.Length; var flow = Wf.Running(string.Format("Reading extracts from {0}", src.ToUri())); var counter = 0u; for (var i = 1u; i < count; i++) { ref readonly var line = ref skip(lines, i);
public ApiBlockIndex IndexApiBlocks() { var src = Db.ParsedExtractPaths().View; var count = src.Length; var flow = Wf.Running(Msg.IndexingPartFiles.Format(count)); var hex = Wf.ApiHex(); for (var i = 0; i < count; i++) { ref readonly var path = ref skip(src, i);
public ReadOnlySpan <ApiHostBlocks> ReadHostBlocks(FS.FolderPath root) { var flow = Wf.Running(string.Format("Loading host blocks from {0}", root)); var files = Files(root).View; var count = files.Length; var dst = list <ApiHostBlocks>(); var counter = 0u; for (var i = 0; i < count; i++) { ref readonly var file = ref skip(files, i);
public ExecToken Emit(ReadOnlySpan <BitMaskInfo> src, FS.FilePath dst) { var flow = Wf.EmittingTable <BitMaskInfo>(dst); var count = src.Length; using var writer = dst.Writer(); writer.WriteLine(Formatter.HeaderText); for (var i = 0u; i < count; i++) { writer.WriteLine(Formatter.Format(skip(src, i))); } return(Wf.EmittedTable <BitMaskInfo>(flow, count, dst)); }
public Index <ResEmission> EmitAssetContent() { var outer = Wf.Running("Emitting reference data"); var components = Wf.ApiCatalog.Components; var descriptors = Resources.descriptors(components).SelectMany(x => x.Storage).View; var count = descriptors.Length; var root = Db.RefDataRoot(); var emissions = sys.alloc <ResEmission>(count); for (var i = 0; i < count; i++) { try { ref var emission = ref seek(emissions, i); ref readonly var descriptor = ref skip(descriptors, i);
public Index <ApiResAccessor> ResPackAccessors() { var path = ResPackPath(); var flow = Wf.Running(Msg.LoadingRespackAccessors.Format(path)); if (!path.Exists) { Throw.sourced(FS.Msg.DoesNotExist.Format(path)); } var assembly = Assembly.LoadFrom(path.Name); var loaded = Resources.accessors(assembly); Wf.Ran(flow, Msg.LoadedRespackAccessors.Format(loaded.Count, path)); return(loaded); }
public Lookup <FS.FilePath, HexPack> Load(FS.Files src) { var flow = Wf.Running(string.Format("Loading {0} packs", src.Length)); var lookup = new Lookup <FS.FilePath, HexPack>(); var errors = new Lookup <FS.FilePath, Outcome>(); iter(src, path => load(path, lookup, errors), true); var result = lookup.Seal(); var count = result.EntryCount; var entries = result.Entries; var counter = 0u; for (var i = 0; i < count; i++) { ref readonly var entry = ref skip(entries, i);
public Index <ClrEnumRecord> EmitEnumRecords(ClrAssemblyAdapter src, FS.FilePath dst) { var records = Enums.records(src); if (records.Length != 0) { var t = default(ClrEnumRecord); var formatter = Tables.formatter <ClrEnumRecord>(32); var flow = Wf.EmittingTable <ClrEnumRecord>(dst); var counter = 0u; Execute(records, ref counter, formatter, dst); Wf.EmittedTable(flow, counter); } return(records); }
public Index <ApiCodeBlock> Read(ApiHostUri host) { var file = FS.file(host.Part, host.HostName, Ext); var path = Paths().Where(f => f.FileName.Name == file.Name).FirstOrDefault(FS.FilePath.Empty); if (path.IsEmpty) { Wf.Warn(Msg.HostFileMissing.Format(host, path)); return(sys.empty <ApiCodeBlock>()); } var flow = Wf.Running(path); var data = Read(path); Wf.Ran(flow, data.Length); return(data); }
public void Emit(Type src, FS.FilePath dst) { var flow = Wf.EmittingFile(dst); using var writer = dst.Writer(); var patterns = Sources(src); var view = patterns.View; var count = view.Length; for (var i = 0; i < count; i++) { writer.WriteLine(skip(view, i).Format()); } Wf.EmittedFile(flow, count); }
void ShowByteConversions() { const string FormatPattern = "{0,-5} | {1,-5} | {2}"; var header = string.Format(FormatPattern, "Dec", "Hex", "Bits"); using var logger = Db.ShowLog(ext: FS.Csv).Writer(); Wf.Row(header); logger.WriteLine(header); var options = BitFormatOptions.bitblock(4, Chars.Space); for (var i = 0; i <= byte.MaxValue; i++) { byte src = (byte)i; var dec = string.Format("{0:D3}", src); var bits = src.FormatBits(options); var hex = src.FormatHex(specifier: false); var row = string.Format(FormatPattern, dec, hex, bits); logger.WriteLine(row); Wf.Row(row); } }
public Outcome <FileSplitInfo> Run(FileSplitSpec spec) { var writer = default(StreamWriter); try { var flow = Wf.Running(Msg.SplittingFile.Format(spec.SourceFile.ToUri(), spec.MaxLineCount)); using var reader = spec.SourceFile.Reader(); var paths = root.list <FS.FilePath>(); var subcount = 0u; var linecount = 0u; var splitcount = 0u; var emptycount = 0; var emptylimit = 5; var path = NextPath(spec, ref splitcount); paths.Add(path); writer = path.Writer(); var emitting = Wf.EmittingFile(path); while (!reader.EndOfStream) { var line = reader.ReadLine(); if (text.empty(line)) { emptycount++; } else { emptycount = 0; } if (emptycount > emptylimit) { continue; } writer.WriteLine(line); subcount++; if (subcount >= spec.MaxLineCount) { writer.Flush(); writer.Dispose(); Wf.EmittedFile(emitting, subcount); path = NextPath(spec, ref splitcount); paths.Add(path); writer = path.Writer(); linecount += subcount; subcount = 0; } } Wf.Ran(flow, Msg.FinishedFileSplit.Format(linecount, spec.SourceFile.ToUri(), splitcount)); return(new FileSplitInfo(spec, paths.ToArray(), linecount)); } catch (Exception e) { Wf.Error(e); return(e); } finally { writer.Flush(); writer.Dispose(); } }
protected override void OnInit() { ApiJit = Wf.ApiJit(); Query = Wf.ApiQuery(); }
public Index <ApiCodeBlock> Read(FS.FilePath src) => Wf.ApiHex().ReadBlocks(src).Where(x => x.IsNonEmpty);