# encoding: utf-8 # frozen_string_literal: true require "carbon/compiler/project/file" require "llvm/target" require "llvm/execution_engine" module Carbon module Compiler class Project attr_reader :diagnostics attr_reader :items attr_reader :main def initialize(files, root, libraries: []) @root = Pathname.new(root).expand_path(Dir.pwd) @files = files.map { |f| Project::File.new(f, @root, self) } @diagnostics = Metanostic::List.new @libraries = [] @files.each { |f| @diagnostics.files[f.short] = f } end def call @index ||= begin @index = Concrete::Index.new @files.each { |f| f.call(@index, @diagnostics.clone) } # load libraries... @libraries.each do |library| @index.link(Carbon::Concrete.load(::File.read(library, "rb"))) end @index.link(Carbon::Core.index) @index.finalize end end end end end