Example #1
0
        internal override string Show(ElaValue value, ExecutionContext ctx)
        {
            var d = value.Ref.AsDouble();

            if (Double.IsInfinity(d) || Double.IsNaN(d))
            {
                return(value.ToString());
            }
            else
            {
                return(value.ToString() + "d");
            }
        }
Example #2
0
        internal override string Show(ElaValue value, ExecutionContext ctx)
        {
            var d = value.DirectGetSingle();

            if (Single.IsInfinity(d) || Single.IsNaN(d))
            {
                return(value.ToString());
            }
            else
            {
                return(value.ToString() + "f");
            }
        }
Example #3
0
        private string PrintValue(ElaValue value)
        {
            try
            {
                var result = String.Empty;
                var hdl    = new AutoResetEvent(false);
                var th     = new Thread(() =>
                {
                    var obj = value.AsObject();

                    if (obj is ElaLazy)
                    {
                        result = ((ElaLazy)obj).Force().AsObject().ToString();
                    }
                    else if (obj is ElaLazyList)
                    {
                        var lalist = (ElaLazyList)obj;
                        result     = ElaList.FromEnumerable(lalist.Take(20)).ToString() + " (lazy)";
                    }
                    else
                    {
                        result = value.ToString();
                    }

                    hdl.Set();
                });
                th.Start();

                if (!hdl.WaitOne(500))
                {
                    th.Abort();
                    result = "<evaluation timeout>";
                }

                if (result == null)
                {
                    return("_|_");
                }
                else if (result.Trim().Length == 0)
                {
                    result = "[" + value.GetTypeName() + "]";
                }

                return(result);
            }
            catch (Exception)
            {
                return("<evaluation error>");
            }
        }
Example #4
0
        internal override ElaValue Concatenate(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            right = right.Ref.Force(right, ctx);

            if (right.TypeId != ElaMachine.STR)
            {
                if (right.TypeId == ElaMachine.CHR)
                    return new ElaValue(left.DirectGetString() + right.ToString());

                NoOverloadBinary(TCF.STRING, right, "concatenate", ctx);
                return Default();
            }

            return new ElaValue(left.DirectGetString() + right.DirectGetString());
        }
Example #5
0
        internal override ElaValue Concatenate(ElaValue left, ElaValue right, ExecutionContext ctx)
        {
            right = right.Ref.Force(right, ctx);

            if (right.TypeId != ElaMachine.CHR)
            {
                if (right.TypeId == ElaMachine.STR)
                {
                    return(new ElaValue(left.ToString() + right.DirectGetString()));
                }

                NoOverloadBinary(TCF.CHAR, right, "concatenate", ctx);
                return(Default());
            }

            return(new ElaValue(((Char)left.I4).ToString() + (Char)right.I4));
        }
Example #6
0
 internal override string Show(ElaValue value, ExecutionContext ctx)
 {
     return(value.ToString());
 }
Example #7
0
 internal override string Show(ElaValue value, ExecutionContext ctx)
 {
     return value.ToString();
 }
Example #8
0
        internal override string Show(ElaValue value, ExecutionContext ctx)
        {
            var d = value.DirectGetSingle();

            if (Single.IsInfinity(d) || Single.IsNaN(d))
                return value.ToString();
            else
                return value.ToString() + "f";
        }
Example #9
0
        internal override string Show(ElaValue value, ExecutionContext ctx)
        {
            var d = value.Ref.AsDouble();

            if (Double.IsInfinity(d) || Double.IsNaN(d))
                return value.ToString();
            else
                return value.ToString() + "d";
        }
Example #10
0
 public ElaValue ToString(string format, ElaValue val)
 {
     return(new ElaValue(val.ToString(format, Culture.NumberFormat)));
 }
Example #11
0
 public void InvalidFormat(string format, ElaValue value)
 {
     Fail(ElaRuntimeError.InvalidFormat, format, value.ToString(), value.GetTypeName());
 }
Example #12
0
 public void IndexOutOfRange(ElaValue index, ElaValue obj)
 {
     Fail(ElaRuntimeError.IndexOutOfRange, index.ToString(), index.GetTypeName(),
         obj.ToString(), obj.GetTypeName());
 }
Example #13
0
 public void DivideByZero(ElaValue value)
 {
     Fail(ElaRuntimeError.DivideByZero, value.ToString(), value.GetTypeName());
 }
Example #14
0
 public void UnknownField(string field, ElaValue given)
 {
     Fail(ElaRuntimeError.UnknownField, field, given.ToString(), given.GetTypeName());
 }