package p.studio.compiler.models;

import p.studio.compiler.source.Span;
import p.studio.compiler.source.identifiers.FileId;
import p.studio.compiler.source.identifiers.ModuleId;

import java.util.Objects;

public record IRGlobalOrigin(
        FileId derivedFromFile,
        ModuleId derivedFromModule,
        String derivedFromUserSymbol,
        Span primarySpan,
        String fallbackSyntheticLabel) {
    public IRGlobalOrigin {
        derivedFromFile = Objects.requireNonNull(derivedFromFile, "derivedFromFile");
        derivedFromModule = derivedFromModule == null ? ModuleId.none() : derivedFromModule;
        derivedFromUserSymbol = derivedFromUserSymbol == null ? "" : derivedFromUserSymbol;
        primarySpan = primarySpan == null ? Span.none() : primarySpan;
        fallbackSyntheticLabel = fallbackSyntheticLabel == null ? "" : fallbackSyntheticLabel;
    }
}
