private static IEnumerable <Json> Function( List <IJsonMasherOperator> mashers, Json json, IMashContext context) { context.Tick(); context.LogValue(Json.ArrayParams(Json.String("DEBUG"), json)); yield return(json); }
public IEnumerable <Json> Mash(Json json, IMashContext context) { context = context.PushStack(this); context.Tick(); var result = new List <Json>(); try { foreach (var value in TryBody.Mash(json, context)) { result.Add(value); } } catch (JsonMasherException ex) { if (CatchBody != null) { foreach (var value in CatchBody.Mash(Json.String(ex.Message), context)) { result.Add(value); } } } return(result); }
public IEnumerable <Json> Mash(Json json, IMashContext context) { context = context.PushStack(this); context.Tick(); var result = Descriptor switch { FunctionName name => CallFunctionName(name, json, context), Builtin builtin => RunBuiltin(builtin, json, context), _ => throw new InvalidOperationException() }; return(result); }
private static IEnumerable <Json> Function_1( List <IJsonMasherOperator> mashers, Json json, IMashContext context) { foreach (var maxValue in mashers[0].Mash(json, context)) { for (int i = 0; i < maxValue.GetNumber(); i++) { context.Tick(); yield return(Json.Number(i)); } } }
private static IEnumerable <Json> Function( List <IJsonMasherOperator> mashers, Json json, IMashContext context) { if (mashers.Count != 2) { throw new InvalidOperationException(); } foreach (var t1 in mashers[0].Mash(json, context)) { if (!t1.GetBool()) { context.Tick(); yield return(Json.False); } else { foreach (var t2 in mashers[1].Mash(json, context)) { context.Tick(); yield return(Json.Bool(t2.GetBool())); } } } }
private static IEnumerable <Json> Function_3( List <IJsonMasherOperator> mashers, Json json, IMashContext context) { foreach (var startValue in mashers[0].Mash(json, context)) { foreach (var maxValue in mashers[1].Mash(json, context)) { foreach (var stepValue in mashers[2].Mash(json, context)) { double start = startValue.GetNumber(); double max = maxValue.GetNumber(); double step = stepValue.GetNumber(); for (double i = start; i < max; i += step) { context.Tick(); yield return(Json.Number(i)); } } } } }