internal void Add(string expression, XmlNamespaceManager names, object item, bool forceExternal) { Fx.Assert(null != item, ""); // Compile the new filter bool compiled = false; OpcodeBlock codeBlock = new OpcodeBlock(); codeBlock.Append(new NoOpOpcode(OpcodeID.QueryTree)); if (!forceExternal) { try { ValueDataType returnType = ValueDataType.None; // Try to compile and merge the compiled query into the query tree codeBlock.Append(QueryMatcher.CompileForInternalEngine(expression, names, QueryCompilerFlags.InverseQuery, out returnType)); MultipleResultOpcode opcode; if (!this.match) { opcode = new QueryMultipleResultOpcode(); } else { opcode = new MatchMultipleResultOpcode(); } opcode.AddItem(item); codeBlock.Append(opcode); compiled = true; // Perform SubExpression Elimination codeBlock = new OpcodeBlock(this.elim.Add(item, codeBlock.First)); this.subExprVars = this.elim.VariableCount; } catch (QueryCompileException) { // If the filter couldn't be compiled, we drop down to the framework engine } } if (!compiled) { codeBlock.Append(QueryMatcher.CompileForExternalEngine(expression, names, item, this.match)); } // Merge the compiled query into the query tree QueryTreeBuilder builder = new QueryTreeBuilder(); this.query = builder.Build(this.query, codeBlock); // To de-merge this filter from the tree, we'll have to walk backwards up the tree... so we // have to remember the last opcode that is executed on behalf of this filter this.lastLookup[item] = builder.LastOpcode; }
internal void Add(string expression, XmlNamespaceManager names, object item, bool forceExternal) { bool flag = false; OpcodeBlock newBlock = new OpcodeBlock(); newBlock.Append(new NoOpOpcode(OpcodeID.QueryTree)); if (!forceExternal) { try { MultipleResultOpcode opcode; ValueDataType none = ValueDataType.None; newBlock.Append(QueryMatcher.CompileForInternalEngine(expression, names, QueryCompilerFlags.InverseQuery, out none)); if (!this.match) { opcode = new QueryMultipleResultOpcode(); } else { opcode = new MatchMultipleResultOpcode(); } opcode.AddItem(item); newBlock.Append(opcode); flag = true; newBlock = new OpcodeBlock(this.elim.Add(item, newBlock.First)); base.subExprVars = this.elim.VariableCount; } catch (QueryCompileException) { } } if (!flag) { newBlock.Append(QueryMatcher.CompileForExternalEngine(expression, names, item, this.match)); } QueryTreeBuilder builder = new QueryTreeBuilder(); base.query = builder.Build(base.query, newBlock); this.lastLookup[item] = builder.LastOpcode; }