class Crystal::CodeGenVisitor

Included Modules

Defined in:

compiler/crystal/codegen/asm.cr
compiler/crystal/codegen/call.cr
compiler/crystal/codegen/cast.cr
compiler/crystal/codegen/class_var.cr
compiler/crystal/codegen/codegen.cr
compiler/crystal/codegen/cond.cr
compiler/crystal/codegen/const.cr
compiler/crystal/codegen/context.cr
compiler/crystal/codegen/debug.cr
compiler/crystal/codegen/dump_type_info.cr
compiler/crystal/codegen/exception.cr
compiler/crystal/codegen/fun.cr
compiler/crystal/codegen/match.cr
compiler/crystal/codegen/once.cr
compiler/crystal/codegen/phi.cr
compiler/crystal/codegen/primitives.cr
compiler/crystal/codegen/type_id.cr
compiler/crystal/codegen/unions.cr

Constant Summary

DW_OP_plus_uconst = 35

see also the other DWARF enums in crystal/dwarf/abbrev.cr (note that LLVM defines several custom opcodes outside the user extension range)

ONCE_STATE = "~ONCE_STATE"
SYMBOL_TABLE_NAME = ":symbol_table"

Constructors

Instance Method Summary

Instance methods inherited from module Crystal::LLVMBuilderHelper

and(*args, **options)
and(*args, **options, &)
and
, bit_cast(*args, **options)
bit_cast(*args, **options, &)
bit_cast
, br(*args, **options)
br(*args, **options, &)
br
, call(func : LLVMTypedFunction, name : String = "")
call(func : LLVMTypedFunction, arg : LLVM::Value, name : String = "")
call(func : LLVMTypedFunction, args : Array(LLVM::Value), name : String = "")
call
, cast_to(value : LLVM::ValueMethods, type : Type) cast_to, cast_to_pointer(value : LLVM::ValueMethods, type : Type) cast_to_pointer, cast_to_void_pointer(pointer : LLVM::ValueMethods) cast_to_void_pointer, cond(*args, **options)
cond(*args, **options, &)
cond
, equal?(value1, value2) equal?, extend_float(to_type, value) extend_float, extend_int(from_type, to_type, value) extend_int, extract_value(*args, **options)
extract_value(*args, **options, &)
extract_value
, float(value, type) float, float32(value) float32, float64(value) float64, float_to_int(from_type, to_type, value) float_to_int, gep(ptr : LLVM::Value, index0 : Int32, index1 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : Int32, index1 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : LLVM::Value, index1 : LLVM::Value, name = "")
gep(ptr : LLVM::Value, index0 : Int32, name = "")
gep(ptr : LLVM::Value, index0 : LLVM::Value, index1 : LLVM::Value, name = "")
gep(ptr : LLVM::Value, index0 : LLVM::Value, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : LLVM::Value, name = "")
gep
, insert_block(*args, **options)
insert_block(*args, **options, &)
insert_block
, int(n, type)
int(n)
int
, int1(n) int1, int128(n) int128, int16(n) int16, int2ptr(*args, **options)
int2ptr(*args, **options, &)
int2ptr
, int32(n) int32, int64(n) int64, int8(n) int8, int_to_float(from_type, to_type, value) int_to_float, invoke(func : LLVMTypedFunction, args : Array(LLVM::Value), a_then, a_catch, name : String = "") invoke, llvm_alignment(type) llvm_alignment, llvm_arg_type(*args, **options)
llvm_arg_type(*args, **options, &)
llvm_arg_type
, llvm_c_return_type(*args, **options)
llvm_c_return_type(*args, **options, &)
llvm_c_return_type
, llvm_c_type(*args, **options)
llvm_c_type(*args, **options, &)
llvm_c_type
, llvm_closure_type(type) llvm_closure_type, llvm_embedded_c_type(*args, **options)
llvm_embedded_c_type(*args, **options, &)
llvm_embedded_c_type
, llvm_embedded_type(*args, **options)
llvm_embedded_type(*args, **options, &)
llvm_embedded_type
, llvm_false llvm_false, llvm_intrinsic_return_type(*args, **options)
llvm_intrinsic_return_type(*args, **options, &)
llvm_intrinsic_return_type
, llvm_nil llvm_nil, llvm_proc_type(type) llvm_proc_type, llvm_return_type(*args, **options)
llvm_return_type(*args, **options, &)
llvm_return_type
, llvm_size(type) llvm_size, llvm_struct_alignment(type) llvm_struct_alignment, llvm_struct_size(type) llvm_struct_size, llvm_struct_type(*args, **options)
llvm_struct_type(*args, **options, &)
llvm_struct_type
, llvm_true llvm_true, llvm_type(*args, **options)
llvm_type(*args, **options, &)
llvm_type
, load(*args, **options)
load(*args, **options, &)
load
, load_volatile(*args, **options)
load_volatile(*args, **options, &)
load_volatile
, not(*args, **options)
not(*args, **options, &)
not
, not_equal?(value1, value2) not_equal?, not_null_pointer?(value) not_null_pointer?, null_pointer?(value) null_pointer?, or(*args, **options)
or(*args, **options, &)
or
, phi(*args, **options)
phi(*args, **options, &)
phi
, position_at_end(*args, **options)
position_at_end(*args, **options, &)
position_at_end
, ptr2int(*args, **options)
ptr2int(*args, **options, &)
ptr2int
, ret(value : Nil)
ret(value)
ret
ret
, size_t(value : LLVM::Value)
size_t(n)
size_t
size_t
, store(*args, **options)
store(*args, **options, &)
store
, store_volatile(*args, **options)
store_volatile(*args, **options, &)
store_volatile
, switch(*args, **options)
switch(*args, **options, &)
switch
, trunc(*args, **options)
trunc(*args, **options, &)
trunc
, trunc_float(to_type, value) trunc_float

