(name, value)
| 22455 | } |
| 22456 | |
| 22457 | registerFunction(name, value) { |
| 22458 | const builtins = this.builtins; |
| 22459 | const index = name.lastIndexOf('.'); |
| 22460 | if (!value) { |
| 22461 | value = () => { |
| 22462 | throw new python.Error(`'${name}' is not implemented.`); |
| 22463 | }; |
| 22464 | } |
| 22465 | value.__class__ = builtins.function; |
| 22466 | value.__name__ = index === -1 ? name : name.substring(index + 1); |
| 22467 | value.__module__ = index === -1 ? '' : name.substring(0, index); |
| 22468 | const module = this.register(value.__module__); |
| 22469 | if (module[name]) { |
| 22470 | throw new python.Error(`Function '${name}' is already registered.`); |
| 22471 | } |
| 22472 | module[value.__name__] = value; |
| 22473 | return value; |
| 22474 | } |
| 22475 | |
| 22476 | registerOperator(name, value) { |
| 22477 | this._operators.set(name, value); |
no test coverage detected