Class: Funicular::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/funicular/compiler.rb

Defined Under Namespace

Classes: NodeNotFoundError, PicorbcMissingError

Constant Summary collapse

PICORBC_DIR =

picorbc.js + picorbc.wasm bundled into the gem at build time by ‘rake copy_wasm`.

File.expand_path("vendor/picorbc", __dir__)
PICORBC_JS =
File.join(PICORBC_DIR, "picorbc.js")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_dir:, output_file:, debug_mode: false, logger: nil) ⇒ Compiler

Returns a new instance of Compiler.



16
17
18
19
20
21
# File 'lib/funicular/compiler.rb', line 16

def initialize(source_dir:, output_file:, debug_mode: false, logger: nil)
  @source_dir = source_dir
  @output_file = output_file
  @debug_mode = debug_mode
  @logger = logger
end

Instance Attribute Details

#debug_modeObject (readonly)

Returns the value of attribute debug_mode.



14
15
16
# File 'lib/funicular/compiler.rb', line 14

def debug_mode
  @debug_mode
end

#loggerObject (readonly)

Returns the value of attribute logger.



14
15
16
# File 'lib/funicular/compiler.rb', line 14

def logger
  @logger
end

#output_fileObject (readonly)

Returns the value of attribute output_file.



14
15
16
# File 'lib/funicular/compiler.rb', line 14

def output_file
  @output_file
end

#source_dirObject (readonly)

Returns the value of attribute source_dir.



14
15
16
# File 'lib/funicular/compiler.rb', line 14

def source_dir
  @source_dir
end

Instance Method Details

#compileObject



23
24
25
26
27
# File 'lib/funicular/compiler.rb', line 23

def compile
  check_picorbc_availability!
  gather_source_files
  compile_to_mrb
end