private static UnifiedExpression CreateEnsure(XElement node) { Contract.Requires(node != null); Contract.Requires(node.Name() == "ensure"); return(UnifiedTry.Create( CreateSmartBlock(node.FirstElement()), null, null, CreateSmartBlock(node.LastElement()))); }
private static UnifiedExpression CreateRescue(XElement node) { Contract.Requires(node != null); Contract.Requires(node.Name() == "rescue"); var lastNode = node.LastElement(); var elseBlock = lastNode.Name() != "resbody" ? CreateSmartBlock(lastNode) : null; return(UnifiedTry.Create( CreateSmartBlock(node.FirstElement()), node.Elements("resbody").Select(CreateResbody).ToSet( ), elseBlock)); }
public UnifiedElement VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) { var uTry = tryCatchStatement.TryBlock.TryAcceptForExpression(this).ToBlock(); var uCatchs = tryCatchStatement .CatchClauses .Select(c => c.AcceptVisitor(this, data)) .Cast <UnifiedCatch>() .ToSet(); var nFinally = tryCatchStatement.FinallyBlock; var uFinally = nFinally == null ? null : nFinally.TryAcceptForExpression(this).ToBlock(); return(UnifiedTry.Create(uTry, uCatchs, /* else */ null, uFinally)); }