예제 #1
0
 private static SymT GatherSymTs(SVX_MSG msg)
 {
     return(GatherUsefulSymTs(msg) ??
            new SymTNondet {
         messageTypeFullName = msg.GetType().FullName
     });
 }
예제 #2
0
        private static void RecordCall(SVX_MSG output, Delegate del, SymT[] inputSymTs)
        {
            Participant participant = del.Target as Participant;

            if (participant == null)
            {
                throw new ArgumentException("Delegate must belong to an SVX participant object");
            }
            MethodInfo mi = del.GetMethodInfo();

            output.SVX_symT = new SymTMethod
            {
                participantId = new SymTParticipantId
                {
                    principal    = participant.SVX_Principal,
                    typeFullName = participant.GetType().FullName
                },
                // XXX Verify that method is unique and doesn't use generics?
                methodName = mi.Name,
                methodReturnTypeFullName = mi.ReturnType.FullName,
                methodArgTypeFullNames   = (from p in mi.GetParameters() select p.ParameterType.FullName).ToArray(),
                inputSymTs = inputSymTs,
            };
            output.active = true;
        }
예제 #3
0
        internal static void Transfer(SVX_MSG msg, Principal producer, Principal sender,
                                      Principal realRequestProducer, bool browserOnly)
        {
            if (producer == null || sender == null)
            {
                // Auto-generate them instead?  But we'd need to know the issuer.
                // We may eventually have a global variable for the current party.
                throw new ArgumentNullException();
            }

            if (VProgram_API.InVProgram)
            {
                if (browserOnly)
                {
                    Contract.Assume(!VProgram_API.ActsFor(sender, VProgram_API.trustedServerPrincipal));
                }
            }
            else
            {
                TransferProd(msg, producer, sender, realRequestProducer, browserOnly);
            }

            // Make the same metadata changes in the vProgram as in production.
            msg.SVX_producer = producer;
            msg.SVX_sender   = sender;
            msg.SVX_placeholderRequestProducer = null;
        }
예제 #4
0
        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;
        }
예제 #5
0
 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;
 }
예제 #6
0
 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));
         }
     }
 }
예제 #7
0
        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
            });
        }
예제 #8
0
        internal static void TransferNested(SVX_MSG msg, Principal producer)
        {
            if (producer == null)
            {
                // Auto-generate it instead?  But we'd need to know the issuer.
                // We may eventually have a global variable for the current party.
                throw new ArgumentNullException();
            }

            if (!VProgram_API.InVProgram)
            {
                TransferNestedProd(msg, producer);
            }

            // Make the same metadata changes in the vProgram as in production.
            msg.SVX_producer = producer;
            // Do not change sender.
            msg.SVX_placeholderRequestProducer = null;
        }
예제 #9
0
 // In support of old examples.  Won't be part of the real SVX API.
 public static void TransferForTesting(SVX_MSG msg, Principal producer, Principal sender)
 {
     Transfer(msg, producer, sender, null, false);
 }