AssignMultiExpr.resize constructor

AssignMultiExpr.resize(
  1. Token op, {
  2. required List<Stmt> lhs,
  3. required List<Stmt> rhs,
})

Implementation

factory AssignMultiExpr.resize(
  Token op, {
  required List<Stmt> lhs,
  required List<Stmt> rhs,
}) {
  final int len = lhs.length;
  final int other = rhs.length;
  List<Stmt> newRhs = [];

  for (int i = 0; i < len; i++) {
    if (i >= other) {
      newRhs.add(NilLiteral(Token.synthesized('multires_$i')));
      continue;
    }
    newRhs.add(rhs[i]);
  }
  return AssignMultiExpr._(op, lhs, rhs);
}