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);
|
LLVMSetUnnamedAddress(string_global, LLVMGlobalUnnamedAddr);
|
||||||
LLVMSetAlignment(string_global, 1);
|
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 {
|
} else {
|
||||||
err = new_backend_impl_error(Implementation, value->nodePtr, "reference initializer can only be string literals");
|
err = new_backend_impl_error(Implementation, value->nodePtr, "reference initializer can only be string literals");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
|
||||||
#include <codegen/backend.h>
|
#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/Core.h>
|
||||||
#include <llvm-c/Types.h>
|
#include <llvm-c/Types.h>
|
||||||
#include <llvm/llvm-ir/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,
|
BackendError impl_global_declaration(LLVMBackendCompileUnit* unit,
|
||||||
LLVMGlobalScope* scope,
|
LLVMGlobalScope* scope,
|
||||||
|
@ -54,8 +56,7 @@ BackendError impl_global_definiton(LLVMBackendCompileUnit* unit,
|
||||||
|
|
||||||
// FIXME: resolve initializer expression!
|
// FIXME: resolve initializer expression!
|
||||||
LLVMValueRef initial_value = NULL;
|
LLVMValueRef initial_value = NULL;
|
||||||
err = get_type_default_value(unit, scope, def->declaration.type,
|
err = get_const_type_value(unit, scope, &def->initializer->impl.constant, &initial_value);
|
||||||
&initial_value);
|
|
||||||
|
|
||||||
if (err.kind == Success) {
|
if (err.kind == Success) {
|
||||||
DEBUG("setting default value");
|
DEBUG("setting default value");
|
||||||
|
|
|
@ -23,6 +23,5 @@ fun printcstr(in cstr: msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
cstr: msg = "Hello, world!\n"
|
printcstr("Hello, world!\n")
|
||||||
printcstr(msg)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import "std"
|
||||||
|
|
||||||
cstr: EOL = "\n"
|
cstr: EOL = "\n"
|
||||||
|
|
||||||
fun main(out u32: e) {
|
fun main() {
|
||||||
|
|
||||||
handle: stdin = nullHandle
|
handle: stdin = nullHandle
|
||||||
getStdinHandle(stdin)
|
getStdinHandle(stdin)
|
||||||
|
@ -22,6 +22,4 @@ fun main(out u32: e) {
|
||||||
writeBytes(stdout, EOL, 1)(bytesWritten)
|
writeBytes(stdout, EOL, 1)(bytesWritten)
|
||||||
|
|
||||||
heapFree(buffer)
|
heapFree(buffer)
|
||||||
|
|
||||||
e = 0 as u32
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue