/// <summary>Interprets a node as a list by returning <c>block.Args</c> if /// <c>block.Calls(braces)</c>, otherwise returning a one-item list of nodes /// with <c>block</c> as the only item.</summary> public static RVList<LNode> AsList(this LNode block, Symbol braces) { return block.Calls(braces) ? block.Args : new RVList<LNode>(block); }
/// <summary>Interprets a node as a list by returning <c>block.Args</c> if /// <c>block.Calls(listIdentifier)</c>, otherwise returning a one-item list /// of nodes with <c>block</c> as the only item.</summary> public static VList<LNode> AsList(this LNode block, Symbol listIdentifier) { return block.Calls(listIdentifier) ? block.Args : new VList<LNode>(block); }
/// <summary> /// Check if the method calls another method which matches the given pattern. /// </summary> /// <param name="method">Method to check</param> /// <param name="codePattern">Pattern to check against</param> /// <returns>true if method calls another which matches, false if not</returns> public static Boolean MatchesIndirect(this MethodDef method, IList<Code> codePattern) { if (method == null) throw new ArgumentNullException(); return method.Calls().FirstOrDefault((called) => { MethodDef def = called as MethodDef; if (def == null) return false; else return def.Matches(codePattern); }) != null; }