Example #1
0
        private object EvaluateAugmentedFast(ScriptThread thread)
        {
            thread.CurrentNode = this; //standard prolog
            var    value     = Target.Evaluate(thread);
            var    exprValue = Expression.Evaluate(thread);
            object result    = null;

            if (_lastUsed != null)
            {
                try {
                    result = _lastUsed.EvaluateBinary(value, exprValue);
                } catch {
                    _failureCount++;
                    // if failed 3 times, change to method without direct try
                    if (_failureCount > 3)
                    {
                        Evaluate = EvaluateAugmented;
                    }
                } //catch
            }     // if _lastUsed
            if (result == null)
            {
                result = thread.Runtime.ExecuteBinaryOperator(BinaryExpressionType, value, exprValue, ref _lastUsed);
            }
            Target.SetValue(thread, result);
            thread.CurrentNode = Parent; //standard epilog
            return(result);
        }
Example #2
0
        protected object EvaluateFast(ScriptThread thread)
        {
            thread.CurrentNode = this; //standard prolog
            var arg1 = Left.Evaluate(thread);
            var arg2 = Right.Evaluate(thread);

            //If we have _lastUsed, go straight for it; if types mismatch it will throw
            if (_lastUsed != null)
            {
                try {
                    var res = _lastUsed.EvaluateBinary(arg1, arg2);
                    thread.CurrentNode = Parent; //standard epilog
                    return(res);
                } catch {
                    _lastUsed = null;
                    _failureCount++;
                    // if failed 3 times, change to method without direct try
                    if (_failureCount > 3)
                    {
                        Evaluate = DefaultEvaluateImplementation;
                    }
                } //catch
            }     // if _lastUsed
            // go for normal evaluation
            var result = thread.Runtime.ExecuteBinaryOperator(this.Op, arg1, arg2, ref _lastUsed);

            thread.CurrentNode = Parent; //standard epilog
            return(result);
        }//method