Skip to content

hir: extract shared helper for crypto.<method>(...) lowering duplicated across globals.rs / module_static.rs #1434

Description

@TheHypnoo

Background

The named-import lowering (lower/expr_call/globals.rs:761-836) and the dotted-call lowering (lower/expr_call/module_static.rs:856-918) build identical Expr::Call { callee: PropertyGet { object: NativeModuleRef(\"crypto\"), property }, args, ... } for the same crypto methods. The two lists must be kept in sync manually; #1419 added several methods and both call sites needed parallel edits.

Scope

  • Add pub(crate) fn lower_crypto_method_passthrough(method: &str, args: Vec<Expr>) -> Expr to lower/expr_call/mod.rs (or a new crypto.rs submodule).
  • Replace both call sites with calls to the helper.
  • Methods passed through identical-shape: createHash, createSign, createVerify, createECDH, createDiffieHellman, ..., hkdfSync, scryptSync, sign, verify, publicEncrypt, privateDecrypt, generatePrime, etc.

Pure refactor, behavior identical. Tracked under #793.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inprogressCurrently being worked on by an agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions