internal WorkerThread(CodeAssembly asm) { Assembly = asm; Module = asm.GetRootModule(); CallStack = new CallStack(); Context = new ExecutionContext(); }
protected override ElaValue Convert(ElaValue @this, ElaTypeInfo type, ExecutionContext ctx) { if (type.ReflectedTypeCode == ElaTypeCode.String) return new ElaValue(Value.ToString()); ctx.ConversionFailed(@this, type.ReflectedTypeName); return Default(); }
protected override bool NotEqual(ElaValue left, ElaValue right, ExecutionContext ctx) { var lg = left.As<ElaGuid>(); var rg = right.As<ElaGuid>(); if (lg != null && rg != null) return lg.Value != rg.Value; else if (lg != null) return right.NotEqual(left, right, ctx); return true; }
protected override string Show(ElaValue @this, ShowInfo info, ExecutionContext ctx) { return !String.IsNullOrEmpty(info.Format) ? Value.ToString(info.Format) : Value.ToString(); }
protected override ElaValue GetValue(ElaValue index, ExecutionContext ctx) { var val = default(ElaValue); if (!Map.TryGetValue(index, out val)) { ctx.Fail(NOKEY, String.Format("An element with a key '{0}' doesn't exist.", index)); return Default(); } return val; }
//protected override void SetValue(ElaValue index, ElaValue value, ExecutionContext ctx) //{ // if (Map.ContainsKey(index)) // Map.Add(index, value); // else // Map[index] = value; //} protected override ElaValue GetLength(ExecutionContext ctx) { return new ElaValue(Map.Count); }
protected override string Show(ElaValue @this, ShowInfo info, ExecutionContext ctx) { return new ElaValue(ConvertToRecord()).Show(info, ctx); }