private void AddFormatterOptions(string format) { if (format == "") { d_showFormatters = true; return; } Plugins.Plugins plugins = Plugins.Plugins.Instance; Type type = plugins.Find(typeof(Programmer.Formatters.IFormatter), format); if (type != null) { if (d_formatter != null) { RemoveOptionsForPlugin(d_formatter); } d_formatter = plugins.Instantiate <Programmer.Formatters.IFormatter>(type); AddOptionsForPlugin(d_formatter); } else { throw new CommandLine.OptionException("The formatter `{0}' does not exist...", format); } }
private Tree.Collectors.Result Collect() { if (Options.Instance.NoEmbeddings) { return(new Tree.Collectors.Result()); } Options parser = Options.Instance; Tree.Collectors.ICollector collector; if (parser.Collector != null) { Plugins.Plugins plugins = Plugins.Plugins.Instance; Type type = plugins.Find(typeof(Tree.Collectors.ICollector), parser.Collector); if (type == null) { throw new Exception(String.Format("The collector `{0}' could not be found...", parser.Collector)); } collector = (Tree.Collectors.ICollector)type.GetConstructor(new Type[] {}).Invoke(new object[] {}); } else { collector = new Tree.Collectors.Default(); } List <Tree.Node> forest = new List <Tree.Node>(); var added = new HashSet <State>(); foreach (State state in Knowledge.Instance.States) { added.Add(state); if (state != Knowledge.Instance.Time && state != Knowledge.Instance.TimeStep) { forest.Add(Tree.Node.Create(state)); } } foreach (State state in Knowledge.Instance.InitializeStates) { if (added.Add(state)) { forest.Add(Tree.Node.Create(state)); } } var ret = collector.Collect(forest.ToArray()); CollectSpecialSingles(ret, forest); return(ret); }
private Tree.Embedding[] Filter(Tree.Collectors.Result collection) { Options parser = Options.Instance; Tree.Filters.IFilter filter; if (parser.Filter != null) { Plugins.Plugins plugins = Plugins.Plugins.Instance; Type type = plugins.Find(typeof(Tree.Filters.IFilter), parser.Filter); if (type == null) { throw new Exception(String.Format("The filter `{0}' could not be found...", parser.Filter)); } filter = (Tree.Filters.IFilter)type.GetConstructor(new Type[] {}).Invoke(new object[] {}); } else { filter = new Tree.Filters.Default(); } // Prefilter remove rands List <Tree.Embedding> ret = new List <Tree.Embedding>(); foreach (Tree.Embedding embed in collection.Prototypes) { if (!(embed.Expression.Instruction is InstructionRand)) { ret.Add(embed); } } return(filter.Filter(ret)); }