Skip to content

Commit

Permalink
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/compiler/crystal/codegen/primitives.cr
Original file line number Diff line number Diff line change
@@ -423,11 +423,22 @@ class Crystal::CodeGenVisitor
def codegen_primitive_pointer_malloc(node, target_def, call_args)
type = node.type.as(PointerInstanceType)
llvm_type = llvm_embedded_type(type.element_type)

old_debug_location = @current_debug_location
if @debug.line_numbers? && (location = node.location)
set_current_debug_location(node.location)
end

if type.element_type.has_inner_pointers?
last = array_malloc(llvm_type, call_args[1])
else
last = array_malloc_atomic(llvm_type, call_args[1])
end

if @debug.line_numbers?
set_current_debug_location(old_debug_location)
end

last
end

5 changes: 4 additions & 1 deletion src/compiler/crystal/semantic/top_level_visitor.cr
Original file line number Diff line number Diff line change
@@ -355,7 +355,10 @@ class Crystal::TopLevelVisitor < Crystal::SemanticVisitor
node.raise "method marked as Primitive must have an empty body"
end

node.body = Primitive.new(value)
primitive = Primitive.new(value)
primitive.location = node.location

node.body = primitive
end

def visit(node : Include)

0 comments on commit 9be7840

Please sign in to comment.