Stores a reference to the current context, creates a nested new one,
 yields to the given block and then restores the previous context.

 @param klass [Context::*Context] context class
 @param args arguments for the class initializer
 @yield block
972813
def inside_new_context(klass, *args)
      new_context = append_new_context(klass, *args)

      orig, self.current_context = current_context, new_context
      yield
      self.current_context = orig
    end
215768
def reapply(&block)
      raise ArgumentError.new('Block required') unless block
      raise InvalidDeferredError.new('reapply must be run inside of a context') unless @context

      if reapply?
        yield
      end

      block = block.weak!
      parent_layout.reapply_blocks << [@context, block]
      return self
    end
423331
function(context, args, stack) {
		var ctx = new Context(args[0], args[1] || context);
		stack.push(ctx);
		return ctx;
	}
761209
def each_registered_block(type, &block)
        klass = self.class
        while klass.respond_to?(type)
          klass.public_send(type).each(&block)
          klass = klass.superclass
        end
      end
1225414
def singleton(name, klass = nil, &block)
      @registry[name.to_sym] = Resolver::Singleton.new(block || klass)
    end
862690
def pool_context(*args, **kwargs):
    
    pool = Pool(*args, **kwargs)
    try:
        yield pool
    except Exception as e:
        raise e
    finally:
        pool.terminate()
1022298
function construct(klass, args) {
  function T() {
    klass.apply(this, arguments[0]);
  }
  T.prototype = klass.prototype;
  return new T(args);
}
42403
def extract_context(user, args)
      context = {}
      context[:user] = user
      if takes_parent_object
        context[:parent_object] = args.shift or raise ArgumentError, "No parent object given"
      end
      if takes_object
        context[:object] = args.shift or raise ArgumentError, "No object given"
      end
      OpenStruct.new(context)
    end
1143756
def factory(name, klass = nil, &block)
      @registry[name.to_sym] = Resolver::Factory.new(block || klass)
    end
1192108
def initialize_coercer(klass)
      coercers[klass] =
        begin
          coercer = Coercer::Object.determine_type(klass) || Coercer::Object
          args    = [ self ]
          args   << config_for(coercer) if coercer.respond_to?(:config_name)
          coercer.new(*args)
        end
    end
755161
def add_deferred_block(context, &block)
      context ||= @context
      if context.nil? && @assign_root
        context ||= self.create_default_root_context
      end
      raise InvalidDeferredError.new('deferred must be run inside of a context') unless context
      raise ArgumentError.new('Block required') unless block

      self.deferred_blocks << [context, block]
    end
