(method, args, context)
| 22028 | } |
| 22029 | |
| 22030 | apply(method, args, context) { |
| 22031 | const locals = Array.prototype.slice.call(args); |
| 22032 | context = new python.Execution.Context(context.globals, {}); |
| 22033 | args = method.args.posonlyargs.concat(method.args.args); |
| 22034 | const default_pos = args.length - method.args.defaults.length; |
| 22035 | for (let i = 0; i < method.args.args.length; i++) { |
| 22036 | const arg = method.args.args[i]; |
| 22037 | let value = null; |
| 22038 | if (locals.length > 0) { |
| 22039 | value = locals.shift(); |
| 22040 | } else if (i >= default_pos) { |
| 22041 | value = this.expression(method.args.defaults[i - default_pos], context); |
| 22042 | } else { |
| 22043 | throw new python.Error('Missing required positional argument.'); |
| 22044 | } |
| 22045 | context.set(arg.arg, value); |
| 22046 | } |
| 22047 | return this.block(method.body, context); |
| 22048 | } |
| 22049 | |
| 22050 | block(statements, context) { |
| 22051 | statements = Array.prototype.slice.call(statements); |
no test coverage detected