public VisitExpression ( System.Compiler.Expression expression ) : System.Compiler.Expression | ||
expression | System.Compiler.Expression | |
return | System.Compiler.Expression |
public override Statement VisitIf(If If) { if (insideAtomicBlock && IsCoalescableIfStmt(If)) { CurrentContinuation = AddBlock(new BasicBlock(If, CurrentContinuation)); return If; } PushContinuationStack(); this.Visit(If.TrueBlock); BasicBlock trueBlock = PopContinuationStack(); PushContinuationStack(); this.Visit(If.FalseBlock); BasicBlock falseBlock = PopContinuationStack(); SourceContext savedConditionalContext = If.SourceContext; if (If.Condition != null) savedConditionalContext = If.Condition.SourceContext; // We normalize all of the conditional expressions here to make life // easier for "select" Normalizer normalizer = new Normalizer(splicer, null, false); CurrentContinuation = AddBlock(new BasicBlock(null, normalizer.VisitExpression(If.Condition), trueBlock, falseBlock)); CurrentContinuation.SourceContext = savedConditionalContext; if (CurrentContinuation.ConditionalExpression != null) CurrentContinuation.ConditionalExpression.SourceContext = savedConditionalContext; return If; }
public override Statement VisitWhile(While While) { if (While == null || While.Condition == null) return While; if (insideAtomicBlock && IsCoalescableWhileStmt(While)) { CurrentContinuation = AddBlock(new BasicBlock(While, CurrentContinuation)); return While; } Normalizer normalizer = new Normalizer(splicer, null, false); BasicBlock testBlock = new BasicBlock(null); testBlock.SourceContext = While.Condition.SourceContext; PushContinuationStack(testBlock); this.Visit(While.Body); BasicBlock bodyBlock = PopContinuationStack(); testBlock.ConditionalExpression = normalizer.VisitExpression(While.Condition); testBlock.ConditionalTarget = bodyBlock; testBlock.UnconditionalTarget = CurrentContinuation; testBlock.ConditionalExpression.SourceContext = testBlock.SourceContext; CurrentContinuation = AddBlock(testBlock); return While; }
public override Statement VisitForEach(ForEach forEach) { Normalizer normalizer = new Normalizer(false); Identifier incrVar = new Identifier("____" + forEach.UniqueKey.ToString(CultureInfo.InvariantCulture)); Expression sourceEnumerable = normalizer.VisitExpression(forEach.SourceEnumerable); Statement incrStmt = Templates.GetStatementTemplate("foreachIncrementer"); Replacer.Replace(incrStmt, "_iterator", incrVar); BasicBlock incrBlock = new BasicBlock(incrStmt); AddBlock(incrBlock); incrBlock.MiddleOfTransition = true; incrBlock.SkipNormalizer = true; incrBlock.SourceContext = forEach.SourceContext; PushContinuationStack(incrBlock); this.Visit(forEach.Body); BasicBlock bodyBlock = PopContinuationStack(); Statement derefStmt = Templates.GetStatementTemplate("foreachDeref"); Replacer.Replace(derefStmt, "_tmpVar", normalizer.VisitExpression(forEach.TargetVariable)); Replacer.Replace(derefStmt, "_collectionExpr", sourceEnumerable); Replacer.Replace(derefStmt, "_collectionType", new Identifier(forEach.SourceEnumerable.Type.FullName)); Replacer.Replace(derefStmt, "_iterator", incrVar); BasicBlock derefBlock = new BasicBlock(derefStmt, bodyBlock); AddBlock(derefBlock); derefBlock.MiddleOfTransition = true; derefBlock.SkipNormalizer = true; Expression testExpr = Templates.GetExpressionTemplate("foreachTest"); Replacer.Replace(testExpr, "_iterator", incrVar); Replacer.Replace(testExpr, "_sourceEnumerable", sourceEnumerable); BasicBlock testBlock = new BasicBlock(null, testExpr, derefBlock, CurrentContinuation); AddBlock(testBlock); testBlock.SkipNormalizer = true; incrBlock.UnconditionalTarget = testBlock; Statement initStmt = Templates.GetStatementTemplate("foreachInit"); Replacer.Replace(initStmt, "_iterator", incrVar); BasicBlock initBlock = new BasicBlock(initStmt, testBlock); AddBlock(initBlock); initBlock.MiddleOfTransition = true; initBlock.SkipNormalizer = true; initBlock.SourceContext = forEach.SourceContext; CurrentContinuation = initBlock; return forEach; }