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

Method call

source/python.js:21989–22028  ·  view source on GitHub ↗
(target, name, args, keywords, context)

Source from the content-addressed store, hash-verified

21987 }
21988
21989 call(target, name, args, keywords, context) {
21990 const builtins = this.builtins;
21991 const callTarget = this.target(target, context);
21992 const callArguments = args.map((arg) => this.expression(arg, context));
21993 if (!callTarget || (name !== null && !callTarget[name])) {
21994 if (name === '__new__' && callArguments.length === 1 && callArguments[0] === callTarget) {
21995 name = null;
21996 callArguments.shift();
21997 } else {
21998 const targetName = `${this.identifier(target)}.${name}`;
21999 throw new python.Error(`Unknown function '${targetName}'.`);
22000 }
22001 }
22002 const func = name ? callTarget[name] : callTarget;
22003 if (func.__class__ === builtins.type) {
22004 if (func.prototype && func.prototype.__class__ === func) {
22005 return Reflect.construct(func, callArguments);
22006 }
22007 const obj = Object.create(func);
22008 obj.__class__ = func;
22009 if (obj.__init__ && typeof obj.__init__ === 'function') {
22010 obj.__init__(...args);
22011 }
22012 return obj;
22013 }
22014 if (func.__class__ === builtins.function) {
22015 if (func.__call__) {
22016 return func.__call__(callArguments);
22017 }
22018 }
22019 if (func.__class__ === builtins.method) {
22020 if (func.__call__) {
22021 return func.__call__([callTarget].concat(callArguments));
22022 }
22023 }
22024 if (typeof func === 'function') {
22025 return func.apply(callTarget, callArguments);
22026 }
22027 throw new python.Error('Unsupported call expression.');
22028 }
22029
22030 apply(method, args, context) {
22031 const locals = Array.prototype.slice.call(args);

Callers 15

_buildTypeMethod · 0.45
hasFunction · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
matchMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
_updateSizeMethod · 0.45
_updateBoxMethod · 0.45
decodeMethod · 0.45
decodeTextMethod · 0.45
decodeMethod · 0.45

Calls 8

mapMethod · 0.80
expressionMethod · 0.80
applyMethod · 0.80
targetMethod · 0.45
identifierMethod · 0.45
createMethod · 0.45
__init__Method · 0.45
__call__Method · 0.45

Tested by

no test coverage detected