Class: Gloss::ProgLoader
- Inherits:
-
Object
- Object
- Gloss::ProgLoader
- Defined in:
- lib/gloss/prog_loader.rb
Constant Summary collapse
- STDLIB_TYPE_DEPENDENCIES =
{"yaml" => ["pstore", "dbm"], "rbs" => ["logger", "set", "tsort"], "logger" => ["monitor"]}
Instance Method Summary collapse
-
#initialize(type_checker, entrypoint_path = nil, entrypoint_contents = nil) ⇒ ProgLoader
constructor
A new instance of ProgLoader.
- #run ⇒ Object
Constructor Details
#initialize(type_checker, entrypoint_path = nil, entrypoint_contents = nil) ⇒ ProgLoader
Returns a new instance of ProgLoader.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gloss/prog_loader.rb', line 10 def initialize(type_checker, entrypoint_path = nil, entrypoint_contents = nil) @type_checker = type_checker entrypoint_path ||= Config.entrypoint (if entrypoint_path.==(nil) || entrypoint_path.==("") throw(:"error", "Entrypoint is not yet set in .gloss.yml") end) entrypoint = (if entrypoint_path && entrypoint_contents ep = (if entrypoint_path.==(Runtime::NON_EXISTENT_FILEPATH) entrypoint_path else Utils.absolute_path(entrypoint_path) end) [ep, entrypoint_contents] else Utils.abs_path_with_contents(entrypoint_path) end) core_types = Utils.abs_path_with_contents(File.join(__dir__ || "", "..", "..", "sig", "core.rbs")) @files_to_process = [entrypoint, core_types] @processed_files = Set.new end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gloss/prog_loader.rb', line 30 def run() @files_to_process.each() { |__arg0| path_string = __arg0.[](0) file_contents = __arg0.[](1) (if path_string.end_with?(".rbs") @type_checker.load_sig_path(path_string) else (if !@processed_files.member?(path_string) || !OUTPUT_BY_PATH.[](path_string) Gloss.logger .debug("Loading #{path_string}") contents_tree = Parser.new(file_contents) .run on_new_file_referenced = proc() { |ps, relative| ps.each() { |pa| (if relative handle_require_relative(pa, path_string) else handle_require(pa) end) } } OUTPUT_BY_PATH.[]=(path_string, Visitor.new(contents_tree, @type_checker, on_new_file_referenced) .run) @processed_files.add(path_string) end) end) } @type_checker end |