diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-23 13:29:20 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-23 13:29:20 -0500 |
| commit | 87bc0cfdbddeb550b7d7959c88088ef9658a5e2d (patch) | |
| tree | 1b5d83c44f43d5db1db970160682b02ee37383e4 /compile.c | |
| parent | 9f56266ae4a2d458576821d74906ab5bc4498b5b (diff) | |
Fix up some ++ stuff for arrays
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -374,12 +374,16 @@ CORD compile(env_t *env, ast_t *ast) } case BINOP_XOR: return CORD_asprintf("%r ^= %r;", lhs, rhs); case BINOP_CONCAT: { - if (operand_t->tag == StringType) + if (operand_t->tag == StringType) { return CORD_asprintf("%r = CORD_cat(%r, %r);", lhs, lhs, rhs); - else if (operand_t->tag == ArrayType) - return CORD_all(lhs, "Array__concat(", lhs, ", ", rhs, ", ", compile_type_info(env, operand_t), ")"); - else + } else if (operand_t->tag == ArrayType) { + if (update->lhs->tag == Var) + return CORD_all("Array__insert_all(&", lhs, ", ", rhs, ", 0, ", compile_type_info(env, operand_t), ")"); + else + return CORD_all(lhs, "Array__concat(", lhs, ", ", rhs, ", ", compile_type_info(env, operand_t), ")"); + } else { code_err(ast, "'++=' is not implemented for %T types", operand_t); + } } default: code_err(ast, "Update assignments are not implemented for this operation"); } |
