//// Starlark bindings for individual graph methods.
489723
func nodesList(nodes []*Node) *starlark.List {
	vals := make([]starlark.Value, len(nodes))
	for i, n := range nodes {
		vals[i] = n
	}
	return starlark.NewList(vals)
}
450598
func (intr *Interpreter) execBuiltin() *starlark.Builtin {
	return starlark.NewBuiltin("exec", func(th *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
		var module starlark.String
		if err := starlark.UnpackArgs("exec", args, kwargs, "module", &module); err != nil {
			return nil, err
		}
		mod := module.GoString()

		// Only threads started via 'exec' (or equivalently ExecModule) can exec
		// other scripts. Modules that are loaded via load(...), or custom callbacks
		// from native code aren't allowed to call exec, since exec's impurity may
		// lead to unexpected results.
		if GetThreadKind(th) != ThreadExecing {
			return nil, fmt.Errorf("exec %s: forbidden in this context, only exec'ed scripts can exec other scripts", mod)
		}

		// See also th.Load in runModule.
		key, err := makeModuleKey(mod, th)
		if err != nil {
			return nil, err
		}
		dict, err := intr.ExecModule(Context(th), key.pkg, key.path)
		if err != nil {
			// Starlark stringifies errors using Error(). For EvalError, Error()
			// string is just a root cause, it does not include the backtrace where
			// the execution failed. Preserve it explicitly by sticking the backtrace
			// into the error message.
			//
			// Note that returning 'err' as is will preserve the backtrace inside
			// the execed module, but we'll lose the backtrace of the 'exec' call
			// itself, since EvalError object will just bubble to the top of the Go
			// call stack unmodified.
			if evalErr, ok := err.(*starlark.EvalError); ok {
				return nil, fmt.Errorf("exec %s failed: %s", mod, evalErr.Backtrace())
			}
			return nil, fmt.Errorf("cannot exec %s: %s", mod, err)
		}

		return starlarkstruct.FromStringDict(starlark.String("execed"), dict), nil
	})
}
818718
func bindingsGraphChecker() ClauseHook {
	var f ClauseHook
	f = func(s *Statement, _ Symbol) (ClauseHook, error) {
		// Force working projection flush.
		s.AddWorkingProjection()
		bs := s.BindingsMap()
		for _, b := range s.InputBindings() {
			if _, ok := bs[b]; !ok {
				return nil, fmt.Errorf("specified binding %s not found in where clause, only %v bindings are available", b, s.Bindings())
			}
		}
		return f, nil
	}
	return f
}
824149
func (p *pluginControl) getMetricsAndCollectors(requested []core.RequestedMetric, configTree *cdata.ConfigDataTree) (map[string]metricTypes, []core.SubscribedPlugin, []serror.SnapError) {
	newMetricsGroupedByPlugin := make(map[string]metricTypes)
	newPlugins := []core.SubscribedPlugin{}
	var serrs []serror.SnapError
	for _, r := range requested {
		// get all metric types available in metricCatalog which fulfill the requested namespace and version (if ver <=0 the latest version will be taken)
		newMetrics, err := p.metricCatalog.GetMetrics(r.Namespace(), r.Version())
		if err != nil {
			log.WithFields(log.Fields{
				"_block": "control",
				"action": "expanding-requested-metrics",
				"query":  r.Namespace(),
				"err":    err,
			}).Error("error matching requested namespace with metric catalog")
			serrs = append(serrs, serror.New(err))
			continue
		}

		if controlLogger.Level >= log.DebugLevel {
			for _, m := range newMetrics {
				controlLogger.WithFields(log.Fields{
					"_block":  "control",
					"ns":      m.Namespace().String(),
					"version": m.Version(),
				}).Debug("Expanded namespaces found in metric catalog")
			}
		}

		for _, mt := range newMetrics {
			// in case config tree doesn't have any configuration for current namespace
			// it's needed to initialize config, otherwise it will stay nil and panic later on
			cfg := configTree.Get(mt.Namespace().Strings())
			if cfg == nil {
				cfg = cdata.NewNode()
			}
			// set config to metric
			mt.config = cfg

			// apply the defaults from the global (plugin) config
			plType, _ := core.ToPluginType(mt.Plugin.TypeName())
			cfgNode := p.pluginManager.GetPluginConfig().getPluginConfigDataNode(plType, mt.Plugin.Name(), mt.Plugin.Version())
			cfg.ApplyDefaults(cfgNode.Table())

			// apply defaults to the metric that may be present in the plugins
			// configpolicy
			if pluginCfg := mt.Plugin.Policy().Get(mt.Namespace().Strings()); pluginCfg != nil {
				mt.config.ApplyDefaults(pluginCfg.Defaults())
			}

			// cataloged plugin which exposes the metric
			cp := mt.Plugin
			key := fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", cp.TypeName(), cp.Name(), cp.Version())

			// groups metricTypes by a plugin.Key()
			pmt, _ := newMetricsGroupedByPlugin[key]

			// pmt (plugin-metric-type) contains plugin and metrics types grouped to this plugin
			pmt.plugin = cp
			pmt.metricTypes = append(pmt.metricTypes, mt)
			newMetricsGroupedByPlugin[key] = pmt

			plugin := subscribedPlugin{
				name:     cp.Name(),
				typeName: cp.TypeName(),
				version:  cp.Version(),
				config:   cdata.NewNode(),
			}

			if !containsPlugin(newPlugins, plugin) {
				newPlugins = append(newPlugins, plugin)
			}
		}
	}
	if controlLogger.Level >= log.DebugLevel {
		for _, pmt := range newMetricsGroupedByPlugin {
			for _, m := range pmt.Metrics() {
				log.WithFields(log.Fields{
					"_block": "control",
					"action": "gather",
					"metric": fmt.Sprintf("%s:%d", m.Namespace().String(), m.Version()),
				}).Debug("gathered metrics from workflow request")
			}

		}
		for _, p := range newPlugins {
			log.WithFields(log.Fields{
				"_block": "control",
				"action": "gather",
				"metric": fmt.Sprintf("%s:%s:%d", p.TypeName(), p.Name(), p.Version()),
			}).Debug("gathered plugins from workflow request")
		}
	}

	return newMetricsGroupedByPlugin, newPlugins, serrs
}
729350
func (b *RefreshGraphBuilder) Steps() []GraphTransformer {
	// Custom factory for creating providers.
	concreteProvider := func(a *NodeAbstractProvider) dag.Vertex {
		return &NodeApplyableProvider{
			NodeAbstractProvider: a,
		}
	}

	concreteManagedResource := func(a *NodeAbstractResource) dag.Vertex {
		return &NodeRefreshableManagedResource{
			NodeAbstractResource: a,
		}
	}

	concreteManagedResourceInstance := func(a *NodeAbstractResourceInstance) dag.Vertex {
		return &NodeRefreshableManagedResourceInstance{
			NodeAbstractResourceInstance: a,
		}
	}

	concreteResourceInstanceDeposed := func(a *NodeAbstractResourceInstance, key states.DeposedKey) dag.Vertex {
		// The "Plan" node type also handles refreshing behavior.
		return &NodePlanDeposedResourceInstanceObject{
			NodeAbstractResourceInstance: a,
			DeposedKey:                   key,
		}
	}

	concreteDataResource := func(a *NodeAbstractResource) dag.Vertex {
		return &NodeRefreshableDataResource{
			NodeAbstractResource: a,
		}
	}

	steps := []GraphTransformer{
		// Creates all the managed resources that aren't in the state, but only if
		// we have a state already. No resources in state means there's not
		// anything to refresh.
		func() GraphTransformer {
			if b.State.HasResources() {
				return &ConfigTransformer{
					Concrete:   concreteManagedResource,
					Config:     b.Config,
					Unique:     true,
					ModeFilter: true,
					Mode:       addrs.ManagedResourceMode,
				}
			}
			log.Println("[TRACE] No managed resources in state during refresh; skipping managed resource transformer")
			return nil
		}(),

		// Creates all the data resources that aren't in the state. This will also
		// add any orphans from scaling in as destroy nodes.
		&ConfigTransformer{
			Concrete:   concreteDataResource,
			Config:     b.Config,
			Unique:     true,
			ModeFilter: true,
			Mode:       addrs.DataResourceMode,
		},

		// Add any fully-orphaned resources from config (ones that have been
		// removed completely, not ones that are just orphaned due to a scaled-in
		// count.
		&OrphanResourceInstanceTransformer{
			Concrete: concreteManagedResourceInstance,
			State:    b.State,
			Config:   b.Config,
		},

		// We also need nodes for any deposed instance objects present in the
		// state, so we can check if they still exist. (This intentionally
		// skips creating nodes for _current_ objects, since ConfigTransformer
		// created nodes that will do that during DynamicExpand.)
		&StateTransformer{
			ConcreteDeposed: concreteResourceInstanceDeposed,
			State:           b.State,
		},

		// Attach the state
		&AttachStateTransformer{State: b.State},

		// Attach the configuration to any resources
		&AttachResourceConfigTransformer{Config: b.Config},

		// Add root variables
		&RootVariableTransformer{Config: b.Config},

		// Add the local values
		&LocalTransformer{Config: b.Config},

		// Add the outputs
		&OutputTransformer{Config: b.Config},

		// Add module variables
		&ModuleVariableTransformer{Config: b.Config},

		TransformProviders(b.Components.ResourceProviders(), concreteProvider, b.Config),

		// Must attach schemas before ReferenceTransformer so that we can
		// analyze the configuration to find references.
		&AttachSchemaTransformer{Schemas: b.Schemas},

		// Connect so that the references are ready for targeting. We'll
		// have to connect again later for providers and so on.
		&ReferenceTransformer{},

		// Target
		&TargetsTransformer{
			Targets: b.Targets,

			// Resource nodes from config have not yet been expanded for
			// "count", so we must apply targeting without indices. Exact
			// targeting will be dealt with later when these resources
			// DynamicExpand.
			IgnoreIndices: true,
		},

		// Close opened plugin connections
		&CloseProviderTransformer{},

		// Single root
		&RootTransformer{},
	}

	if !b.DisableReduce {
		// Perform the transitive reduction to make our graph a bit
		// more sane if possible (it usually is possible).
		steps = append(steps, &TransitiveReductionTransformer{})
	}

	return steps
}
757203
func AddManagedByControllerPodEdges(g osgraph.MutableUniqueGraph, to graph.Node, namespace string, selector map[string]string) {
	if selector == nil {
		return
	}
	query := labels.SelectorFromSet(selector)
	for _, n := range g.(graph.Graph).Nodes() {
		switch target := n.(type) {
		case *kubegraph.PodNode:
			if target.Namespace != namespace {
				continue
			}
			if query.Matches(labels.Set(target.Labels)) {
				g.AddEdge(target, to, appsgraph.ManagedByControllerEdgeKind)
			}
		}
	}
}
770088
func (r *ruleImpl) CallInternal(th *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
	newArgs := make(starlark.Tuple, 0, len(args)+1)
	newArgs = append(newArgs, starlarkstruct.FromStringDict(
		starlark.String("lucicfg.rule_ctx"),
		starlark.StringDict{
			"defaults": r.defaults,
		},
	))
	newArgs = append(newArgs, args...)
	switch res, err := r.Callable.CallInternal(th, newArgs, kwargs); {
	case err != nil:
		return nil, err
	case !isNamedStruct(res, "graph.keyset"):
		return nil, fmt.Errorf("bad rule implementation %s: must return graph.keyset, got %s", r.Callable, res.Type())
	default:
		return res, nil
	}
}
1157612
func (g *Graph) ast() {

	if g == nil {
		return
	}

	for _, node := range g.Out {
		if node.ThisString() == TypeExpression {
			node._ast()
		} else {
			node.ast()
		}
	}
}
813543
@SuppressWarnings("serial")
	private DataSet<Vertex<K, VV>> createResultVerticesWithDegrees(Graph<K, VV, EV> graph, EdgeDirection messagingDirection,
			TypeInformation<Tuple2<K, Message>> messageTypeInfo, DataSet<LongValue> numberOfVertices) {

		DataSet<Tuple2<K, Message>> messages;

		this.gatherFunction.setOptDegrees(this.configuration.isOptDegrees());

		DataSet<Tuple2<K, LongValue>> inDegrees = graph.inDegrees();
		DataSet<Tuple2<K, LongValue>> outDegrees = graph.outDegrees();

		DataSet<Tuple3<K, LongValue, LongValue>> degrees = inDegrees.join(outDegrees).where(0).equalTo(0)
				.with(new FlatJoinFunction<Tuple2<K, LongValue>, Tuple2<K, LongValue>, Tuple3<K, LongValue, LongValue>>() {

					@Override
					public void join(Tuple2<K, LongValue> first, Tuple2<K, LongValue> second, Collector<Tuple3<K, LongValue, LongValue>> out) {
						out.collect(new Tuple3<>(first.f0, first.f1, second.f1));
					}
				}).withForwardedFieldsFirst("f0;f1").withForwardedFieldsSecond("f1");

		DataSet<Vertex<K, Tuple3<VV, LongValue, LongValue>>> verticesWithDegrees = initialVertices
				.join(degrees).where(0).equalTo(0)
				.with(new FlatJoinFunction<Vertex<K, VV>, Tuple3<K, LongValue, LongValue>, Vertex<K, Tuple3<VV, LongValue, LongValue>>>() {
					@Override
					public void join(Vertex<K, VV> vertex, Tuple3<K, LongValue, LongValue> degrees,
									Collector<Vertex<K, Tuple3<VV, LongValue, LongValue>>> out) throws Exception {
						out.collect(new Vertex<>(vertex.getId(),
									new Tuple3<>(vertex.getValue(), degrees.f1, degrees.f2)));
					}
				}).withForwardedFieldsFirst("f0");

		// add type info
		TypeInformation<Vertex<K, Tuple3<VV, LongValue, LongValue>>> vertexTypes = verticesWithDegrees.getType();

		final DeltaIteration<Vertex<K, Tuple3<VV, LongValue, LongValue>>, Vertex<K, Tuple3<VV, LongValue, LongValue>>> iteration =
				verticesWithDegrees.iterateDelta(verticesWithDegrees, this.maximumNumberOfIterations, 0);
				setUpIteration(iteration);

		switch (messagingDirection) {
			case IN:
				messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices);
				break;
			case OUT:
				messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices);
				break;
			case ALL:
				messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices)
						.union(buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices));
				break;
			default:
				throw new IllegalArgumentException("Illegal edge direction");
		}

		@SuppressWarnings({ "unchecked", "rawtypes" })
		GatherUdf<K, Tuple3<VV, LongValue, LongValue>, Message> updateUdf =
				new GatherUdfVVWithDegrees(gatherFunction, vertexTypes);

		// build the update function (co group)
		CoGroupOperator<?, ?, Vertex<K, Tuple3<VV, LongValue, LongValue>>> updates =
				messages.coGroup(iteration.getSolutionSet()).where(0).equalTo(0).with(updateUdf);

		if (this.configuration != null && this.configuration.isOptNumVertices()) {
			updates = updates.withBroadcastSet(numberOfVertices, "number of vertices");
		}

		configureUpdateFunction(updates);

		return iteration.closeWith(updates, updates).map(
				new MapFunction<Vertex<K, Tuple3<VV, LongValue, LongValue>>, Vertex<K, VV>>() {

					public Vertex<K, VV> map(Vertex<K, Tuple3<VV, LongValue, LongValue>> vertex) {
						return new Vertex<>(vertex.getId(), vertex.getValue().f0);
					}
				});
	}
