internal XmlQueryRuntime(XmlILCommand cmd, object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, XmlSequenceWriter seqWrt) {
Debug.Assert(cmd != null, "Command object must be non-null");
string[] names = cmd.Names;
Int32Pair[] filters = cmd.Filters;
WhitespaceRuleLookup wsRules;
int i;
this.cmd = cmd;
// Early-Bound Library Objects
wsRules = (cmd.WhitespaceRules.Count != 0) ? new WhitespaceRuleLookup(cmd.WhitespaceRules) : null;
this.ctxt = new XmlQueryContext(this, defaultDataSource, dataSources, argList, wsRules);
this.xsltLib = null;
this.earlyInfo = cmd.EarlyBound;
this.earlyObjects = (this.earlyInfo != null) ? new object[earlyInfo.Length] : null;
// Global variables and parameters
this.globalNames = cmd.GlobalNames;
this.globalValues = (this.globalNames != null) ? new object[this.globalNames.Length] : null;
// Names
this.nameTableQuery = this.ctxt.QueryNameTable;
this.atomizedNames = null;
if (names != null) {
// Atomize all names in "nameTableQuery". Use names from the default data source's
// name table when possible.
XmlNameTable nameTableDefault = ctxt.DefaultNameTable;
this.atomizedNames = new string[names.Length];
if (nameTableDefault != this.nameTableQuery && nameTableDefault != null) {
// Ensure that atomized names from the default data source are added to the
// name table used in this query
for (i = 0; i < names.Length; i++) {
string name = nameTableDefault.Get(names[i]);
this.atomizedNames[i] = this.nameTableQuery.Add(name ?? names[i]);
}
}
else {
// Enter names into nametable used in this query
for (i = 0; i < names.Length; i++)
this.atomizedNames[i] = this.nameTableQuery.Add(names[i]);
}
}
// Name filters
this.filters = null;
if (filters != null) {
// Construct name filters. Each pair of integers in the filters[] array specifies the
// (localName, namespaceUri) of the NameFilter to be created.
this.filters = new XmlNavigatorFilter[filters.Length];
for (i = 0; i < filters.Length; i++)
this.filters[i] = XmlNavNameFilter.Create(this.atomizedNames[filters[i].Left], this.atomizedNames[filters[i].Right]);
}
// Prefix maping lists
this.prefixMappingsList = cmd.PrefixMappingsList;
// Xml types
this.types = cmd.Types;
// Xml collations
this.collations = cmd.Collations;
// Document ordering
this.docOrderCmp = new DocumentOrderComparer();
// Indexes
this.indexes = null;
// Output construction
this.stkOutput = new Stack<XmlQueryOutput>(16);
this.output = new XmlQueryOutput(this, seqWrt);
}