Class: Kumi::Core::Analyzer::Passes::Codegen::JsPass

Inherits:
PassBase
  • Object
show all
Defined in:
lib/kumi/core/analyzer/passes/codegen/js_pass.rb

Instance Method Summary collapse

Methods inherited from PassBase

#debug, #debug_enabled?, #initialize

Methods included from ErrorReporting

#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error

Constructor Details

This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase

Instance Method Details

#run(_errors) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/kumi/core/analyzer/passes/codegen/js_pass.rb', line 9

def run(_errors)
  decls = get_state(:lir_module)
  manifest = get_state(:binding_manifest)[:javascript]
  schema_digest = get_state(:schema_digest)
  hints = get_state(:hints)

  decls = decls.reject { |n, _v| hints[n][:inline] }
  emitter = Codegen::Js::Emitter.new(manifest["kernels"], manifest["bindings"])
  src = emitter.emit(decls, schema_digest: schema_digest)

  files = { "codegen.mjs" => src }
  state.with(:javascript_codegen_files, files)
end