예제 #1
0
        public static ISymbolValue Execute(MemberSymbol method, Dictionary <DVariable, ISymbolValue> arguments, AbstractSymbolValueProvider vp)
        {
            if (vp.ResolutionContext.CancelOperation)
            {
                return(null);
            }

            var dm = method.Definition as DMethod;

            if (dm == null || dm.BlockStartLocation.IsEmpty)
            {
                return(new ErrorValue(new EvaluationException("Method either not declared or undefined", method)));
            }
            var          eval = new FunctionEvaluation(method, vp, arguments);
            ISymbolValue ret;

            using (vp.ResolutionContext.Push(method, dm.BlockStartLocation))
            {
                try
                {
                    dm.Body.Accept(eval);
                }
                catch (CtfeException ex)
                {
                    vp.LogError(dm, "Can't execute function at precompile time: " + ex.Message);
                }

                ret = Evaluation.GetVariableContents(eval.returnedValue, eval.vp);
            }

            return(ret);

            //return new ErrorValue(new EvaluationException("CTFE is not implemented yet."));
        }
예제 #2
0
        public static ISymbolValue Execute(MemberSymbol method, Dictionary <DVariable, ISymbolValue> arguments, AbstractSymbolValueProvider vp)
        {
            var dm   = method.Definition as DMethod;
            var eval = new FunctionEvaluation(method, vp, arguments);

            var ctxt = vp.ResolutionContext;

            ctxt.PushNewScope(dm, dm.Body);

            try
            {
                dm.Body.Accept(eval);
            }
            catch (CtfeException ex)
            {
                vp.LogError(dm, "Can't execute function at precompile time: " + ex.Message);
            }

            var ret = Evaluation.GetVariableContents(eval.returnedValue, eval.vp);

            ctxt.Pop();

            return(ret);

            //return new ErrorValue(new EvaluationException("CTFE is not implemented yet."));
        }
예제 #3
0
        public static ISymbolValue Execute(MemberSymbol method, Dictionary<DVariable, ISymbolValue> arguments, AbstractSymbolValueProvider vp)
        {
            var dm = method.Definition as DMethod;
            var eval = new FunctionEvaluation(method,vp,arguments);

            var ctxt = vp.ResolutionContext;
            ctxt.PushNewScope(dm, dm.Body);

            try
            {
                dm.Body.Accept(eval);
            }
            catch (CtfeException ex)
            {
                vp.LogError(dm, "Can't execute function at precompile time: " + ex.Message);
            }

            var ret = Evaluation.GetVariableContents(eval.returnedValue, eval.vp);

            ctxt.Pop();

            return ret;

            //return new ErrorValue(new EvaluationException("CTFE is not implemented yet."));
        }