public override Value Execute(Args args, Environment environment, SourcePos pos) { return(ValueBoolean.From(args.Get("obj").IsNull())); }
public override Value Execute(Args args, Environment environment, SourcePos pos) { return(args.GetAsInt("obj")); }
public override Value Execute(Args args, Environment environment, SourcePos pos) { if (args.IsNull("list")) { return(ValueNull.NULL); } var list = args.GetList("list").GetValue(); var ignore = new List <Value>(); if (args.HasArg("ignore")) { ignore.AddRange(args.GetList("ignore").GetValue()); } var resultdecimal = (decimal)0; var resultint = 0L; var decimalrequired = false; foreach (var value in list) { var skipvalue = false; foreach (var ignoreval in ignore) { if (ignoreval.IsEquals(value)) { skipvalue = true; break; } } if (skipvalue) { continue; } if (decimalrequired) { resultdecimal += value.AsDecimal().GetValue(); } else if (value.IsInt()) { resultint += value.AsInt().GetValue(); } else if (value.IsDecimal()) { if (!decimalrequired) { decimalrequired = true; resultdecimal = resultint; } resultdecimal += value.AsDecimal().GetValue(); } else { throw new ControlErrorException(new ValueString("ERROR"), "Cannot sum " + value, pos); } } if (decimalrequired) { return(new ValueDecimal(resultdecimal)); } return(new ValueInt(resultint)); }