private static SymT GatherSymTs(SVX_MSG msg) { return(GatherUsefulSymTs(msg) ?? new SymTNondet { messageTypeFullName = msg.GetType().FullName }); }
private static void TransferProd(SVX_MSG msg, Principal producer, Principal sender, Principal realRequestProducer, bool browserOnly) { var originalSymT = (SymT)msg.SVX_symT ?? new SymTNondet { messageTypeFullName = msg.GetType().FullName }; // XXX Warn if one is set and the other isn't? if (realRequestProducer != null && msg.SVX_placeholderRequestProducer != null) { // Replace the server-issued facet with the real principal. We // could also strip the SymTTransfer layers, but this should // leave it clearer what happened. // If we try to define ProducerReplacer as a lambda, we get "Use // of unassigned local variable" on the recursive call. originalSymT = new ProducerReplacer { oldProducer = msg.SVX_placeholderRequestProducer, newProducer = realRequestProducer }.Rewrite(originalSymT); } msg.SVX_symT = new SymTTransfer { originalSymT = originalSymT, producer = producer, sender = sender, hasSender = true, browserOnly = browserOnly }; msg.active = true; }
private static SymT GatherUsefulSymTs(SVX_MSG msg) { // Want to warn if the msg is inactive but has a symT set, at least // for the root message (possible developer mistake)? SymT rootSymT = msg.active ? (SymT)msg.SVX_symT : null; var nestedSymTs = ( // NOTE: This will traverse into PayloadSecrets that contain // messages, which is what we want. from acc in FieldFinder <SVX_MSG> .FindFields(msg.GetType(), // We do our own recursion in matches. false) let nestedMsg = acc.nullConditionalGetter(msg) where nestedMsg != null let nestedSymT = GatherUsefulSymTs(nestedMsg) where nestedSymT != null select new NestedSymTEntry { fieldPath = acc.path, symT = nestedSymT } ).ToArray(); // As a simplification, don't unnecessarily create composites // (though it shouldn't break anything). And if we have no // information, return null so an outer message doesn't // unnecessarily create a composite. if (nestedSymTs.Length == 0) { return(rootSymT); // may be null } if (rootSymT == null) { rootSymT = new SymTNondet { messageTypeFullName = msg.GetType().FullName } } ; return(new SymTComposite { RootSymTWithMessageId = rootSymT, nestedSymTs = nestedSymTs }); }
private static void TransferNestedProd(SVX_MSG msg, Principal producer) { msg.SVX_symT = new SymTTransfer { originalSymT = (SymT)msg.SVX_symT ?? new SymTNondet { messageTypeFullName = msg.GetType().FullName }, producer = producer, hasSender = false }; msg.active = true; }
internal static void WipeActiveFlags(SVX_MSG msg) { if (msg != null) { msg.active = false; // FIXME: What if a field contains an object whose dynamic type // contains more nested messages than the static type of the // field? We should fix this for all FieldFinder callers at // once. ~ REDACTED 2016-08-16 foreach (var acc in FieldFinder <SVX_MSG> .FindFields(msg.GetType(), // We do our own recursion in matches since it's cleaner. false)) { WipeActiveFlags(acc.nullConditionalGetter(msg)); } } }