Esempio n. 1
0
 private void Abort()
 {
     if (status != InliningResult.Success)
     {
         status = InliningResult.Abort;
     }
 }
Esempio n. 2
0
        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;
        }
Esempio n. 4
0
        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;
        }
 private void Abort()
 {
     if (status != InliningResult.Success)
     {
         status = InliningResult.Abort;
     }
 }