MCPcopy
hub / github.com/lutzroeder/netron / apply

Method apply

source/python.js:22030–22048  ·  view source on GitHub ↗
(method, args, context)

Source from the content-addressed store, hash-verified

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);

Callers 15

peekMethod · 0.80
regexMethod · 0.80
flatbuffersMethod · 0.80
_filterMethod · 0.80
_openSignatureMethod · 0.80
constructorMethod · 0.80
stringMethod · 0.80
openMethod · 0.80
openMethod · 0.80
readMethod · 0.80
stringMethod · 0.80
matchMethod · 0.80

Calls 4

expressionMethod · 0.80
callMethod · 0.45
setMethod · 0.45
blockMethod · 0.45

Tested by

no test coverage detected