626513
private void initialize(Map context) {
    // Guard against recursion.
    context.put(jsTypeTree, this);

    // Create temporary accumulators for the contents of the fields and variants instance
    // variables.
    List tmpFields = new ArrayList();
    List tmpVariants = new ArrayList();

    // Perform tasks assigned to the recursive 'number' subroutine (see comment there)
    number(jsTypeTree, context, false, 0, tmpFields, tmpVariants);

    // Move information from temporaries into permanent instance variables
    fields = (JSField[])tmpFields.toArray(new JSField[0]);
    variants = (JSVariant[])tmpVariants.toArray(new JSVariant[0]);

    // Compute the contents of the 'boxed' instance variable, which is deriveable from the
    // contents of those JSVariants which have found their way into 'fields.'  These are
    // all intended to be boxed variants because they were detected to be underneath
    // JSRepeated nodes during the 'number' process.
    int boxLen = 0; // accumulate total length of boxed array
    for (int i = 0; i < fields.length; i++)
      if (fields[i] instanceof JSVariant)
        // On the first pass, we box the variant and accumulate its accessor count
        boxLen += ((JSVariant)fields[i]).box(context).getAccessorCount();
    boxed = new int[boxLen][];
    int boxIndex = 0;

    // On the second pass through the boxed variants, we get their accessor count a second
    // time and use it this time to fill in the contents of the 'boxed' instance variable
    // proper.
    for (int i = 0; i < fields.length; i++)
      if (fields[i] instanceof JSVariant)
        for (int j = 0; j < ((JSVariant)fields[i]).getBoxed().getAccessorCount(); j++)
          boxed[boxIndex++] = new int[] { i, j };

    // Set the 'accessor' property of every JSField in the tree (see comment on
    // setAccessors).
    setAccessors(0, this);

    // Set the multiChoiceCount for each node in the tree.  Note this must be done
    // after boxing any variants found underneath JSRepeated nodes, since boxing changes
    // the multiChoiceCount.  setMultiChoiceCount is a recursive method that will set
    // counts starting from the leaves working back to the root.
    jsTypeTree.setMultiChoiceCount();

    // Compute the serialForm if it isn't already there due to the deserializing
    // constructor
    if (serialForm == null) {
      // Store the name in a convenient non-null form
      name = jsTypeTree.getFeatureName();
      if (name == null)
        name = "";
      try {
        byte[] utfname = name.getBytes("UTF8");
        serialForm = new byte[2 + utfname.length + 2 + jsTypeTree.encodedTypeLength()];
        ArrayUtil.writeShort(serialForm, 0, (short)utfname.length);
        System.arraycopy(utfname, 0, serialForm, 2, utfname.length);
        int limits[] = new int[] { 2 + utfname.length, serialForm.length };
        JSType.setCount(serialForm, limits, version);
        jsTypeTree.encodeType(serialForm, limits);
      } catch (UnsupportedEncodingException e) {
        FFDCFilter.processException(e, "initialize", "604");
        IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
      }
    }

    // Compute the schemaID, which is a 64-bit truncated SHA-1 hash over the serialForm.
    schemaID = CryptoHash.hash(serialForm);
    schemaLongID = Long.valueOf(schemaID);
  }
683663
def context(&block)
      # Include the context
      context = @context
      machine.owner_class.class_eval { include context }
      
      # Evaluate the method definitions and track which ones were added
      old_methods = context_methods
      context.class_eval(&block)
      new_methods = context_methods.to_a.select {|(name, method)| old_methods[name] != method}
      
      # Alias new methods so that the only execute when the object is in this state
      new_methods.each do |(method_name, method)|
        context_name = context_name_for(method_name)
        context.class_eval <<-end_eval, __FILE__, __LINE__ + 1
          alias_method :"#{context_name}", :#{method_name}
          def #{method_name}(*args, &block)
            state = self.class.state_machine(#{machine.name.inspect}).states.fetch(#{name.inspect})
            options = {:method_missing => lambda {super(*args, &block)}, :method_name => #{method_name.inspect}}
            state.call(self, :"#{context_name}", *(args + [options]), &block)
          end
        end_eval
      end
      
      true
    end
166913
function( context, args ) {
				if ( stack ) {
					if ( firing ) {
						if ( !flags.once ) {
							stack.push( [ context, args ] );
						}
					} else if ( !( flags.once && memory ) ) {
						fire( context, args );
					}
				}
				return this;
			}
1251430
public T newInstance(Object... args) {
                try {
                        con.setAccessible(true);
                        return con.newInstance(args);
                } catch (Exception e) {
                        throw $(e);
                }
        }
1152173
def context(nodes, &block)
      nodes = nodes.first.is_a?(Matcher) ? nodes.first : WhitelistMatcher.new(nodes)
      @contexts << context = {:nodes => nodes, :block => block}
      
      # Evaluate the new context for existing nodes
      each {|node| eval_context(context, node)}
      
      context
    end
1369066
def call(*args)
      cache.fetch_or_store(args) do
        name, header, ns = args
        attributes = header.map(&method(:visit)).compact

        if attributes.empty?
          ROM::OpenStruct
        else
          build_class(name, ROM::Struct, ns) do |klass|
            klass.attributes(attributes.to_h)
          end
        end
      end
    end