protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack)
        {
            if (values.Count == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Constants:");
                foreach (string func in GetConstants())
                {
                    Console.WriteLine(GetConstantHelp(func));
                    Console.WriteLine();
                }

                Console.WriteLine("Functions:");
                foreach (string func in GetFunctions())
                {
                    Console.WriteLine(GetFunctionHelp(func));
                    Console.WriteLine();
                }
            }
            else
            {
            }

            return(NullValue.Null);
        }
            public ProxyIdentifierStore(IdentifierStore parent, IReadOnlyDictionary <string, Value> proxies)
            {
                foreach (KeyValuePair <string, Value> proxy in proxies)
                {
                    identifiers.Add(proxy.Key, proxy.Value);
                }

                Parent = parent;
            }
            public Value GetValue(List <Value> values, IdentifierStore identifierStore = null, CallStack callstack = null)
            {
                if (values.Count < parent.MinParameterCount || values.Count > parent.MaxParameterCount)
                {
                    throw new InvalidOperationException("Value count doesn´t match parameter count");
                }

                return(parent.CalculateValue(values, identifierStore, callstack));
            }
        protected override Value GetValueInternal(bool execute = true)
        {
            IdentifierStore store = (Identifiers ?? IdentifierStore.Global);

            if (!store.Contains(Identifier))
            {
                throw new ExpressionException(Callstack, $"Identifier '{Identifier}' not found");
            }

            return((Identifiers ?? IdentifierStore.Global)[Identifier, true]);
        }
        protected override Value GetValueInternal(bool execute = true)
        {
            IdentifierStore store = (Identifiers ?? IdentifierStore.Global);

            if (!store.Contains(Identifier))
            {
                throw new IdentifierNotFoundExpressionException(Callstack, Identifier);
            }

            return((Identifiers ?? IdentifierStore.Global)[Identifier]);
        }
Beispiel #6
0
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack) => values.CastingRequest()
 .With((TextValue v) =>
 {
     try
     {
         return(LoadFile.ExecuteFile(((TextValue)values[0]).Text));
     }
     catch (Exception e)
     {
         throw new ExpressionException(callstack, "ExecuteFile(" + values[0].ToString() + ") failed", e);
     }
 })
 .GetResult();
Beispiel #7
0
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack) => values.CastingRequest()
 .With((IntValue b, IntValue e) =>
 {
     int val = 1;
     for (int i = 0; i < e; i = i + 1)
     {
         val *= (int)b;
     }
     return((IntValue)val);
 })
 .With((DecimalValue b, DecimalValue e) => (DecimalValue)Math.Pow((double)b, (double)e))
 .With((FractionValue b, FractionValue e) => b ^ e)
 .GetResult();
Beispiel #8
0
        public Value GetValue(List <Value> values, IdentifierStore identifierStore = null, CallStack callstack = null)
        {
            identifierStore = identifierStore ?? IdentifierStore.Global;
            callstack       = callstack ?? new CallStack();

            if (values.Count != parameters.Count)
            {
                throw new InvalidOperationException("Value count doesn´t match parameter count");
            }

            var dict = parameters.Zip(values, (k, v) => new { k, v })
                       .ToDictionary(x => x.k, x => x.v);

            identifierStore = identifierStore.NewScopeWith(dict);

            Expression.Identifiers = identifierStore;
            Expression.This        = this;
            return(Expression.GetValue(callstack));
        }
            public Value GetValue(List <Value> values, IdentifierStore identifierStore = null, CallStack callstack = null)
            {
                Value returned;

                if (values.Count == 0)
                {
                    returned = NullValue.Null;
                }
                else if (values.Count == 1)
                {
                    returned = values[0];
                }
                else
                {
                    returned = new ListValue(values);
                }
                callstack.Result = returned;
                callstack.Flags |= CallStack.ReturnFlags.Return;
                return(returned);
            }
Beispiel #10
0
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack) => values.CastingRequest()
 .With((IntValue v) => (DecimalValue)Math.Sqrt((int)v))
 .With((DecimalValue v) => (DecimalValue)Math.Sqrt((double)v))
 .With((FractionValue v) => (DecimalValue)Math.Sqrt((double)v))
 .GetResult();
Beispiel #11
0
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack)
 {
     return(func(values, identifierStore, callstack));
 }
Beispiel #12
0
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstacks) => values.CastingRequest(false)
 .With((Value[] v) =>
 {
     return(Sum(v) ?? NullValue.Null);
 })
 .GetResult();
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstacks) => values.CastingRequest(false)
 .With((ListValue values) =>
 protected override Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack) => CalculateProduct(values);
 public ProxyIdentifierStore(IdentifierStore parent)
 {
     Parent = parent;
 }
 protected abstract Value CalculateValue(List <Value> values, IdentifierStore identifierStore, CallStack callstack);