Class: Polycrystal::Compiler
- Inherits:
-
Object
- Object
- Polycrystal::Compiler
- Defined in:
- lib/polycrystal/compiler.rb
Instance Attribute Summary collapse
-
#build_path ⇒ Object
readonly
Returns the value of attribute build_path.
-
#precompile ⇒ Object
readonly
Returns the value of attribute precompile.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#shardfile ⇒ Object
readonly
Returns the value of attribute shardfile.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(build_path:, shardfile: nil, registry: Polycrystal::Registry.instance, precompile: LAZY_COMPILE) ⇒ Compiler
constructor
A new instance of Compiler.
- #prepare ⇒ Object
Constructor Details
#initialize(build_path:, shardfile: nil, registry: Polycrystal::Registry.instance, precompile: LAZY_COMPILE) ⇒ Compiler
Returns a new instance of Compiler.
9 10 11 12 13 14 |
# File 'lib/polycrystal/compiler.rb', line 9 def initialize(build_path:, shardfile: nil, registry: Polycrystal::Registry.instance, precompile: LAZY_COMPILE) @build_path = build_path @registry = registry @shardfile = shardfile @precompile = precompile end |
Instance Attribute Details
#build_path ⇒ Object (readonly)
Returns the value of attribute build_path.
7 8 9 |
# File 'lib/polycrystal/compiler.rb', line 7 def build_path @build_path end |
#precompile ⇒ Object (readonly)
Returns the value of attribute precompile.
7 8 9 |
# File 'lib/polycrystal/compiler.rb', line 7 def precompile @precompile end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
7 8 9 |
# File 'lib/polycrystal/compiler.rb', line 7 def registry @registry end |
#shardfile ⇒ Object (readonly)
Returns the value of attribute shardfile.
7 8 9 |
# File 'lib/polycrystal/compiler.rb', line 7 def shardfile @shardfile end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/polycrystal/compiler.rb', line 26 def execute if precompile == NO_PRECOMPILE compile elsif precompile == REQUIRE_AOT raise 'Crystal module should be compiled before run' unless File.exist?(outfile) else compile unless File.exist?(outfile) end outfile end |
#prepare ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/polycrystal/compiler.rb', line 16 def prepare # load anyolite add_anyolite # add lib with shards use_shards # write crystal entrypoint in_file.write(entrypoint) in_file.close end |