Skip to content

Commit

Permalink
Augmented assignment operators (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich authored Jan 22, 2024
1 parent 3ca10a8 commit db9ac5d
Show file tree
Hide file tree
Showing 22 changed files with 904 additions and 1,471 deletions.
5 changes: 5 additions & 0 deletions src/generator/writers/writeFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export function writeStatement(f: ASTStatement, self: string | null, returns: Ty

ctx.append(`${path} = ${writeCastedExpression(f.expression, t, ctx)};`);
return;
} else if (f.kind === 'statement_augmentedassign') {
let path = f.path.map((v, i) => (i === 0) ? id(v.name) : v.name).join(`'`);
let t = getExpType(ctx.ctx, f.path[f.path.length - 1]);
ctx.append(`${path} = ${cast(t, t, `${path} ${f.op} ${writeExpression(f.expression, ctx)}`, ctx)};`);
return;
} else if (f.kind === 'statement_condition') {
writeCondition(f, self, false, returns, ctx);
return;
Expand Down
Loading

0 comments on commit db9ac5d

Please sign in to comment.