fixed string literals
This commit is contained in:
parent
d35442f092
commit
d9791cc0a2
|
@ -55,7 +55,11 @@ BackendError impl_reference_const(LLVMBackendCompileUnit* unit, TypeValue* value
|
|||
LLVMSetUnnamedAddress(string_global, LLVMGlobalUnnamedAddr);
|
||||
LLVMSetAlignment(string_global, 1);
|
||||
|
||||
*llvm_value = string_global;
|
||||
// Cast the global variable to a pointer type if needed
|
||||
LLVMTypeRef i8_ptr_type = LLVMPointerType(LLVMInt8TypeInContext(unit->context), 0);
|
||||
LLVMValueRef global_str_ptr = LLVMConstBitCast(string_global, i8_ptr_type);
|
||||
|
||||
*llvm_value = global_str_ptr;
|
||||
} else {
|
||||
err = new_backend_impl_error(Implementation, value->nodePtr, "reference initializer can only be string literals");
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
|
||||
#include <codegen/backend.h>
|
||||
#include <set/types.h>
|
||||
#include <sys/log.h>
|
||||
#include <llvm/llvm-ir/variables.h>
|
||||
#include <llvm-c/Core.h>
|
||||
#include <llvm-c/Types.h>
|
||||
#include <llvm/llvm-ir/types.h>
|
||||
#include <llvm/llvm-ir/variables.h>
|
||||
#include <set/types.h>
|
||||
#include <sys/log.h>
|
||||
|
||||
#include "expr.h"
|
||||
|
||||
BackendError impl_global_declaration(LLVMBackendCompileUnit* unit,
|
||||
LLVMGlobalScope* scope,
|
||||
|
@ -54,8 +56,7 @@ BackendError impl_global_definiton(LLVMBackendCompileUnit* unit,
|
|||
|
||||
// FIXME: resolve initializer expression!
|
||||
LLVMValueRef initial_value = NULL;
|
||||
err = get_type_default_value(unit, scope, def->declaration.type,
|
||||
&initial_value);
|
||||
err = get_const_type_value(unit, scope, &def->initializer->impl.constant, &initial_value);
|
||||
|
||||
if (err.kind == Success) {
|
||||
DEBUG("setting default value");
|
||||
|
|
|
@ -23,6 +23,5 @@ fun printcstr(in cstr: msg) {
|
|||
}
|
||||
|
||||
fun main() {
|
||||
cstr: msg = "Hello, world!\n"
|
||||
printcstr(msg)
|
||||
printcstr("Hello, world!\n")
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import "std"
|
|||
|
||||
cstr: EOL = "\n"
|
||||
|
||||
fun main(out u32: e) {
|
||||
fun main() {
|
||||
|
||||
handle: stdin = nullHandle
|
||||
getStdinHandle(stdin)
|
||||
|
@ -22,6 +22,4 @@ fun main(out u32: e) {
|
|||
writeBytes(stdout, EOL, 1)(bytesWritten)
|
||||
|
||||
heapFree(buffer)
|
||||
|
||||
e = 0 as u32
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue