public RecordNode(IRContext irContext, IReadOnlyDictionary <DName, IntermediateNode> fields) : base(irContext) { Contracts.AssertAllValid(fields.Keys); Contracts.AssertAllValues(fields.Values); Fields = fields; }
// Removes the specified item from the tree, and returns a new tree. // If any item in 'names' cannot be found, sets fAnyMissing to true. public ValueTree RemoveItems(ref bool fAnyMissing, params DName[] names) { Contracts.AssertNonEmpty(names); Contracts.AssertAllValid(names); RedBlackNode <EquatableObject> root = _root; foreach (string name in names) { Contracts.AssertNonEmpty(name); root = RedBlackNode <EquatableObject> .RemoveItem(ref fAnyMissing, root, name, _hashCodeCache); } return(new ValueTree(root)); }
// Removes the specified item from the tree, and returns a new tree. // If any item in rgname cannot be found, sets fAnyMissing to true. public TypeTree RemoveItems(ref bool fAnyMissing, params DName[] rgname) { Contracts.AssertNonEmpty(rgname); Contracts.AssertAllValid(rgname); RedBlackNode <DType> root = _root; foreach (string name in rgname) { Contracts.AssertNonEmpty(name); root = RedBlackNode <DType> .RemoveItem(ref fAnyMissing, root, name, _hashCodeCache); } return(new TypeTree(root)); }
public override bool CheckInvocation(TexlBinding binding, TexlNode[] args, DType[] argTypes, IErrorContainer errors, out DType returnType, out Dictionary <TexlNode, DType> nodeToCoercedTypeMap) { Contracts.AssertValue(args); Contracts.AssertAllValues(args); Contracts.AssertValue(argTypes); Contracts.AssertAllValid(argTypes); Contracts.Assert(args.Length == argTypes.Length); Contracts.AssertValue(errors); Contracts.Assert(MinArity <= args.Length && args.Length <= MaxArity); nodeToCoercedTypeMap = null; bool isValid = true; DType argType = argTypes[0]; if (!DType.Number.Accepts(argType) && !DType.String.Accepts(argType)) { if (argType.CoercesTo(DType.DateTime) && !argType.IsControl) { CollectionUtils.Add(ref nodeToCoercedTypeMap, args[0], DType.DateTime); } else { errors.EnsureError(DocumentErrorSeverity.Severe, args[0], TexlStrings.ErrNumberOrStringExpected); isValid = false; } } if (args.Length > 1) { argType = argTypes[1]; if (!DType.String.Accepts(argType)) { errors.EnsureError(DocumentErrorSeverity.Severe, args[1], TexlStrings.ErrStringExpected); isValid = false; } } returnType = DType.Number; return(isValid); }