All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aya.tyck.order.AyaOrgaTycker Maven / Gradle / Ivy

There is a newer version: 0.33.0
Show newest version
// Copyright (c) 2020-2021 Yinsen (Tesla) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.tyck.order;

import kala.collection.mutable.MutableSet;
import org.aya.concrete.resolve.ResolveInfo;
import org.aya.concrete.stmt.Decl;
import org.aya.util.MutableGraph;
import org.aya.util.tyck.OrgaTycker;
import org.jetbrains.annotations.NotNull;

/**
 * Incremental and non-stopping compiler for SCCs.
 *
 * @param declUsage   usage graph of decls (usually the transpose of {@link ResolveInfo#declGraph()}).
 *                    for each (vertex, w) in the graph, the vertex should be tycked first.
 * @param sampleUsage transpose of {@link ResolveInfo#sampleGraph()}
 * @author kiva
 */
public record AyaOrgaTycker(
  @NotNull AyaSccTycker sccTycker,
  @NotNull MutableGraph declUsage,
  @NotNull MutableGraph sampleUsage,
  @NotNull MutableSet skippedSet
) implements OrgaTycker {
  public AyaOrgaTycker(@NotNull AyaSccTycker sccTycker, @NotNull ResolveInfo resolveInfo) {
    this(sccTycker, resolveInfo.declGraph().transpose(), resolveInfo.sampleGraph().transpose(), MutableSet.of());
  }

  @Override public @NotNull Iterable collectUsageOf(@NotNull TyckUnit failed) {
    var graph = failed instanceof Decl ? declUsage : sampleUsage;
    return graph.suc(failed);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy