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"); } }
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"); } }
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>"); } }
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()); }
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)); }
internal override string Show(ElaValue value, ExecutionContext ctx) { return(value.ToString()); }
internal override string Show(ElaValue value, ExecutionContext ctx) { return value.ToString(); }
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"; }
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"; }
public ElaValue ToString(string format, ElaValue val) { return(new ElaValue(val.ToString(format, Culture.NumberFormat))); }
public void InvalidFormat(string format, ElaValue value) { Fail(ElaRuntimeError.InvalidFormat, format, value.ToString(), value.GetTypeName()); }
public void IndexOutOfRange(ElaValue index, ElaValue obj) { Fail(ElaRuntimeError.IndexOutOfRange, index.ToString(), index.GetTypeName(), obj.ToString(), obj.GetTypeName()); }
public void DivideByZero(ElaValue value) { Fail(ElaRuntimeError.DivideByZero, value.ToString(), value.GetTypeName()); }
public void UnknownField(string field, ElaValue given) { Fail(ElaRuntimeError.UnknownField, field, given.ToString(), given.GetTypeName()); }