Conversation
src/llvm.cpp
Outdated
| } | ||
| Type *type = llvm_type(self, sym->type); | ||
|
|
||
| Type *type = llvm_type(self, sym->type, true); |
There was a problem hiding this comment.
It seems like I need the true here for global variables but I'm not exactly sure if I need it for all cases. Thoughts?
There was a problem hiding this comment.
That makes sense for array's, a Global Variable needs the raw type so it know's how much space to reserve, this actually will cause an error for functions though, llvm_type will return a FunctionType for functions, this will cause an assert in LLVM when it attempts to work out a size for the global.
I guess maybe we need llvm_type's hide behind pointer to be a mask maybe? Something like llvm_type(self, sym->type, ARRAY | STRUCT) and in emit_expr_func we would have llvm_type(self, type, FUNCTION)
|
I'm so sorry about the whitespace... Looks like Xcode is mixing tabs and spaces... Will fix later |
| Value *value = emit_expr(self, decl->dval.val).val; | ||
| arrpop(self->symbols); | ||
| if (isa<Function>(value)) { | ||
| if (isa<Function>(value) || isa<StructType>((Type *)value)) { |
src/llvm.cpp
Outdated
| } | ||
| Type *type = llvm_type(self, sym->type); | ||
|
|
||
| Type *type = llvm_type(self, sym->type, true); |
There was a problem hiding this comment.
That makes sense for array's, a Global Variable needs the raw type so it know's how much space to reserve, this actually will cause an error for functions though, llvm_type will return a FunctionType for functions, this will cause an assert in LLVM when it attempts to work out a size for the global.
I guess maybe we need llvm_type's hide behind pointer to be a mask maybe? Something like llvm_type(self, sym->type, ARRAY | STRUCT) and in emit_expr_func we would have llvm_type(self, type, FUNCTION)
I did a first pass but still would like to clean up a little. Please feel free to nitpick this