Skip to content

Commit

Permalink
Merge branch 'release/0.18'
Browse files Browse the repository at this point in the history
Ary Borenszweig committed Jul 2, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents a4df5f2 + 752bb8d commit 8a10530
Showing 2 changed files with 11 additions and 15 deletions.
19 changes: 10 additions & 9 deletions src/compiler/crystal/codegen/class_var.cr
Original file line number Diff line number Diff line change
@@ -8,10 +8,15 @@ require "./codegen"
class Crystal::CodeGenVisitor
def declare_class_var(owner, name, type, thread_local)
global_name = class_var_global_name(owner, name)
global = @main_mod.globals[global_name]? ||
@main_mod.globals.add(llvm_type(type), global_name)
global.linkage = LLVM::Linkage::Internal if @single_module
global.thread_local = true if thread_local
global = @main_mod.globals[global_name]?
unless global
global = @main_mod.globals.add(llvm_type(type), global_name)
global.linkage = LLVM::Linkage::Internal if @single_module
global.thread_local = true if thread_local
if !global.initializer && type.includes_type?(@mod.nil_type)
global.initializer = llvm_type(type).null
end
end
global
end

@@ -138,11 +143,7 @@ class Crystal::CodeGenVisitor
elsif @last.constant? && (type.is_a?(PrimitiveType) || type.is_a?(EnumType))
global.initializer = @last
else
if type.passed_by_value?
global.initializer = llvm_type(type).undef
else
global.initializer = llvm_type(type).null
end
global.initializer = llvm_type(type).null
assign global, type, node.type, @last
end

7 changes: 1 addition & 6 deletions src/compiler/crystal/codegen/const.cr
Original file line number Diff line number Diff line change
@@ -142,12 +142,7 @@ class Crystal::CodeGenVisitor
const.initializer = @last
end
else
if const.value.type.passed_by_value?
global.initializer = llvm_type(const.value.type).undef
else
global.initializer = @last.type.null
end

global.initializer = llvm_type(const.value.type).null
store @last, global
end

0 comments on commit 8a10530

Please sign in to comment.