class Ven::Machine
- Ven::Machine
- Reference
- Object
Included Modules
Defined in:
ven/machine.crConstructors
-
.new(context : Ven::Suite::Context::Machine, chunks : Chunks, cp = 0)
Initializes a Machine given some chunks, a context and a chunk pointer cp: in chunks, the chunk at cp will be the first to be executed.
Class Method Summary
-
.start(context, chunks, offset, &)
Makes an instance of Machine given context, chunks and offset (see
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.
-
#inspect : Bool
Whether to run the inspector.
-
#inspect=(inspect : Bool)
Whether to run the inspector.
-
#inspector
Starts a primitive state inspector prompt.
-
#measure : Bool
Whether to measure instruction evaluation time.
-
#measure=(measure : Bool)
Whether to measure instruction evaluation time.
-
#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.
- #timetable : Timetable
Constructor Detail
Initializes a Machine given some chunks, a context and a chunk pointer cp: in chunks, the chunk at cp will be the first to be executed.
Remember: per each frame there should always be a scope; if you push a frame, that is, you have to push a scope as well. This has to be done so the frames and the context scopes are in sync.
Class Method Detail
Makes an instance of Machine given context, chunks
and offset (see Machine
). Yields this instance to
the block.
After the block was executed, starts the Machine and returns the resulting value.
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.