1030379
function transitiveClosure(nodeLabels, graph) {
  let madeProgress = false;
  do {
    madeProgress = false;
    for (const [ src, values ] of Array.from(nodeLabels.entries())) {
      const targets = graph[src];
      if (targets) {
        for (const target of targets) {
          for (const value of values) {
            madeProgress = multiMapSet(nodeLabels, target, value) || madeProgress;
          }
        }
      }
    }
  } while (madeProgress);
}
389606
func _simplify(i interface{}) interface{} {

	if v, ok := i.(*Graph); ok {
		if v.Len() == 1 && v.Out[0].Len() == 0 {
			return v.Out[0].This
		}
	}
	return i
}
1191708
func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []addrs.Referenceable) {
	rn, ok := v.(GraphNodeReferencer)
	if !ok {
		return nil, nil
	}
	if _, ok := v.(GraphNodeSubPath); !ok {
		return nil, nil
	}

	var matches []dag.Vertex
	var missing []addrs.Referenceable

	for _, ref := range rn.References() {
		subject := ref.Subject

		key := m.referenceMapKey(v, subject)
		if _, exists := m.vertices[key]; !exists {
			// If what we were looking for was a ResourceInstance then we
			// might be in a resource-oriented graph rather than an
			// instance-oriented graph, and so we'll see if we have the
			// resource itself instead.
			switch ri := subject.(type) {
			case addrs.ResourceInstance:
				subject = ri.ContainingResource()
			case addrs.ResourceInstancePhase:
				subject = ri.ContainingResource()
			}
			key = m.referenceMapKey(v, subject)
		}

		vertices := m.vertices[key]
		for _, rv := range vertices {
			// don't include self-references
			if rv == v {
				continue
			}
			matches = append(matches, rv)
		}
		if len(vertices) == 0 {
			missing = append(missing, ref.Subject)
		}
	}

	return matches, missing
}
1203335
function loadPrettyGraphSONSync(graph, filename) {
        var jsonText = fs.readFileSync(filename, { encoding: 'utf8' });
        var jsonObjArray = JSON.parse(jsonText);
        var jsonTextArray = _.map(jsonObjArray, JSON.stringify);
        var uglyText = jsonTextArray.join('\n');
        var StringInputStream = Tinkerpop.autoImport('StringInputStream');
        var stream = StringInputStream.from(uglyText);
        var builder = Tinkerpop.GraphSONReader.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var reader = builder.create();
        reader.readGraph(stream, graph);
        return graph;
    }
