Module: Jade::Stdlib::Compiled
- Included in:
- Calendar, Clock, Decode::Params, Maybe, Result
- Defined in:
- lib/jade/stdlib/compiled.rb
Instance Method Summary collapse
- #entry ⇒ Object
- #generate_entry(registry) ⇒ Object
- #resolve_imports(entry) ⇒ Object
-
#symbols ⇒ Object
Compiled modules declare interfaces and impls in their Jade source, not via the Intrinsics DSL.
Instance Method Details
#entry ⇒ Object
27 28 29 |
# File 'lib/jade/stdlib/compiled.rb', line 27 def entry @entry ||= fail("entry not generated yet.") end |
#generate_entry(registry) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jade/stdlib/compiled.rb', line 4 def generate_entry(registry) return @entry if @entry source = Source[uri, code] source .then { Lexer.tokenize(it) } .then { Parsing.parse(it, source:) } => Ok([ast, _comments]) Registry .entry(source.to_module_name) .with(ast:) .with(source:) .then { resolve_imports(it) } .then do Frontend .run_entry(it, registry.add_module(it)) .map { Codegen.generate_entry(it, registry.add_module(it)) } end => Ok(entry) @entry = entry end |
#resolve_imports(entry) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/jade/stdlib/compiled.rb', line 39 def resolve_imports(entry) imports .reduce(entry) do |acc, stdlib| ImportEntry[stdlib.entry.name, stdlib.entry.name, stdlib.default_imports, stdlib.entry.exposes] .then { acc.import(it) } end end |
#symbols ⇒ Object
Compiled modules declare interfaces and impls in their Jade source, not via the Intrinsics DSL. The lookup that scans ‘imports` for Interface symbols (intrinsics.rb#implementation) never finds anything here, but exposing an empty list keeps the call site uniform.
35 36 37 |
# File 'lib/jade/stdlib/compiled.rb', line 35 def symbols [] end |