Macros inherited from module Crystal::LLVMBuilderHelper

pointer_cast(value, type) pointer_cast

Instance methods inherited from class Crystal::Visitor

accept(node) accept, end_visit(node) end_visit, end_visit_any(node) end_visit_any, visit_any(node) visit_any

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, node : ASTNode, single_module : Bool = false, debug : Crystal::Debug = Debug::Default, frame_pointers : FramePointers = :auto, llvm_context : LLVM::Context = LLVM::Context.new) #

[View source]

Instance Method Detail

def abi_info(external : Def, node : Call) #

[View source]
def abi_info(external : Def) #

[View source]
def accept(node) #

[View source]
def accept_control_expression(node) #

[View source]
def add_typed_fun(mod : LLVM::Module, name : String, type : LLVM::Type) : LLVMTypedFunction #

[View source]
def aggregate_index(type : LLVM::Type, ptr : LLVM::Value, index : Int32) #

type is the pointee type of ptr (not the type of the returned element)


[View source]
def alloca(type, name = "") #

[View source]
def alloca_block : LLVM::BasicBlock #

[View source]
def alloca_non_closured_vars(vars, obj = nil, args = nil, reset_nilable_vars = true) #

[View source]
def alloca_vars(vars, obj = nil, args = nil, parent_context = nil, reset_nilable_vars = true) #

[View source]
def allocate_aggregate(type) #

[View source]
def allocate_tuple(type, &) #

[View source]
def array_malloc(type, count) #

[View source]
def array_malloc_atomic(type, count) #

[View source]
def assign(target_pointer, target_type, value_type, value) #

[View source]
def assign_distinct(target_pointer, target_type : NilableType, value_type : Type, value) #

[View source]
def assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : ReferenceUnionType, value) #

[View source]
def assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : VirtualType, value) #

[View source]
def assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : Type, value) #

[View source]
def assign_distinct(target_pointer, target_type : NilableReferenceUnionType, value_type : Type, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : MixedUnionType, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : NilableType, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : VoidType, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : BoolType, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : NilType, value) #

[View source]
def assign_distinct(target_pointer, target_type : MixedUnionType, value_type : Type, value) #

[View source]
def assign_distinct(target_pointer, target_type : VirtualType, value_type : MixedUnionType, value) #

[View source]
def assign_distinct(target_pointer, target_type : VirtualType, value_type : Type, value) #

[View source]
def assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : MetaclassType | GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType | VirtualMetaclassType, value) #

[View source]
def assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : UnionType, value) #

[View source]
def assign_distinct(target_pointer, target_type : NilableProcType, value_type : NilType, value) #

[View source]
def assign_distinct(target_pointer, target_type : NilableProcType, value_type : ProcInstanceType, value) #

[View source]
def assign_distinct(target_pointer, target_type : NilableProcType, value_type : TypeDefType, value) #

[View source]
def assign_distinct(target_pointer, target_type : TupleInstanceType, value_type : TupleInstanceType, value) #

[View source]
def assign_distinct(target_pointer, target_type : NamedTupleInstanceType, value_type : NamedTupleInstanceType, value) #

[View source]
def assign_distinct(target_pointer, target_type : ProcInstanceType, value_type : ProcInstanceType, value) #

[View source]
def assign_distinct(target_pointer, target_type : ProcInstanceType, value_type : MixedUnionType, value) #

[View source]
def assign_distinct(target_pointer, target_type : Type, value_type : Type, value) #

[View source]
def assign_distinct_union_types(to_pointer, to_type, from_type, from_pointer) #

[View source]
def atomic_ordering_get_const(node, llvm_arg) #

[View source]
def atomicrwm_bin_op_get_const(node, llvm_arg) #

[View source]
def bool_from_bool_literal(node) #

[View source]
def bound_to_mod_nil?(var) #

[View source]
def br_block_chain(*blocks) #

[View source]
def br_from_alloca_to_entry #

[View source]
def build_string_constant(str, name = "str", *, llvm_mod = @llvm_mod, llvm_typer = @llvm_typer) #

[View source]
def builder : CrystalLLVMBuilder #

[View source]
def c_malloc_fun #

[View source]
def c_realloc_fun #

[View source]
def call_abi_info(target_def, node) #

[View source]
def cant_pass_closure_to_c_exception_call #

[View source]
def check_assign_to_special_var_in_block(target, value) #