1341746
func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error) {
	return api.ListStarsContext(context.Background(), params)
}
360040
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
	const graph = Object.create(null);

	const promises = moduleNames.map( (moduleName) => {
		return pool.getModuleInfo(moduleName).
			then( (module) => {
				let node = graph[moduleName];
				if ( node == null ) {
					node = new GraphNode(moduleName, indegreeOnly);
					graph[moduleName] = node;
				}
				const p = module.dependencies.map( function(dep) {
					if ( module.isConditionalDependency(dep) ) {
						return;
					}
					return pool.getModuleInfo(dep).then( (depModule) => {
						if ( moduleNames.indexOf(dep) >= 0 ) {
							let depNode = graph[dep];
							if ( depNode == null ) {
								depNode = new GraphNode(dep, indegreeOnly);
								graph[dep] = depNode;
							}
							node.outgoing.push(depNode);
							if ( indegreeOnly ) {
								depNode.indegree++;
							} else {
								depNode.incoming.push(node);
							}
						}
					}, (erro) => null);
				});
				return Promise.all(p);
			}, (err) => {
				log.error("module %s not found in pool", moduleName);
			});
	});

	return Promise.all(promises).then(function() {
		// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
		return graph;
	});
}
163240
func SwilkCoeffs(n int) []float64 {

	a := make([]float64, n+1)

	an := float64(n)

	n2 := n / 2

	if n == 3 {
		a[1] = sqrth
	} else {
		an25 := an + 0.25
		summ2 := 0.0
		for i := 1; i <= n2; i++ {
			a[i] = ppnd((float64(i) - th) / an25)
			summ2 += a[i] * a[i]
		}
		summ2 *= 2.0
		ssumm2 := math.Sqrt(summ2)
		rsn := 1.0 / math.Sqrt(an)
		a1 := poly(c1, 6, rsn) - a[1]/ssumm2

		// Normalize coefficients

		var i1 int
		var fac float64
		if n > 5 {
			i1 = 3
			a2 := -a[2]/ssumm2 + poly(c2, 6, rsn)
			fac = math.Sqrt((summ2 - 2.0*a[1]*a[1] - 2.0*a[2]*a[2]) / (1.0 - 2.0*a1*a1 - 2.0*a2*a2))
			a[1] = a1
			a[2] = a2
		} else {
			i1 = 2
			fac = math.Sqrt((summ2 - 2.0*a[1]*a[1]) / (1.0 - 2.0*a1*a1))
			a[1] = a1
		}
		for i := i1; i <= n2; i++ {
			a[i] = -a[i] / fac
		}
	}

	return a
}
1373456
func tripleToRow(t *triple.Triple, cls *semantic.GraphClause) (table.Row, error) {
	r, s, p, o := make(table.Row), t.Subject(), t.Predicate(), t.Object()

	// Enforce binding validity inside te clause.
	bnd := make(map[string]*table.Cell)
	validBinding := func(k string, v *table.Cell) bool {
		c, ok := bnd[k]
		bnd[k] = v
		if !ok {
			return true
		}
		if reflect.DeepEqual(c, v) {
			return true
		}
		return false
	}

	// Subject related bindings.
	if cls.SBinding != "" {
		c := &table.Cell{N: s}
		r[cls.SBinding] = c
		if !validBinding(cls.SBinding, c) {
			return nil, nil
		}
	}
	if cls.SAlias != "" {
		c := &table.Cell{N: s}
		r[cls.SAlias] = c
		if !validBinding(cls.SAlias, c) {
			return nil, nil
		}
	}
	if cls.STypeAlias != "" {
		c := &table.Cell{S: table.CellString(s.Type().String())}
		r[cls.STypeAlias] = c
		if !validBinding(cls.STypeAlias, c) {
			return nil, nil
		}
	}
	if cls.SIDAlias != "" {
		c := &table.Cell{S: table.CellString(s.ID().String())}
		r[cls.SIDAlias] = c
		if !validBinding(cls.SIDAlias, c) {
			return nil, nil
		}
	}

	// Predicate related bindings.
	if cls.PBinding != "" {
		c := &table.Cell{P: p}
		r[cls.PBinding] = c
		if !validBinding(cls.PBinding, c) {
			return nil, nil
		}
	}
	if cls.PAlias != "" {
		c := &table.Cell{P: p}
		r[cls.PAlias] = c
		if !validBinding(cls.PAlias, c) {
			return nil, nil
		}
	}
	if cls.PIDAlias != "" {
		c := &table.Cell{S: table.CellString(string(p.ID()))}
		r[cls.PIDAlias] = c
		if !validBinding(cls.PIDAlias, c) {
			return nil, nil
		}
	}
	if cls.PAnchorBinding != "" {
		if p.Type() != predicate.Temporal {
			return nil, fmt.Errorf("cannot retrieve the time anchor value for non temporal predicate %q in binding %q", p, cls.PAnchorBinding)
		}
		t, err := p.TimeAnchor()
		if err != nil {
			return nil, fmt.Errorf("failed to retrieve the time anchor value for predicate %q in binding %q with error %v", p, cls.PAnchorBinding, err)
		}
		c := &table.Cell{T: t}
		r[cls.PAnchorBinding] = c
		if !validBinding(cls.PAnchorBinding, c) {
			return nil, nil
		}
	}

	if cls.PAnchorAlias != "" {
		if p.Type() != predicate.Temporal {
			return nil, fmt.Errorf("cannot retrieve the time anchor value for non temporal predicate %q in binding %q", p, cls.PAnchorAlias)
		}
		t, err := p.TimeAnchor()
		if err != nil {
			return nil, fmt.Errorf("failed to retrieve the time anchor value for predicate %q in binding %q with error %v", p, cls.PAnchorAlias, err)
		}
		c := &table.Cell{T: t}
		r[cls.PAnchorAlias] = c
		if !validBinding(cls.PAnchorAlias, c) {
			return nil, nil
		}
	}

	// Object related bindings.
	if cls.OBinding != "" {
		// Extract the object type.
		c, err := objectToCell(o)
		if err != nil {
			return nil, err
		}
		r[cls.OBinding] = c
		if !validBinding(cls.OBinding, c) {
			return nil, nil
		}
	}
	if cls.OAlias != "" {
		// Extract the object type.
		c, err := objectToCell(o)
		if err != nil {
			return nil, err
		}
		r[cls.OAlias] = c
		if !validBinding(cls.OAlias, c) {
			return nil, nil
		}
	}
	if cls.OTypeAlias != "" {
		n, err := o.Node()
		if err != nil {
			return nil, err
		}
		c := &table.Cell{S: table.CellString(n.Type().String())}
		r[cls.OTypeAlias] = c
		if !validBinding(cls.OTypeAlias, c) {
			return nil, nil
		}
	}
	if cls.OIDAlias != "" {
		n, err := o.Node()
		if err == nil {
			r[cls.OIDAlias] = &table.Cell{S: table.CellString(n.ID().String())}
		} else {
			p, err := o.Predicate()
			if err != nil {
				return nil, err
			}
			c := &table.Cell{S: table.CellString(string(p.ID()))}
			r[cls.OIDAlias] = c
			if !validBinding(cls.OIDAlias, c) {
				return nil, nil
			}
		}
	}
	if cls.OAnchorBinding != "" {
		p, err := o.Predicate()
		if err != nil {
			return nil, err
		}
		ts, err := p.TimeAnchor()
		if err != nil {
			return nil, err
		}
		c := &table.Cell{T: ts}
		r[cls.OAnchorBinding] = c
		if !validBinding(cls.OAnchorBinding, c) {
			return nil, nil
		}
	}
	if cls.OAnchorAlias != "" {
		p, err := o.Predicate()
		if err != nil {
			return nil, err
		}
		ts, err := p.TimeAnchor()
		if err != nil {
			return nil, err
		}
		c := &table.Cell{T: ts}
		r[cls.OAnchorAlias] = c
		if !validBinding(cls.OAnchorAlias, c) {
			return nil, nil
		}
	}

	return r, nil
}