code: public Binding createBinding(final Map<String, Object> context) {
      Binding binding = new Binding();
  
      log.debug("Binding:");
      for (Entry<String, Object> entry : context.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
  
        if (value instanceof ClosureTarget) {
          value = createClosure(this, (ClosureTarget) value);
        }
        else if (value instanceof MagicContext) {
          value = createMagicContextValue((MagicContext) value);
        }
  
        log.debug("  {}={}", key, value);
        binding.setVariable(entry.getKey(), value);
      }
  
      return binding;
    }
docs: Create script binding, handling conversion of {@link ClosureTarget} and {@link MagicContext} entries.