From 663182abdf0cb34c1b4331bfe29cefe14e053f73 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 22 Feb 2024 13:00:27 -0500 Subject: Implement concatenation --- compile.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 98de6614..3985d45a 100644 --- a/compile.c +++ b/compile.c @@ -300,6 +300,20 @@ CORD compile(env_t *env, ast_t *ast) else code_err(ast, "Boolean operators are only supported for Bool and integer types"); } + case BINOP_CONCAT: { + switch (operand_t->tag) { + case StringType: { + return CORD_all("CORD_cat(", lhs, ", ", rhs, ")"); + } + case ArrayType: { + return CORD_all("({ array_t $joined = ", lhs, ", $rhs = ", rhs, ";\n" + "Array__insert_all(&$joined, $rhs, 0, ", compile_type_info(env, operand_t), ");\n" + "$joined; })"); + } + default: + code_err(ast, "Concatenation isn't supported for %T types", operand_t); + } + } default: break; } code_err(ast, "unimplemented binop"); -- cgit v1.2.3