Sha256: dfd146f2aac87a90764a3962b62b9b17b2fb064a9eb80f5473d7d6ab4d9613a9

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carbon-compiler-0.2.0 lib/carbon/compiler/project.rb