Skip to content

Commit

Permalink
Emit: binary expr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 5, 2024
1 parent c9c10a3 commit 551225e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/codegen/js/expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const emitBinaryExpr = (binaryExpr: BinaryExpr, module: Module, ctx: Cont
return {
emit: [
lOp.emit,
...args.map(a => a.emit),
...args.map(a => a.emit).join('\n'),
jsVariable(resultVar, `${lOp.resultVar}.${traitName}.${methodName}(${argsEmit})`)
].join('\n'),
resultVar
Expand All @@ -107,7 +107,10 @@ export const emitBinaryExpr = (binaryExpr: BinaryExpr, module: Module, ctx: Cont
}
}
const method = operatorImplMap.get(binaryExpr.binaryOp.kind)!.names.at(-1)!
return { emit: jsVariable(resultVar, `${lOp}.${method}(${rOp})`), resultVar }
return {
emit: [lOp.emit, rOp.emit, jsVariable(resultVar, `${lOp.resultVar}.${method}(${rOp.resultVar})`)].join('\n'),
resultVar
}
}

export const emitOperand = (operand: Operand, module: Module, ctx: Context): EmitExpr => {
Expand Down

0 comments on commit 551225e

Please sign in to comment.