package p.studio.compiler.models;

import p.studio.compiler.backend.bytecode.BytecodeModule;
import p.studio.compiler.backend.irvm.IRVMProgram;
import p.studio.compiler.messages.BuilderPipelineConfig;
import p.studio.compiler.source.tables.FileTable;
import p.studio.compiler.utilities.SourceProviderFactory;

import java.nio.file.Path;

public class BuilderPipelineContext {
    public final BuilderPipelineConfig config;
    public final SourceProviderFactory sourceProviderFactory;

    public Path rootProjectPathCanon;
    public ResolvedWorkspace resolvedWorkspace;

    public FileTable fileTable;
    public IRBackend irBackend;
    public IRVMProgram irvm;
    public IRVMProgram optimizedIrvm;
    public BytecodeModule bytecodeModule;
    public byte[] bytecodeBytes;
    public Path bytecodeArtifactPath;

    private BuilderPipelineContext(
            final BuilderPipelineConfig config,
            final SourceProviderFactory factory) {
        this.config = config;
        this.sourceProviderFactory = factory;
    }

    public static BuilderPipelineContext fromConfig(final BuilderPipelineConfig config) {
        return new BuilderPipelineContext(config, config.sourceProviderFactory());
    }
}
