Module: Jade::Frontend::ForwardDeclaration::InteropImportDeclaration

Extended by:
Helper, InteropImportDeclaration
Included in:
InteropImportDeclaration
Defined in:
lib/jade/frontend/forward_declaration/interop_import_declaration.rb

Instance Method Summary collapse

Methods included from Helper

deep_declare_node, figure_out_type, shallow_declare_node

Instance Method Details

#deep(node, entry, registry) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jade/frontend/forward_declaration/interop_import_declaration.rb', line 20

def deep(node, entry, registry)
  node => AST::InteropImportDeclaration(module: mod_name, functions:)

  functions
    .reduce([entry, []]) do |(acc, errors), fn|
      case figure_out_type(entry, fn.type)
      in Err[e]
        [acc, errors + [e]]

      in Ok[type_sym]
        wrap_in_fn_type(type_sym)
          .then { fn_type_to_interop(mod_name, fn, it, entry, registry) }
          .then { |(sym, interop_errors)| [acc.define(sym), errors + interop_errors] }
      end
    end
    .then { Result[*it] }
end

#shallow(node, registry, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jade/frontend/forward_declaration/interop_import_declaration.rb', line 8

def shallow(node, registry, entry)
  node => AST::InteropImportDeclaration(functions:)

  functions
    .reduce(entry) do |acc, fn|
      Symbol
        .predeclared_interop_function(fn.name)
        .then { entry.define(it) }
    end
    .then { Result[it, []] }
end