| 6424 | return index === -1 ? null : index; |
| 6425 | } |
| 6426 | _parse() { |
| 6427 | if (this._buffer) { |
| 6428 | const parser = new torch._C.SchemaParser(this._buffer, true /* parseSchemaOrName */); |
| 6429 | const L = parser.L; |
| 6430 | this._arguments = []; |
| 6431 | this._is_vararg = false; |
| 6432 | this._kwarg_only = false; |
| 6433 | let idx = 0; |
| 6434 | L.expect('('); |
| 6435 | if (!L.nextIf(')')) { |
| 6436 | while (true) { |
| 6437 | if (this._is_vararg) { |
| 6438 | throw new python.Error("Unexpected 'torch.FunctionSchema._is_vararg'."); |
| 6439 | } |
| 6440 | if (L.nextIf('*')) { |
| 6441 | this._kwarg_only = true; |
| 6442 | } else if (L.nextIf('...')) { |
| 6443 | this._is_vararg = true; |
| 6444 | } else { |
| 6445 | const argument = parser.parseArgument(idx++, false, this._kwarg_only); |
| 6446 | this._arguments.push(argument); |
| 6447 | } |
| 6448 | if (!L.nextIf(',')) { |
| 6449 | break; |
| 6450 | } |
| 6451 | } |
| 6452 | L.expect(')'); |
| 6453 | } |
| 6454 | L.expect('->'); |
| 6455 | this._returns = []; |
| 6456 | this._is_varret = false; |
| 6457 | if (L.nextIf('...')) { |
| 6458 | this._is_varret = true; |
| 6459 | } else if (L.nextIf('(')) { |
| 6460 | if (!L.nextIf(')')) { |
| 6461 | while (true) { |
| 6462 | if (this._is_varret) { |
| 6463 | throw new python.Error("Unexpected 'torch.FunctionSchema._is_varret'."); |
| 6464 | } |
| 6465 | if (L.nextIf('...')) { |
| 6466 | this._is_varret = true; |
| 6467 | } else { |
| 6468 | const argument = parser.parseArgument(idx++, true, false); |
| 6469 | this._returns.push(argument); |
| 6470 | } |
| 6471 | if (!L.nextIf(',')) { |
| 6472 | break; |
| 6473 | } |
| 6474 | } |
| 6475 | L.expect(')'); |
| 6476 | } |
| 6477 | } else { |
| 6478 | this._returns.push(parser.parseArgument(0, true, false)); |
| 6479 | } |
| 6480 | delete this._buffer; |
| 6481 | } |
| 6482 | } |
| 6483 | __str__() { |