class Ven::Machine
- Ven::Machine
- Reference
- Object
Included Modules
Defined in:
ven/machine.crConstructors
-
.new(chunks : Chunks, context : Ven::Suite::Context::Machine = Context::Machine.new, origin = 0, legate : Ven::Legate = Legate.new)
Makes a
Machine
that will run chunks, an array of stitched chunks.
Class Method Summary
- .run(chunks, context = Context::Machine.new, origin = 0, &)
-
.run(chunks, context = Context::Machine.new, origin = 0, legate = Legate.new)
Makes a Machine, runs chunks and disposes the Machine.
Instance Method Summary
-
#binary(operator : String, left : Model, right : Model)
Performs a binary operation on left, right.
- #context : Context::Machine
-
#defun(informer : VFunction, given : Models)
Properly defines a function based off an informer and some given values.
-
#die(message : String)
Dies of runtime error with message, which should explain why the error happened.
-
#field(head : Vec, field)
If head, a vector, has a field field, returns the value of that field.
-
#field(head : Model, field : Model)
Same as
#field?
, but dies if found no working field resolution. -
#field?(head : Model, field : Str)
Resolves a field access.
-
#field?(head : Vec, field : MFunction)
Resolves a field access.
-
#field?(head, field : MFunction)
Resolves a field access.
-
#field?(head, field)
Resolves a field access.
-
#inspector
Starts a primitive state inspector prompt.
-
#normalize(operator, left, right)
Normalizes a binary operation (i.e., converts it to its normal form).
-
#normalize?(operator : String, left : Model, right : Model)
Normalizes a binary operation (i.e., converts it to its normal form).
-
#record!(instruction, duration, cp, ip)
Updates the timetable entry for an instruction given duration - the time it took to execute.
-
#reduce(operator : String, operand : Vec)
Reduces vector operand using a binary operator.
-
#reduce(operator, operand : MRange)
Reduces range operand using a binary operator.
-
#reduce(operator, operand)
Fallback reduce (converts operand to vec).
-
#return!
Cleans up and returns the last value on the operand stack, if any.
-
#start
Starts the evaluation loop, which begins to fetch the instructions from the current chunk and execute them, until there aren't any left.
Constructor Detail
Makes a Machine
that will run chunks, an array of
stitched chunks.
context is the context that the Machine will run in. origin is the first chunk that will be evaluated (the main chunk).
Class Method Detail
Makes a Machine
, runs chunks and disposes the Machine
.
context is the context that the Machine will run in. origin is the first chunk that will be evaluated (the main chunk).
Before running, yields the Machine
to the block.
Returns the result that was produced by the Machine, or nil if nothing was produced.
Makes a Machine, runs chunks and disposes the Machine.
context is the context that the Machine will run in. origin is the first chunk that will be evaluated (the main chunk).
Returns the result that was produced by the Machine, or nil if nothing was produced.
Instance Method Detail
Performs a binary operation on left, right.
Tries to normalize if left, right cannot be used with the operator.
Properly defines a function based off an informer and some given values.
Dies of runtime error with message, which should explain why the error happened.
If head, a vector, has a field field, returns the value of that field.
Otherwise, spreads the field access on the items of
head. E.g., [1, 2, 3].a is [1.a, 2.a, 3.a]
Same as #field?
, but dies if found no working field
resolution.
Resolves a field access.
Provides the 'callable?' field for any head, which
calls Model.callable?
.
If head has a field named field, returns the value of that field.
Otherwise, tries to construct a partial from a function called field, if it exists.
Returns nil if found no valid field resolution.
Resolves a field access.
Provides the 'callable?' field for any head, which
calls Model.callable?
.
If head has a field named field, returns the value of that field.
Otherwise, tries to construct a partial from a function called field, if it exists.
Returns nil if found no valid field resolution.
Resolves a field access.
Provides the 'callable?' field for any head, which
calls Model.callable?
.
If head has a field named field, returns the value of that field.
Otherwise, tries to construct a partial from a function called field, if it exists.
Returns nil if found no valid field resolution.
Resolves a field access.
Provides the 'callable?' field for any head, which
calls Model.callable?
.
If head has a field named field, returns the value of that field.
Otherwise, tries to construct a partial from a function called field, if it exists.
Returns nil if found no valid field resolution.
Starts a primitive state inspector prompt.
Returns false if the user wanted to terminate inspector functionality, or true if the user requested the next instruction.
Normalizes a binary operation (i.e., converts it to its normal form).
Dies if found no matching conversion.
Normalizes a binary operation (i.e., converts it to its normal form).
Returns nil if found no matching conversion.
Updates the timetable entry for an instruction given duration - the time it took to execute.
cp is a chunk pointer to the chunk where the instruction is found.
ip is an instruction pointer to the instruction.
Reduces vector operand using a binary operator.
Note:
- If operand is empty, returns it back.
- If operand has one item, returns that one item.
Reduces range operand using a binary operator.
Starts the evaluation loop, which begins to fetch the instructions from the current chunk and execute them, until there aren't any left.