Example #1
0
        /// <summary>
        /// Creates a fresh label with ID "*", and set it on the
        /// supplied <paramref name="entity"/> object.
        /// </summary>
        public void AddFreshLabel(IEntity entity)
        {
            var label = new Label(NewId());

            TrapWriter.Emit(new DefineFreshLabelEmitter(label));
            entity.Label = label;
        }
Example #2
0
 /// <summary>
 /// Runs the given action <paramref name="a"/>, guarding for trap duplication
 /// based on key <paramref name="key"/>.
 /// </summary>
 public virtual void WithDuplicationGuard(Key key, Action a)
 {
     tagStack.Push(key);
     TrapWriter.Emit(new PushEmitter(key));
     try
     {
         a();
     }
     finally
     {
         TrapWriter.Emit(new PopEmitter());
         tagStack.Pop();
     }
 }
Example #3
0
 /// <summary>
 /// Runs the given action <paramref name="a"/>, guarding for trap duplication
 /// based on key <paramref name="key"/>.
 /// </summary>
 public void WithDuplicationGuard(Key key, Action a)
 {
     if (Scope is AssemblyScope)
     {
         // No need for a duplication guard when extracting assemblies,
         // and the duplication guard could lead to method bodies being missed
         // depending on trap import order.
         a();
     }
     else
     {
         tagStack.Push(key);
         TrapWriter.Emit(new PushEmitter(key));
         try
         {
             a();
         }
         finally
         {
             TrapWriter.Emit(new PopEmitter());
             tagStack.Pop();
         }
     }
 }