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.cr

Constructors

Instance Method Summary

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

def self.new(program : Program) #

[View source]

Instance Method Detail

def add_gc_reference(ref : Reference) #

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.


[View source]
def align(size : Int32) : Int32 #

[View source]
def aligned_instance_sizeof_type(type : Type) : Int32 #

[View source]
def aligned_sizeof_type(node : ASTNode) : Int32 #

[View source]
def aligned_sizeof_type(type : Type) : Int32 #

[View source]
def aligned_sizeof_type(type : Nil) : Int32 #

[View source]
def c_function(name : String) #

[View source]
def checkout_stack(& : Pointer(UInt8) -> _) #

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.


[View source]
def class_var_index_and_compiled_def(owner : Type, name : String) : Tuple(Int32, CompiledDef | Nil) | Nil #

[View source]
def class_vars : ClassVars #

Information about all known class variables.


[View source]
def class_vars? : ClassVars | Nil #

Information about all known class variables.


[View source]
def class_vars_memory : Pointer(UInt8) #

The memory where class vars are stored. Refer to ClassVars for more on this.


[View source]
def class_vars_memory=(class_vars_memory : Pointer(UInt8)) #

The memory where class vars are stored. Refer to ClassVars for more on this.


[View source]
def compiled_procs : Set(UInt64) #

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.


[View source]
def const_index_and_compiled_def?(const : Const) : Tuple(Int32, CompiledDef) | Nil #

[View source]
def const_slice_buffer(info : Program::ConstSliceInfo) : Pointer(UInt8) #

[View source]
def constants : Constants #

Information about all known constants.


[View source]
def constants? : Constants | Nil #

Information about all known constants.


[View source]
def constants_memory : Pointer(UInt8) #

The memory where constants are stored. Refer to Constants for more on this.


[View source]
def constants_memory=(constants_memory : Pointer(UInt8)) #

The memory where constants are stored. Refer to Constants for more on this.


[View source]
def crystal_raise_overflow_compiled_def : CompiledDef #

This returns the CompiledDef that corresponds to __crystal_raise_overflow


[View source]
def declare_class_var(owner : Type, name : String, type : Type, compiled_def : CompiledDef | Nil) : Int32 #

[View source]
def declare_const(const : Const, compiled_def : CompiledDef) : Int32 #

[View source]
def defs : Hash(Def, CompiledDef) #

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.


[View source]
def extern_proc_wrapper(proc_type : ProcInstanceType, symbol : Pointer(Void)) : CompiledDef #

[View source]
def extern_proc_wrappers : Hash(Pointer(Void), Crystal::Repl::CompiledDef) #

A cache from C proc pointers to CompiledDefs, formed using Proc.new.


[View source]
def ffi_closure_context(interpreter : Interpreter, compiled_def : CompiledDef) #

[View source]
def ffi_closure_fun : LibFFI::ClosureFun #

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.


[View source]
def ffi_closure_to_compiled_def : Hash(Pointer(Void), CompiledDef) #

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.


[View source]
def index_to_symbol(index : Int32) : String #

[View source]
def inner_alignof_type(node : ASTNode) : Int32 #

[View source]
def inner_alignof_type(type : Type) : Int32 #

[View source]
def inner_alignof_type(type : Nil) : Int32 #

[View source]
def inner_instance_alignof_type(node : ASTNode) : Int32 #

[View source]
def inner_instance_alignof_type(type : Type) : Int32 #

[View source]
def inner_instance_alignof_type(type : Nil) : Int32 #

[View source]
def inner_instance_sizeof_type(node : ASTNode) : Int32 #

[View source]
def inner_instance_sizeof_type(type : Type) : Int32 #

[View source]
def inner_instance_sizeof_type(type : Nil) : Int32 #

[View source]
def inner_sizeof_type(node : ASTNode) : Int32 #

[View source]
def inner_sizeof_type(type : Type) : Int32 #

[View source]
def inner_sizeof_type(type : Nil) : Int32 #

[View source]
def instance_offset_of(type : Type, index : Int32) : Int32 #

[View source]
def ivar_offset(type : Type, name : String) : Int32 #

[View source]
def lib_functions : Hash(Pointer(Void), LibFunction) #

libffi information about external functions.


[View source]
def loader : Loader #

[View source]
def loader? : Loader | Nil #

[View source]
def multidispatchs : Hash(MultidispatchKey, Def) #

Cache of multidispatch expansions.


[View source]
def offset_of(type : Type, index : Int32) : Int32 #

[View source]
def program : Program #

[View source]
def symbol_index(symbol : String) : Int32 #

[View source]
def throw_value_type : Type #

[View source]
def type_from_id(id : Int32) : Type #

[View source]
def type_id(type : Type) : Int32 #

[View source]
def type_instance_var_initializers(type : Type) #

[View source]