[View source]
def check_atomic_call(call, target_def) #

[View source]
def check_c_fun(type, value) #

[View source]
def check_main_fun(name, func : LLVMTypedFunction) : LLVMTypedFunction #

[View source]
def check_mod_fun(mod, name, func : LLVMTypedFunction) : LLVMTypedFunction #

[View source]
def check_proc_is_not_closure(value, type) #

[View source]
def class_var_global_initialized_name(class_var : MetaTypeVar) #

[View source]
def class_var_global_name(class_var : MetaTypeVar) #

[View source]
def clear_current_debug_location #

[View source]
def closured_vars(vars, obj = nil) #

[View source]
def codegen_addsub_same_signedness_with_overflow(op, t1, t2, p1, p2) #

[View source]
def codegen_addsub_with_overflow(op, t1, t2, p1, p2) #

[View source]
def codegen_assign(target : Underscore, value, node) #

[View source]
def codegen_assign(target : Path, value, node) #

[View source]
def codegen_assign(target, value, node) #

[View source]
def codegen_binary_extend_int(t1, t2, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : BoolType, t2 : BoolType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : CharType, t2 : CharType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : SymbolType, t2 : SymbolType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : IntegerType, t2 : IntegerType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : IntegerType, t2 : FloatType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : FloatType, t2 : IntegerType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : FloatType, t2 : FloatType, p1, p2) #

[View source]
def codegen_binary_op(op, t1 : TypeDefType, t2, p1, p2) #

[View source]
def codegen_binary_op(op, t1, t2 : TypeDefType, p1, p2) #

[View source]
def codegen_binary_op(op, t1, t2, p1, p2) #

[View source]
def codegen_binary_op_eq(t1, t2, p1, p2) #

[View source]
def codegen_binary_op_gt(t1, t2, p1, p2) #

[View source]
def codegen_binary_op_gte(t1, t2, p1, p2) #

[View source]
def codegen_binary_op_lt(t1, t2, p1, p2) #

[View source]
def codegen_binary_op_lte(t1, t2, p1, p2) #

[View source]
def codegen_binary_op_ne(t1, t2, p1, p2) #

[View source]
def codegen_call(node, target_def, self_type, call_args) #

[View source]
def codegen_call_or_invoke(node, target_def, self_type, func, call_args, raises, type, is_closure = false, fun_type = nil) #

[View source]
def codegen_call_with_block(node, block, self_type, call_args) #

[View source]
def codegen_call_with_block_as_fun_literal(node, fun_literal, self_type, call_args) #

[View source]
def codegen_cast(from_type, to_type, arg) #

[View source]
def codegen_cond(node : ASTNode) #

[View source]
def codegen_cond(type) #

[View source]
def codegen_cond_branch(node_cond, then_block, else_block) #

[View source]
def codegen_convert(from_type : IntegerType, to_type : IntegerType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : IntegerType, to_type : FloatType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : FloatType, to_type : IntegerType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : FloatType, to_type : FloatType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : IntegerType, to_type : CharType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : CharType, to_type : IntegerType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : SymbolType, to_type : IntegerType, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type : TypeDefType, to_type, arg, *, checked : Bool) #

[View source]
def codegen_convert(from_type, to_type, arg, *, checked : Bool) #

[View source]
def codegen_direct_abi_call(call_arg_type, call_arg, abi_arg_type) #

[View source]
def codegen_dispatch(node, target_defs) #

[View source]
def codegen_extern_primitive_proc_call(target_def, args, fun_ptr) #

[View source]
def codegen_fun(mangled_name, target_def, self_type, is_exported_fun = false, fun_module_info = type_module(self_type), is_fun_literal = false, is_closure = false) #

[View source]
def codegen_fun_signature(mangled_name, target_def, self_type, is_fun_literal, is_closure) #

[View source]
def codegen_fun_signature_external(mangled_name, target_def) #

[View source]
def codegen_fun_signature_non_external(mangled_name, target_def, self_type, is_fun_literal, is_closure) #

[View source]
def codegen_if_branch(phi, node, branch_block, last) #

[View source]
def codegen_indirect_abi_call(call_arg, abi_arg_type) #

For an indirect argument we need to make a copy of the value in the stack and replace the call argument by a pointer to the allocated memory


[View source]
def codegen_mul_same_signedness_with_overflow(t1, t2, p1, p2) #

[View source]
def codegen_mul_signed_unsigned_with_overflow(t1, t2, p1, p2) #

[View source]
def codegen_mul_unsigned_signed_with_overflow(t1, t2, p1, p2) #

[View source]
def codegen_mul_with_overflow(t1, t2, p1, p2) #

[View source]
def codegen_primitive(call, node, target_def, call_args) #

[View source]
def codegen_primitive_allocate(node, target_def, call_args) #

[View source]
def codegen_primitive_atomicrmw(call, node, target_def, call_args) #

[View source]
def codegen_primitive_binary(node, target_def, call_args) #

[View source]
def codegen_primitive_class(node, target_def, call_args) #

[View source]
def codegen_primitive_class_crystal_instance_type_id(node, target_def, call_args) #

