Created
September 5, 2011 16:47
-
-
Save danielmoore/1195440 to your computer and use it in GitHub Desktop.
Big ass match statement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec processMethodCalls (rule : IRule) (processor : MethodCall -> Option<Problem>) (mbr : Member) : ProblemCollection = | |
let problems = new ProblemCollection(rule) | |
let rec processMbrs mbrs = Seq.iter processMbr mbrs | |
and processMbr (mbr : Member) = | |
let rec processStmts stmts = Seq.iter processStmt stmts | |
and processStmt (stmt : Statement) = | |
let rec processExprs exprs = Seq.iter processExpr exprs | |
and processExpr (expr : Expression) = | |
match expr with | |
| :? UnaryExpression as ur -> | |
processExpr ur.Operand | |
| :? BinaryExpression as br -> | |
processExpr br.Operand1 | |
processExpr br.Operand2 | |
| :? TernaryExpression as tr -> | |
processExpr tr.Operand1 | |
processExpr tr.Operand2 | |
processExpr tr.Operand3 | |
| :? NaryExpression as nr -> | |
processExprs nr.Operands | |
match nr with | |
| :? MethodCall as mc -> | |
match processor mc with | |
| Some p -> problems.Add(p) | |
| None -> () | |
| _ -> () | |
| _ -> () | |
match stmt with | |
| :? AssignmentStatement as astmt -> | |
processExpr astmt.Source | |
processExpr astmt.Target | |
| :? Block as b -> | |
processStmts b.Statements | |
| :? Branch as b -> | |
processExpr b.Condition | |
processStmt b.Target | |
| :? TryNode as tn -> | |
processStmt tn.Block | |
processStmts tn.Catchers | |
processStmt tn.Finally | |
processStmt tn.FaultHandler | |
| :? CatchNode as cn -> | |
processStmt cn.Block | |
processStmt cn.Filter | |
processExpr cn.Variable | |
| :? FinallyNode as fn -> | |
processStmt fn.Block | |
| :? FaultHandler as fh -> | |
processStmt fh.Block | |
| :? Filter as f -> | |
processExpr f.Expression | |
processStmt f.Block | |
| :? EndFilter as ef -> | |
processExpr ef.Value | |
| :? SwitchInstruction as si -> | |
processExpr si.Expression | |
processStmts si.Targets | |
| :? ThrowNode as tn -> | |
processExpr tn.Expression | |
| _ -> () | |
match mbr with | |
| :? Method as x -> | |
processStmts x.Body.Statements | |
| :? PropertyNode as pn -> | |
processMbr pn.Getter | |
processMbr pn.Setter | |
| _ -> () | |
processMbr mbr | |
problems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment