class
Crystal::Repl::Context
Overview
This class contains all of the global data used to interpret a single program. For example, it includes the memory region to store constants and class variables, what are all the know symbols, and a few more things.
Defined in:
compiler/crystal/interpreter/context.crConstructors
Instance Method Summary
-
#add_gc_reference(ref : Reference)
Many reference values we create when compiling nodes to bytecode must not be collected by the GC.
- #align(size : Int32) : Int32
- #aligned_instance_sizeof_type(type : Type) : Int32
- #aligned_sizeof_type(node : ASTNode) : Int32
- #aligned_sizeof_type(type : Type) : Int32
- #aligned_sizeof_type(type : Nil) : Int32
- #c_function(name : String)
-
#checkout_stack(& : Pointer(UInt8) -> _)
Checks out a stack from the stack pool and yields it to the given block.
- #class_var_index_and_compiled_def(owner : Type, name : String) : Tuple(Int32, CompiledDef | Nil) | Nil
-
#class_vars : ClassVars
Information about all known class variables.
-
#class_vars? : ClassVars | Nil
Information about all known class variables.
-
#class_vars_memory : Pointer(UInt8)
The memory where class vars are stored.
-
#class_vars_memory=(class_vars_memory : Pointer(UInt8))
The memory where class vars are stored.
-
#compiled_procs : Set(UInt64)
A cache of object IDs of the
CompiledDefs corresponding toProcLiterals. - #const_index_and_compiled_def?(const : Const) : Tuple(Int32, CompiledDef) | Nil
- #const_slice_buffer(info : Program::ConstSliceInfo) : Pointer(UInt8)
-
#constants : Constants
Information about all known constants.
-
#constants? : Constants | Nil
Information about all known constants.
-
#constants_memory : Pointer(UInt8)
The memory where constants are stored.
-
#constants_memory=(constants_memory : Pointer(UInt8))
The memory where constants are stored.
-
#crystal_raise_overflow_compiled_def : CompiledDef
This returns the CompiledDef that corresponds to __crystal_raise_overflow
- #declare_class_var(owner : Type, name : String, type : Type, compiled_def : CompiledDef | Nil) : Int32
- #declare_const(const : Const, compiled_def : CompiledDef) : Int32
-
#defs : Hash(Def, CompiledDef)
A hash of Def to their compiled representation, so we don't compile a single method multiple times.
- #extern_proc_wrapper(proc_type : ProcInstanceType, symbol : Pointer(Void)) : CompiledDef
-
#extern_proc_wrappers : Hash(Pointer(Void), Crystal::Repl::CompiledDef)
A cache from C proc pointers to
CompiledDefs, formed usingProc.new. - #ffi_closure_context(interpreter : Interpreter, compiled_def : CompiledDef)
-
#ffi_closure_fun : LibFFI::ClosureFun
The single closure function that we use for all function pointers (procs) passed to C.
-
#ffi_closure_to_compiled_def : Hash(Pointer(Void), CompiledDef)
Associated an FFI::Closure's code to a CompiledDef.
- #index_to_symbol(index : Int32) : String
- #inner_alignof_type(node : ASTNode) : Int32
- #inner_alignof_type(type : Type) : Int32
- #inner_alignof_type(type : Nil) : Int32
- #inner_instance_alignof_type(node : ASTNode) : Int32
- #inner_instance_alignof_type(type : Type) : Int32
- #inner_instance_alignof_type(type : Nil) : Int32
- #inner_instance_sizeof_type(node : ASTNode) : Int32
- #inner_instance_sizeof_type(type : Type) : Int32
- #inner_instance_sizeof_type(type : Nil) : Int32
- #inner_sizeof_type(node : ASTNode) : Int32
- #inner_sizeof_type(type : Type) : Int32
- #inner_sizeof_type(type : Nil) : Int32
- #instance_offset_of(type : Type, index : Int32) : Int32
- #ivar_offset(type : Type, name : String) : Int32
-
#lib_functions : Hash(Pointer(Void), LibFunction)
libffi information about external functions.
- #loader : Loader
- #loader? : Loader | Nil
-
#multidispatchs : Hash(MultidispatchKey, Def)
Cache of multidispatch expansions.
- #offset_of(type : Type, index : Int32) : Int32
- #program : Program
- #symbol_index(symbol : String) : Int32
- #throw_value_type : Type
- #type_from_id(id : Int32) : Type
- #type_id(type : Type) : Int32
- #type_instance_var_initializers(type : Type)
Instance methods inherited from class Reference
==(other : self)==(other : JSON::Any)
==(other : YAML::Any)
==(other) ==, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Constructor methods inherited from class Reference
new
new,
unsafe_construct(address : Pointer, *args, **opts) : self
unsafe_construct
Class methods inherited from class Reference
pre_initialize(address : Pointer)
pre_initialize
Instance methods inherited from class Object
! : Bool
!,
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, to_yaml(io : IO) : Nil
to_yaml : String to_yaml, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Class methods inherited from class Object
from_json(string_or_io : String | IO, root : String)from_json(string_or_io : String | IO) from_json, from_yaml(string_or_io : String | IO) from_yaml
Macros inherited from class Object
class_getter(*names, &block)
class_getter,
class_getter!(*names)
class_getter!,
class_getter?(*names, &block)
class_getter?,
class_property(*names, &block)
class_property,
class_property!(*names)
class_property!,
class_property?(*names, &block)
class_property?,
class_setter(*names)
class_setter,
def_clone
def_clone,
def_equals(*fields)
def_equals,
def_equals_and_hash(*fields)
def_equals_and_hash,
def_hash(*fields)
def_hash,
delegate(*methods, to object)
delegate,
forward_missing_to(delegate)
forward_missing_to,
getter(*names, &block)
getter,
getter!(*names)
getter!,
getter?(*names, &block)
getter?,
property(*names, &block)
property,
property!(*names)
property!,
property?(*names, &block)
property?,
setter(*names)
setter
Constructor Detail
Instance Method Detail
Many reference values we create when compiling nodes to bytecode must not be collected by the GC. Ideally they should be referenced in the bytecode itself. The problem is that the bytecode isn't always aligned to 8 bytes boundaries. So until we figure out what's the proper way to do it, we just retain these references here.
Checks out a stack from the stack pool and yields it to the given block. Once the block returns, the stack is returned to the pool. The stack is not cleared after or before it's used.
The memory where class vars are stored. Refer to ClassVars for more on this.
The memory where class vars are stored. Refer to ClassVars for more on this.
A cache of object IDs of the CompiledDefs corresponding to ProcLiterals.
Used to determine whether such an object ID or a raw function pointer is
passed to Proc.new.
The memory where constants are stored. Refer to Constants for more on this.
The memory where constants are stored. Refer to Constants for more on this.
This returns the CompiledDef that corresponds to __crystal_raise_overflow
A hash of Def to their compiled representation, so we don't compile a single method multiple times. The exceptions are methods with non-captured blocks.
A cache from C proc pointers to CompiledDefs, formed using Proc.new.
The single closure function that we use for all function pointers (procs) passed to C. This closure function knows all the information about the callback being passed, and is able to run the code associated to it.
Associated an FFI::Closure's code to a CompiledDef. When we set an extern struct's field that is a Proc, we create an FFI::Closure object and set that instead of a Proc. In case a user reads that field back we need to create a Proc, we can't use an FFI::Closure object. In that case we lookup the proc in this Hash.
libffi information about external functions.