[View source]
def codegen_primitive_class_with_type(type : VirtualType, value) #

[View source]
def codegen_primitive_class_with_type(type : Type, value) #

[View source]
def codegen_primitive_cmpxchg(call, node, target_def, call_args) #

[View source]
def codegen_primitive_convert(node, target_def, call_args, *, checked : Bool) #

[View source]
def codegen_primitive_external_var_get(node, target_def, call_args) #

[View source]
def codegen_primitive_external_var_set(node, target_def, call_args) #

[View source]
def codegen_primitive_fence(call, node, target_def, call_args) #

[View source]
def codegen_primitive_load_atomic(call, node, target_def, call_args) #

[View source]
def codegen_primitive_object_crystal_type_id(node, target_def, call_args) #

[View source]
def codegen_primitive_object_id(node, external, call_args) #

[View source]
def codegen_primitive_pointer_add(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_address(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_diff(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_get(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_malloc(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_new(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_realloc(node, target_def, call_args) #

[View source]
def codegen_primitive_pointer_set(node, target_def, call_args) #

[View source]
def codegen_primitive_pre_initialize(node, target_def, call_args) #

[View source]
def codegen_primitive_proc_call(node, target_def, call_args) #

[View source]
def codegen_primitive_store_atomic(call, node, target_def, call_args) #

[View source]
def codegen_primitive_struct_or_union_set(node, target_def, call_args) #

[View source]
def codegen_primitive_symbol_to_s(node, target_def, call_args) #

[View source]
def codegen_primitive_tuple_indexer_known_index(node, target_def, call_args) #

[View source]
def codegen_raise_cast_failed(value, type_id, obj_type, to_type, node) #

[View source]
def codegen_re_raise(node, unwind_ex_obj) #

[View source]
def codegen_return(type : NoReturnType | Nil) #

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

[View source]
def codegen_return(target_def : Def) #

[View source]
def codegen_return_node(node, node_type) #

[View source]
def codegen_trunc_binary_op_result(t1, t2, result) #

Ensures the result is returned in the type of the left hand side operand t1. This is only needed if the operation was carried in the realm of t2 because it was of higher rank


[View source]
def codegen_tuple_indexer(type, value, index : Range) #

[View source]
def codegen_tuple_indexer(type, value, index : Int32) #

[View source]
def codegen_type_filter(node, &) #

[View source]
def codegen_va_arg(call, node, target_def, call_args) #

[View source]
def codegen_well_known_functions(node) #

[View source]
def configure_module(llvm_mod) #

[View source]
def context : Context #

[View source]
def create_check_proc_is_not_closure_fun(fun_name) #

[View source]
def create_debug_type(type : NilType, original_type : Type) #

[View source]
def create_debug_type(type : VoidType, original_type : Type) #

[View source]
def create_debug_type(type : CharType, original_type : Type) #

[View source]
def create_debug_type(type : IntegerType, original_type : Type) #

[View source]
def create_debug_type(type : SymbolType, original_type : Type) #

[View source]
def create_debug_type(type : FloatType, original_type : Type) #

[View source]
def create_debug_type(type : BoolType, original_type : Type) #

[View source]
def create_debug_type(type : EnumType, original_type : Type) #

[View source]
def create_debug_type(type : PointerInstanceType, original_type : Type) #

[View source]
def create_debug_type(type : StaticArrayInstanceType, original_type : Type) #

[View source]
def create_debug_type(type : TupleInstanceType, original_type : Type) #

[View source]
def create_debug_type(type : NamedTupleInstanceType, original_type : Type) #

[View source]
def create_debug_type(type : ProcInstanceType, original_type : Type) #

[View source]
def create_debug_type(type : InstanceVarContainer, original_type : Type) #

[View source]
def create_debug_type(type : MixedUnionType, original_type : Type) #

[View source]
def create_debug_type(type : NilableReferenceUnionType | ReferenceUnionType, original_type : Type) #

[View source]
def create_debug_type(type : NilableType, original_type : Type) #

[View source]
def create_debug_type(type : TypeDefType, original_type : Type) #

[View source]
def create_debug_type(type : NilableProcType, original_type : Type) #

[View source]

This is a sinkhole for debug types that most likely does not need to be implemented


[View source]
def create_debug_type(type, original_type : Type) #

[View source]
def create_initialize_class_var_function(class_var, initializer) #

[View source]
def create_initialize_const_function(fun_name, const) #

[View source]
def create_local_copy_of_arg(target_def, target_def_vars, arg, value, index) #

[View source]
def create_local_copy_of_block_args(target_def, self_type, call_args, args_base_index) #

[View source]
def create_local_copy_of_block_self(self_type, call_args) #

[View source]
def create_local_copy_of_fun_args(target_def, self_type, args, is_fun_literal, is_closure) #

[View source]
def create_metaclass_fun(name) #

[View source]
def create_read_class_var_function(class_var, initializer) #

[View source]
def create_read_const_function(fun_name, const) #

[View source]
def create_read_virtual_class_var_ptr_function(fun_name, class_var, owner) #

[View source]
def create_read_virtual_metaclass_var_ptr_function(fun_name, class_var, owner) #

[View source]
def create_type_id_to_class_name_map #

[View source]
def crystal_malloc_atomic_fun #

[View source]
def crystal_malloc_fun #

[View source]
def crystal_raise_cast_failed_fun #

[View source]
def crystal_raise_overflow_fun #

[View source]
def crystal_realloc_fun #

[View source]
def debug_codegen_log(file = __FILE__, line = __LINE__, &) #

Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.

The message is only generated if CRYSTAL_DEBUG_CODEGEN is set

The block given to this method should yield #printf arguments to show additional information. The following forms are all valid and helps to allocate the arguments only if the message is to be generated.

debug_codegen_log
debug_codegen_log { }
debug_codegen_log { "Lorem" }
debug_codegen_log { {"Lorem"} }
debug_codegen_log { {"Lorem %d", [an_int_llvm_value] of LLVM::Value} }

[View source]
def debug_codegen_log(file = __FILE__, line = __LINE__) #

Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.

The message is only generated if CRYSTAL_DEBUG_CODEGEN is set

The block given to this method should yield #printf arguments to show additional information. The following forms are all valid and helps to allocate the arguments only if the message is to be generated.

debug_codegen_log
debug_codegen_log { }
debug_codegen_log { "Lorem" }
debug_codegen_log { {"Lorem"} }
debug_codegen_log { {"Lorem %d", [an_int_llvm_value] of LLVM::Value} }

[View source]
def debug_files_cache #

[View source]
def debug_type_cache #

[View source]
def declare_class_var(class_var : MetaTypeVar) #

[View source]
def declare_class_var_and_initialized_flag(class_var : MetaTypeVar) #

[View source]
def declare_class_var_and_initialized_flag_in_this_module(class_var : MetaTypeVar) #

[View source]
def declare_class_var_initialized_flag(class_var : MetaTypeVar) #

[View source]
def declare_const(const) #

[View source]
def declare_const_and_initialized_flag(const) #

[View source]
def declare_const_initialized_flag(const) #

[View source]
def declare_debug_for_function_argument(arg_name, arg_type, arg_no, alloca, location) #

[View source]
def declare_fun(mangled_name, func : LLVMTypedFunction) : LLVMTypedFunction #

[View source]
def declare_lib_var(name, type, thread_local) #

[View source]
def declare_parameter(arg_name, arg_type, arg_no, alloca, location) #

[View source]
def declare_var(var) #

[View source]
def declare_variable(var_name, var_type, alloca, location, basic_block : LLVM::BasicBlock | Nil = nil, offset : Int = 0) #

[View source]
def define_main_function(name, arg_types : Array(LLVM::Type), return_type : LLVM::Type, needs_alloca : Bool = false, &) #

[View source]
def define_main_function(name, type : LLVM::Type, needs_alloca : Bool = false, &) #

[View source]
def define_slice_constant(info : Program::ConstSliceInfo) #

[View source]
def define_symbol_table(llvm_mod, llvm_typer) #

[View source]
def di_builder(llvm_module = @llvm_mod || @main_mod) #

[View source]
def discard_value(node : ASTNode) #

[View source]
def downcast(value, to_type, from_type : VoidType, already_loaded, *, extern = false) #

[View source]
def downcast(value, to_type, from_type : Type, already_loaded, *, extern = false) #

extern is only used in CodeGenVisitor#read_instance_var, and it is irrelevant whenever already_loaded == true


[View source]
def downcast_distinct(value, to_type : NilType, from_type : Type) #

[View source]

[View source]
def downcast_distinct(value, to_type : VirtualType, from_type : VirtualType) #

[View source]
def downcast_distinct(value, to_type : ReferenceUnionType, from_type : VirtualType) #

[View source]
def downcast_distinct(value, to_type : NonGenericClassType | GenericClassInstanceType, from_type : VirtualType) #

[View source]
def downcast_distinct(value, to_type : VirtualType, from_type : NilableType) #

[View source]
def downcast_distinct(value, to_type : Type, from_type : NilableType) #

[View source]
def downcast_distinct(value, to_type : ProcInstanceType, from_type : NilableProcType) #

[View source]
def downcast_distinct(value, to_type : TypeDefType, from_type : NilableProcType) #

[View source]
def downcast_distinct(value, to_type : PointerInstanceType, from_type : PointerInstanceType) #

[View source]
def downcast_distinct(value, to_type : ReferenceUnionType, from_type : ReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : VirtualType, from_type : ReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : Type, from_type : ReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : VirtualType, from_type : NilableReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : ReferenceUnionType, from_type : NilableReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : NilableType, from_type : NilableReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : Type, from_type : NilableReferenceUnionType) #

[View source]
def downcast_distinct(value, to_type : MixedUnionType, from_type : MixedUnionType) #

[View source]
def downcast_distinct(value, to_type : NilableType, from_type : MixedUnionType) #

[View source]
def downcast_distinct(value, to_type : BoolType, from_type : MixedUnionType) #

[View source]
def downcast_distinct(value, to_type : Type, from_type : MixedUnionType) #

[View source]
def downcast_distinct(value, to_type : ProcInstanceType, from_type : ProcInstanceType) #

[View source]
def downcast_distinct(value, to_type : TupleInstanceType, from_type : TupleInstanceType) #

[View source]
def downcast_distinct(value, to_type : NamedTupleInstanceType, from_type : NamedTupleInstanceType) #

[View source]
def downcast_distinct(value, to_type : IntegerType, from_type : IntegerType) #

This is the case of the automatic cast between integer types


[View source]
def downcast_distinct(value, to_type : FloatType, from_type : IntegerType) #

This is the case of the automatic cast between integer type and float type


[View source]
def downcast_distinct(value, to_type : FloatType, from_type : FloatType) #

This is the case of the automatic cast between float types


[View source]
def downcast_distinct(value, to_type : EnumType, from_type : SymbolType) #

This is the case of the automatic cast between symbol and enum


[View source]
def downcast_distinct(value, to_type : Type, from_type : Type) #

[View source]
def downcast_distinct_union_types(value, to_type : MixedUnionType, from_type : MixedUnionType) #

[View source]
def emit_def_debug_metadata(target_def) #

[View source]
def emit_fun_debug_metadata(func, fun_name, location, *, debug_types = [] of LibLLVM::MetadataRef, is_optimized = false) #

[View source]
def emit_vars_debug_info(vars) #

Emit debug info for toplevel variables. Used for the main module and all required files.


[View source]
def end_visit(node : ReadInstanceVar) #

[View source]
def ensure_class_var_in_this_module(global, class_var) #

[View source]
def ensure_class_var_initialized_flag_in_this_module(initialized_flag, class_var) #

[View source]
def entry_block : LLVM::BasicBlock #

[View source]
def execute_ensures_until(node) #

[View source]
def extern_to_lhs(value, type) #

[View source]
def extern_to_rhs(value, type) #

[View source]
def external_constant(type, name) #

[View source]
def fetch_typed_fun(mod : LLVM::Module, name : String, & : -> LLVM::Type) : LLVMTypedFunction #

[View source]
def file_and_dir(filename) #

[View source]
def finish #

[View source]
def fun_literal_name(node : ProcLiteral) #

[View source]
def fun_metadata_type(debug_types = [] of LibLLVM::MetadataRef) #

[View source]
def fun_metadatas #

[View source]
def generic_array_malloc(type, count, &) #

[View source]
def generic_malloc(type, &) #

[View source]
def get_class_var_global(class_var) #

[View source]
def get_current_debug_scope(location) #

[View source]
def get_debug_type(type, original_type : Type) #

[View source]
def get_debug_type(type) #

[View source]
def get_external_var(external) #

[View source]
def get_global(name, type, real_var, initial_value = nil) #

[View source]
def get_global_var(name, type, real_var, initial_value = nil) #

[View source]
def get_thread_local(name, type, real_var) #

[View source]
def in_alloca_block(&) #

[View source]
def in_main(&) #

[View source]
def initialize_class_var(class_var : MetaTypeVar, initializer : ClassVarInitializer) #

[View source]
def initialize_class_var(class_var : ClassVar) #

[View source]
def initialize_class_var(class_var : MetaTypeVar) #

[View source]
def initialize_const(const) #

[View source]
def initialize_no_init_flag_const(const) #

[View source]
def initialize_predefined_constants #

The special constants ARGC_UNSAFE and ARGV_UNSAFE (and others) need to be initialized as soon as the program starts, because we have access to argc and argv in the main function.


[View source]
def initialize_simple_const(const) #

[View source]
def initialize_simple_constants #

Here we only initialize simple constants, those that has simple values like 1, "foo" and other literals.


[View source]
def inline_call_return_value(target_def, body) #

[View source]
def instance_var_ptr(type, name, pointer) #

[View source]
def last : LLVM::Value #

[View source]
def last=(last : LLVM::Value) #

[View source]
def lazy_initialize_class_var(node, init_func, global, initialized_flag) #

[View source]
def llvm_context : LLVM::Context #

[View source]
def llvm_mod : LLVM::Module #

[View source]
def llvm_self(type = context.type) #

[View source]
def llvm_self_ptr #

[View source]
def llvm_typer : LLVMTyper #

[View source]
def main : LLVM::Function #

[View source]
def main_fun(name) #

[View source]
def make_fun(type, fun_ptr, ctx_ptr) #

[View source]
def make_nilable_fun(type) #

[View source]
def malloc(type) #

[View source]
def malloc_atomic(type) #

[View source]
def malloc_closure(closure_vars, current_context, parent_context = nil, self_closured = false) #

[View source]
def match_any_type_id(type, type_id) #

[View source]
def match_type_id(type, restriction, type_id) #

[View source]
def memcpy(dest, src, len, align, volatile, *, src_align = align) #

[View source]
def memset(pointer, value, size) #

[View source]
def modules : Hash(String, ModuleInfo) #

[View source]
def needs_value_cast_inside_union?(value_type, union_type) #

[View source]
def new_block(name = "") #

[View source]
def new_blocks(*names) #

[View source]
def new_builder(llvm_context) #

[View source]
def new_entry_block #

[View source]
def new_entry_block_chain(*names) #

[View source]
def once_init #

[View source]
def personality_name : String #

[View source]
def pre_initialize_aggregate(type, struct_type, ptr : LLVM::Value) #

[View source]
def prepare_call_args(node, owner) #

[View source]
def prepare_call_args_external(node, target_def, owner) #

[View source]
def prepare_call_args_non_external(node, target_def, owner) #

[View source]
def printf(format, args = [] of LLVM::Value) #

[View source]
def process_finished_hooks #

[View source]
def push_debug_info_metadata(mod) #

[View source]
def read_class_var(node : ClassVar) #

[View source]
def read_class_var(class_var : MetaTypeVar) #

[View source]
def read_class_var_ptr(node : ClassVar) #

[View source]
def read_class_var_ptr(class_var : MetaTypeVar) #

[View source]
def read_const(const, node) #

[View source]
def read_const_pointer(const) #

[View source]
def read_instance_var(node_type, type, name, value) #

[View source]
def read_virtual_class_var_ptr(class_var, owner) #

[View source]
def read_virtual_metaclass_class_var_ptr(class_var, owner) #

[View source]
def realloc(buffer, size) #

[View source]
def request_value(request : Bool = true, &) #

[View source]
def request_value(node : ASTNode) #

[View source]
def reset_nilable_vars(node) #

Sets to nil any variable in node that is nilable.


[View source]
def run_instance_vars_initializers(real_type, type : ClassType | GenericClassInstanceType, type_ptr) #

[View source]
def run_instance_vars_initializers(real_type, type : Type, type_ptr) #

[View source]
def run_instance_vars_initializers_non_recursive(real_type, type, type_ptr) #

[View source]
def run_once(flag, func : LLVMTypedFunction) #

[View source]
def set_aggregate_field(node, target_def, call_args, &) #

[View source]
def set_alignment(inst, type) #

[View source]
def set_call_attributes(node : Call, target_def, self_type, is_closure, fun_type) #

[View source]
def set_call_attributes(node, target_def, self_type, is_closure, fun_type) #

This is for function pointer calls and exception handler re-raise


[View source]
def set_call_attributes_external(node, target_def) #

[View source]
def set_current_debug_location(node : ASTNode) #

[View source]
def set_current_debug_location(location) #

[View source]
def set_ensure_exception_handler(node) #

[View source]
def set_internal_fun_debug_location(func, name, location = nil) #

used for generated internal functions like ~metaclass and ~match


[View source]
def setup_closure_vars(target_def, closure_vars, context, closure_type, closure_ptr) #

[View source]
def setup_context_fun(mangled_name, target_def, llvm_args_types, llvm_return_type) : Nil #

[View source]
def sret?(abi_info) #

[View source]
def store_bool_in_union(target_type, union_pointer, value) #

[View source]
def store_in_union(union_type, union_pointer, value_type, value) #

[View source]
def store_nil_in_union(target_type, union_pointer) #

[View source]
def store_union_in_union(union_type, union_pointer, value_type, value) #

this is needed if union_type and value_type have different alignments, i.e. their #union_values do not have the same offsets


[View source]
def store_void_in_union(target_type, union_pointer) #

[View source]
def struct_field_ptr(type, field_name, pointer) #

[View source]
def sub_image_base(value) #

[View source]
def target_def_fun(target_def, self_type) : LLVMTypedFunction #

[View source]
def to_lhs(value, type) #

[View source]
def to_rhs(value, type) #

[View source]
def try_inline_call(target_def, body, self_type, call_args) #

If a method's body is just a simple literal, "self", or an instance variable, we always inline it: less code generated, easier job for LLVM to optimize, and avoid a call in non-release builds.

Do this even in debug mode, because there's not much use in stepping to read a constant value or the value of an instance variable. Additionally, not inlining instance variable getters changes the semantic a program, so we must always inline these.


[View source]
def type #

[View source]
def type_cast_exception_call(from_type, to_type, node, var_name) #

fallback for stdlib before 1.16.2 when using a 1.16.2 or later compiler


[View source]
def type_id(value, type) #

[View source]
def type_id(type) #

[View source]
def type_id_to_class_name(type_id) #

[View source]
def type_module(type) #

[View source]
def typed_fun?(mod : LLVM::Module, name : String) : LLVMTypedFunction | Nil #

[View source]
def undef_vars(vars, obj) #

[View source]
def union_field_ptr(union_type, field_type, pointer) #

[View source]
def union_type_and_value_pointer(union_pointer, type : MixedUnionType) #

[View source]
def union_type_and_value_pointer(union_pointer, type : UnionType) #

[View source]
def union_type_id(struct_type, union_pointer) #

[View source]
def union_value(struct_type, union_pointer) #

[View source]
def unreachable(file = __FILE__, line = __LINE__) #

[View source]
def upcast(value, to_type, from_type) #

[View source]

[View source]
def upcast_distinct(value, to_type : VirtualType, from_type) #

[View source]
def upcast_distinct(value, to_type : NilableType, from_type : NilType | Nil) #

[View source]
def upcast_distinct(value, to_type : NilableType, from_type : Type) #

[View source]
def upcast_distinct(value, to_type : NilableReferenceUnionType, from_type : NilType | Nil) #

[View source]
def upcast_distinct(value, to_type : NilableReferenceUnionType, from_type : Type) #

[View source]
def upcast_distinct(value, to_type : NilableProcType, from_type : NilType) #

[View source]
def upcast_distinct(value, to_type : NilableProcType, from_type : ProcInstanceType) #

[View source]
def upcast_distinct(value, to_type : NilableProcType, from_type : TypeDefType) #

[View source]
def upcast_distinct(value, to_type : ReferenceUnionType, from_type) #

[View source]
def upcast_distinct(value, to_type : MixedUnionType, from_type : MixedUnionType) #

[View source]
def upcast_distinct(value, to_type : MixedUnionType, from_type : VoidType) #

[View source]
def upcast_distinct(value, to_type : MixedUnionType, from_type : BoolType) #

[View source]
def upcast_distinct(value, to_type : MixedUnionType, from_type : NilType) #

[View source]
def upcast_distinct(value, to_type : MixedUnionType, from_type : Type) #

[View source]
def upcast_distinct(value, to_type : EnumType, from_type : Type) #

[View source]
def upcast_distinct(value, to_type : TupleInstanceType, from_type : TupleInstanceType) #

[View source]
def upcast_distinct(value, to_type : NamedTupleInstanceType, from_type : NamedTupleInstanceType) #

[View source]
def upcast_distinct(value, to_type : GenericClassInstanceType, from_type : Type) #

[View source]
def upcast_distinct(value, to_type : Type, from_type : Type) #

[View source]
def upcast_distinct_union_types(value, to_type : MixedUnionType, from_type : MixedUnionType) #

[View source]
def validate_atomic_cmpxchg_ordering(success_node, success_ordering, failure_node, failure_ordering) #

[View source]
def visit(node : Annotation) #

[View source]
def visit(node : FunDef) #

[View source]
def visit(node : FileNode) #

[View source]
def visit(node : Nop) #

[View source]
def visit(node : NilLiteral) #

[View source]
def visit(node : BoolLiteral) #

[View source]
def visit(node : CharLiteral) #

[View source]
def visit(node : NumberLiteral) #

[View source]
def visit(node : StringLiteral) #

[View source]
def visit(node : SymbolLiteral) #

[View source]
def visit(node : TupleLiteral) #

[View source]
def visit(node : NamedTupleLiteral) #

[View source]
def visit(node : PointerOf) #

[View source]
def visit(node : ProcLiteral) #

[View source]
def visit(node : ProcPointer) #

[View source]
def visit(node : Expressions) #

[View source]
def visit(node : Return) #

[View source]
def visit(node : ClassDef) #

[View source]
def visit(node : ModuleDef) #

[View source]
def visit(node : LibDef) #

[View source]
def visit(node : CStructOrUnionDef) #

[View source]
def visit(node : EnumDef) #

[View source]
def visit(node : ExternalVar) #

[View source]
def visit(node : TypeDef) #

[View source]
def visit(node : Alias) #

[View source]
def visit(node : TypeOf) #

[View source]
def visit(node : SizeOf) #

[View source]
def visit(node : InstanceSizeOf) #

[View source]
def visit(node : AlignOf) #

[View source]
def visit(node : InstanceAlignOf) #

[View source]
def visit(node : Include) #

[View source]
def visit(node : Extend) #

[View source]
def visit(node : If) #

[View source]
def visit(node : While) #

[View source]
def visit(node : Not) #

[View source]
def visit(node : Break) #

[View source]
def visit(node : Next) #

[View source]
def visit(node : Assign) #

[View source]
def visit(node : TypeDeclaration) #

[View source]
def visit(node : UninitializedVar) #

[View source]
def visit(node : Var) #

[View source]
def visit(node : Global) #

[View source]
def visit(node : ClassVar) #

[View source]
def visit(node : InstanceVar) #

[View source]
def visit(node : Cast) #

[View source]
def visit(node : NilableCast) #

[View source]
def visit(node : IsA) #

[View source]
def visit(node : RespondsTo) #

[View source]
def visit(node : Def) #

[View source]
def visit(node : Macro) #

[View source]
def visit(node : Path) #

[View source]
def visit(node : Generic) #

[View source]
def visit(node : Yield) #

[View source]
def visit(node : Unreachable) #

[View source]
def visit(node : ExpandableNode) #

[View source]
def visit(node : Call) #

[View source]
def visit(node : ExceptionHandler) #

[View source]
def visit(node : Primitive) #

Can only happen in a Const or as an argument cast.


[View source]
def visit(node : Asm) #

[View source]
def visit(node : ASTNode) #

[View source]
def visit_any(node) #

[View source]
def void_ptr_throwinfo #

[View source]
def void_ptr_type_descriptor #

[View source]
def with_cloned_context(new_context = @context, &) #

[View source]
def with_context(new_context : Crystal::CodeGenVisitor::Context, &) #

[View source]
def wrap_builder(builder) #

[View source]