createPureProxy method

void createPureProxy(
  1. Expression fn,
  2. int argCount,
  3. ReadClassMemberExpr pureProxyProp, {
  4. OutputType? pureProxyType,
})

Implementation

void createPureProxy(
  o.Expression fn,
  int argCount,
  o.ReadClassMemberExpr pureProxyProp, {
  o.OutputType? pureProxyType,
}) {
  var proxy = storage.allocate(
    pureProxyProp.name,
    outputType: pureProxyType,
    modifiers: const [
      o.StmtModifier.Private,
      o.StmtModifier.Late,
      o.StmtModifier.Final,
    ],
  );
  var pureProxyId = argCount < Identifiers.pureProxies.length
      ? Identifiers.pureProxies[argCount]
      : null;
  if (pureProxyId == null) {
    throw StateError(
        'Unsupported number of argument for pure functions: $argCount');
  }
  _createMethod.addStmt(storage
      .buildWriteExpr(proxy, o.importExpr(pureProxyId).callFn([fn]))
      .toStmt());
}