private void Abort() { if (status != InliningResult.Success) { status = InliningResult.Abort; } }
public override ICodeNode VisitVariableReferenceExpression(VariableReferenceExpression node) { if (status == InliningResult.Abort) { //sanity check throw new Exception("Invalid state"); } if (node.Variable.Resolve() == variableDef) { status = InliningResult.Success; return(GetNewValue(node)); } return(node); }
public bool TryInlineVariable(VariableDefinition variableDef, Expression value, ICodeNode target, bool aggressive, out ICodeNode result) { this.variableDef = variableDef; this.value = value; if (!aggressive) { ASTNodeCounter counter = new ASTNodeCounter(); if (counter.CountNodes(value) + counter.CountNodes(target) - 1 > MaxCount) { result = target; return false; } } SideEffectsFinder sideEffectsFinder = new SideEffectsFinder(); valueHasSideEffects = sideEffectsFinder.HasSideEffectsRecursive(value); status = InliningResult.NotFound; result = Visit(target); return status == InliningResult.Success; }
public bool TryInlineVariable(VariableDefinition variableDef, Expression value, ICodeNode target, bool aggressive, out ICodeNode result) { this.variableDef = variableDef; this.value = value; if (!aggressive) { ASTNodeCounter counter = new ASTNodeCounter(); if (counter.CountNodes(value) + counter.CountNodes(target) - 1 > MaxCount) { result = target; return(false); } } SideEffectsFinder sideEffectsFinder = new SideEffectsFinder(); valueHasSideEffects = sideEffectsFinder.HasSideEffectsRecursive(value); status = InliningResult.NotFound; result = Visit(target); return(status == InliningResult.Success); }
public override ICodeNode VisitVariableReferenceExpression(VariableReferenceExpression node) { if (status == InliningResult.Abort) { //sanity check throw new Exception("Invalid state"); } if (node.Variable.Resolve() == variableDef) { status = InliningResult.Success; return GetNewValue(node); } return node; }