Class: Fusion::Interpreter::FileThunk
- Inherits:
-
Object
- Object
- Fusion::Interpreter::FileThunk
- Defined in:
- lib/fusion/interpreter/file_thunk.rb
Instance Method Summary collapse
- #force ⇒ Object
-
#initialize(loader, abspath) ⇒ FileThunk
constructor
A new instance of FileThunk.
Constructor Details
#initialize(loader, abspath) ⇒ FileThunk
Returns a new instance of FileThunk.
10 11 12 13 14 15 |
# File 'lib/fusion/interpreter/file_thunk.rb', line 10 def initialize(loader, abspath) @loader = loader @abspath = abspath @state = :unforced # :unforced | :forcing | :done @value = nil end |
Instance Method Details
#force ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fusion/interpreter/file_thunk.rb', line 17 def force case @state when :done then @value when :forcing # We are already evaluating this file and were asked for it again # without any intervening function boundary => non-productive data cycle. ErrorVal.internal( kind: "reference_error", location: @loader.file_location(@abspath), operation: "forcing a file reference", input: @abspath, message: "non-productive data cycle" ) else @state = :forcing @value = @loader.evaluate_file(@abspath) @state = :done @value end end |