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!
Sourcecall!(function : FunctionObject, arg_count : Byte) : Bool
Sourcecall_value!(callee : Value, arg_count : Byte) : Bool
Sourcecurrent_byte
Sourcecurrent_chunk
Sourceequal!
Sourceinterpret!(input : String) : InterpretResult
Sourcepeek(distance)
Sourceplaceholder_fn
Sourcepop!
Sourcepush!(value)
Sourceread_byte!
Sourceread_constant!
Sourceread_short!
Sourcerepl_session!
Sourcereset_stack!
Sourcerun!
Sourcerun_file!(file : String)
Sourceruntime_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.
runtime_error!(format : String, *args : Object)
SourceMacros
binary_op!(op)
Source