static void WriteTargetTags(GraphBuilder gb, WrenchTarget wt, XmlTextWriter tw) { foreach (KeyValuePair <string, SingleValue <int> > kvp in wt.IdTags) { int tagid = gb.GetTagId(kvp.Key); if (tagid < 0) { throw ExHelp.Argument("tag", "Invalid tag name {0}", kvp.Key); } if (kvp.Value.IsResult) { tw.WriteStartElement("rt"); tw.WriteAttributeString("id", tagid.ToString()); ((Result)kvp.Value).ExportXml(tw, "r"); } else { tw.WriteStartElement("tt"); tw.WriteAttributeString("id", tagid.ToString()); tw.WriteAttributeString("target", ((int)kvp.Value).ToString()); } tw.WriteEndElement(); } }
void ScanTags(WrenchTarget wt) { foreach (KeyValuePair <string, SingleValue <TargetBuilder> > kvp in wt.Tags) { int tagid = gb.GetTagId(kvp.Key); if (tagid < 0) { throw ExHelp.Argument("tag", "Invalid tag name {0}", kvp.Key); } List <int> list; if (tag_items.ContainsKey(tagid)) { list = tag_items[tagid]; } else { list = new List <int> (); tag_items[tagid] = list; } list.Add(wt.Id); list.Add(CompileSingleValue(kvp.Value)); } }
public int GetTargetId(string target) { // This one always kind of sucks. int idx = target.LastIndexOf('/'); string basis = target.Substring(0, idx + 1); string basename = target.Substring(idx + 1); short pid = GetProviderId(basis); if (pid < 0) { throw ExHelp.Argument("target", "No such target `{0}'", target); } int bound = GetProviderTargetBound(pid); for (int i = ((int)pid) << 16; i < bound; i++) { if (GetTargetName(i) == basename) { return(i); } } throw ExHelp.Argument("target", "No such target `{0}'", target); }
Result ResultFromCode(int code) { if ((code & 0x7FFF0000) != 0x7FFF0000) { throw ExHelp.Argument("code", "Result code {0:x} must have PID 0x7FFF", code); } return(result_table[code & 0x0000FFFF]); }
// Throws an exception if the target with the given // name has not yet been defined -- this function should only // be called if the given target is known to exist by now. public TargetBuilder GetTarget(string name) { if (!targets.ContainsKey(name) || targets[name].Validity != TargetValidity.Defined) { throw ExHelp.Argument("name", "The target {0}{1} should be " + "defined by now, but isn't.", basis, name); } return(targets[name]); }
// Helper type things public static string ParseFullName(string fullname, out string basis) { basis = null; if (fullname[0] != '/' || fullname[fullname.Length - 1] == '/') { throw ExHelp.Argument("fullname", "Invalid absolute target name `{0}'", fullname); } int idx = fullname.LastIndexOf('/'); basis = fullname.Substring(0, idx + 1); return(fullname.Substring(idx + 1)); }
// Throws an exception if the target or its provider is // not yet defined; this function should only be called // if the target is known to exist. public TargetBuilder GetTarget(string fullname) { string basis, basename; basename = ParseFullName(fullname, out basis); ProviderBuilder pb = providers[basis]; if (pb == null) { throw ExHelp.Argument("fullname", "The target `{0}' should exist by " + "now but does not", fullname); } return(pb.GetTarget(basename)); }
protected ProviderLoaderBase(string basis, string decl_loc) { if (basis == null || basis[0] != '/' || basis[basis.Length - 1] != '/') { throw ExHelp.Argument(basis, "Invalid basis string `{0}'", basis); } this.basis = basis; if (decl_loc == null) { this.decl_loc = SourceSettings.BasisToSubpath(basis); } else { this.decl_loc = decl_loc; } }