Skip to content

Commit

Permalink
Unpack structures
Browse files Browse the repository at this point in the history
  • Loading branch information
waj committed Dec 4, 2013
1 parent fcf0254 commit 6657d3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/compiler/crystal/codegen/llvm_typer.cr
Expand Up @@ -3,7 +3,7 @@ require "../llvm"

module Crystal
class LLVMTyper
HIERARCHY_LLVM_TYPE = LLVM.struct_type("Object+", [LLVM::Int32, LLVM.pointer_type(LLVM::Int8)], true)
HIERARCHY_LLVM_TYPE = LLVM.struct_type("Object+", [LLVM::Int32, LLVM.pointer_type(LLVM::Int8)])
HIERARCHY_LLVM_ARG_TYPE = LLVM.pointer_type(HIERARCHY_LLVM_TYPE)

getter landing_pad_type
Expand Down Expand Up @@ -58,16 +58,15 @@ module Crystal
max_size = size if size > max_size
end
end
max_size /= 4
max_size /= 8
max_size = 1 if max_size == 0

llvm_value_type = LLVM.array_type(LLVM::Int32, max_size)
LLVM.struct_type(type.llvm_name, [LLVM::Int32, llvm_value_type], true)
llvm_value_type = LLVM.array_type(LLVM::Int64, max_size)
LLVM.struct_type(type.llvm_name, [LLVM::Int32, llvm_value_type])
end

def create_llvm_type(type : PaddingType)
llvm_value_type = LLVM.array_type(LLVM::Int32, type.padding)
LLVM.struct_type(type.llvm_name, [LLVM::Int32, llvm_value_type], true)
LLVM.array_type(LLVM::Int32, type.padding)
end

def create_llvm_type(type : NilableType)
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/program.cr
Expand Up @@ -81,10 +81,10 @@ module Crystal

@types["Macro"] = macro_mod = NonGenericModuleType.new self, self, "Macro"
macro_var = macro_mod.types["Var"] = NonGenericClassType.new self, macro_mod, "Var", @reference
macro_var.lookup_instance_var("@padding").type = PaddingType.new(self, 17)
macro_var.lookup_instance_var("@padding").type = PaddingType.new(self, 24)

macro_ivar = macro_mod.types["InstanceVar"] = NonGenericClassType.new self, macro_mod, "InstanceVar", @reference
macro_ivar.lookup_instance_var("@padding").type = PaddingType.new(self, 17)
macro_ivar.lookup_instance_var("@padding").type = PaddingType.new(self, 24)

@symbols = Set(String).new
@global_vars = {} of String => Var
Expand Down

0 comments on commit 6657d3c

Please sign in to comment.