module

Lox::VM

Constants

FRAMES_MAX = 64

We have to set a limit on call frames to avoid stack overflow, e.g. in the case of infinite recursion.

Instance methods

add!
Source
call!(function : FunctionObject, arg_count : Byte) : Bool
Source
call_value!(callee : Value, arg_count : Byte) : Bool
Source
current_byte
Source
current_chunk
Source
equal!
Source
interpret!(input : String) : InterpretResult
Source
peek(distance)
Source
placeholder_fn
Source
pop!
Source
push!(value)
Source
read_byte!
Source
read_constant!
Source
read_short!
Source
repl_session!
Source
reset_stack!
Source
run!
Source
run_file!(file : String)
Source
runtime_error!(format : String)

The behavior of splat arguments in Crystal is a little unexpected. Given the definition above where the overload is (String, *Object), I would expect that passing in just a string and no additional arguments would work, but instead, I get this error:

Error: no overload matches 'Lox::VM.runtime_error!' with type String

Defining this overload for (String) works. I wasn't able to pass in an empty tuple/array of object, e.g. *([] of Object) so I just pass in an arbitrary tuple of one Nil, since the args shouldn't matter in this case.

Source
runtime_error!(format : String, *args : Object)
Source

Macros

binary_op!(op)
Source

Nested types