public override Value Evaluate() { if (isTrue()) { var verbResult = verb.Evaluate(); result = statement.Map(s => s.Result).DefaultTo(() => ""); typeName = statement.Map(s => s.TypeName).DefaultTo(() => ""); Index = statement.Map(s => s.Index).DefaultTo(() => 0); return(verbResult); } return(null); }
public override Value AlternateValue(string message) { if (stop == -1) { return(new Array()); } var length = arrayLength.Map(l => l, () => (int)Ceiling((decimal)((stop - start) / increment))); var array = length <= MAX_LOOP?Array.SliceRange(start, stop, length, Inside, increment) : new IntLazyArray(start, stop, increment); return(array); }
public override int GetHashCode() { unchecked { var hashCode = mutable.GetHashCode(); hashCode = hashCode * 397 ^ (name?.GetHashCode() ?? 0); hashCode = hashCode * 397 ^ (label?.GetHashCode() ?? 0); hashCode = hashCode * 397 ^ (_defaultValue?.GetHashCode() ?? 0); hashCode = hashCode * 397 ^ _typeConstraint.Map(tc => tc.Hash).DefaultTo(() => 0); hashCode = hashCode * 397 ^ reference.GetHashCode(); hashCode = hashCode * 397 ^ capturing.GetHashCode(); return(hashCode); } }
public Value Next(int index) { if (_generator.IsNone) { _generator = value.Evaluate().IfCast <IGenerator>(); } return(_generator.Map(generator => generator.Next(index)).DefaultTo(() => NilValue)); }
public override Value Evaluate() { var value = expression.Map(e => e.Evaluate().AssignmentValue()).DefaultTo(() => new Nil()); typeName = value.Type.ToString(); State.ReturnValue = value; State.ReturnSignal = true; return(value); }
public Finder(string pattern, bool not, IMaybe <string> _unless, string include, string includeExt, string exclude, string excludeExt) { if (not) { matches = line => !line.IsMatch(pattern); } else { matches = line => line.IsMatch(pattern); } if (not) { getMatcher = _ => notMatched <Result>(); } else { getMatcher = line => ((Matcher)pattern).Matches(line); } unless = _unless.Map(unless => (Func <string, bool>)(line => !line.IsMatch(unless))).DefaultTo(() => _ => false); if (include.IsNotEmpty()) { includeFile = file => file.NameExtension.IsMatch(include); } else if (includeExt.IsNotEmpty()) { includeFile = file => file.Extension.EndsWith(includeExt); } else { includeFile = _ => true; } if (exclude.IsNotEmpty()) { excludeFile = file => !file.NameExtension.IsMatch(include); } else if (excludeExt.IsNotEmpty()) { excludeFile = file => !file.Extension.EndsWith(excludeExt); } else { excludeFile = _ => false; } }
public override string ToString() { return($"?{selector}({arguments.Select(a => a.ToString()).ToString(", ")})" + lambda.Map(l => $" {l}").DefaultTo(() => "")); }
public override Value Clone() { return(new NSInnerComprehension((Parameters)parameters.Clone(), (Block)generatorSource.Clone(), ifBlock.Map(b => ((Block)b.Clone()).Some())) { NextComprehension = NextComprehension.Map(c => ((NSInnerComprehension)c.Clone()).Some()) }); }
public IMaybe <string> ReadLine() => textBoxInterface.Map(tbi => tbi.Reader.ReadLine().SomeIfNotNull());
public void Map_Theory(IMaybe <int> m1, Func <int, string> mapFn, object expectation) { var result = m1.Map(mapFn); Assert.Equal(expectation, result); }
public ObjectRegionPopper(IMaybe <ObjectRegion> objectRegion, string name) : base(null, name) { exists = objectRegion.IsSome; region = objectRegion.Map(r => r).DefaultTo(() => null); }
public static IObject AsOptional <T>(this IMaybe <T> maybe) where T : IObject { return(maybe.Map(o => Some.Object(o)).DefaultTo(() => None.NoneValue)); }
public override string ToString() => $"maybe {fieldName} = {expression} ({ifTrue}){_ifFalse.Map(f => $" ({f})").DefaultTo(() => "")}";
public override string ToString() { return(stream() / fieldName / " " / _operation.Map(o => o.ToString()).DefaultTo(() => "") / "= " / expression); }
public override Value Clone() { var yielding = _yielding.Map(y => (Block)y.Clone()); return(new LoopRange(variable, (Block)init.Clone(), positive, (Block)condition.Clone(), (Block)increment.Clone(), yielding, region.Clone())); }
public override string ToString() { return($"assert{_error.Map(_ => "!").DefaultTo(() => "?")} {condition} : {value}{_error.Map(e => $" : {e}").DefaultTo(() => "")}"); }
public override string ToString() { return((StringStream)"" / (reference, "ref ") / (mutable, "var ") / label.Map(l => $"{l}: ") / name / _typeConstraint.Map(t => t.Image).DefaultTo(() => "") / _defaultValue.Map(i => $" = {i.Image}").DefaultTo(() => "")); }