feat(gs/achilles): Codegen string literals

Codegen string literals to LLVM as (for now) global C string pointers

Change-Id: I6dcd7fa25a7806a2f708a8e9275c9a01174fd0cf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2613
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
Griffin Smith 2021-03-19 20:35:05 -04:00 committed by glittershark
parent b1c4b84dba
commit fec6595d21

View file

@ -92,7 +92,11 @@ impl<'ctx, 'ast> Codegen<'ctx, 'ast> {
Literal::Bool(b) => Ok(AnyValueEnum::IntValue(
ty.const_int(if *b { 1 } else { 0 }, false),
)),
Literal::String(_) => todo!(),
Literal::String(s) => Ok(self
.builder
.build_global_string_ptr(s, "s")
.as_pointer_value()
.into()),
}
}
Expr::UnaryOp { op, rhs, .. } => {