runFunction method
dynamic
runFunction()
执行函数
Implementation
dynamic runFunction(dynamic instance, List<dynamic>? positionalArguments, Map<Symbol, dynamic>? namedArguments) {
if (instance == this || instance == _vmclass) {
//执行静态函数
if (isExternal) {
final listArgumentsNative = positionalArguments?.map((e) => VmObject.readValue(e)).toList();
final nameArgumentsNative = namedArguments?.map((key, value) => MapEntry(key, VmObject.readValue(value)));
if (externalStaticFunctionCaller != null) return Function.apply(externalStaticFunctionCaller!, listArgumentsNative, nameArgumentsNative);
if (externalStaticPropertyReader != null) return Function.apply(externalStaticPropertyReader!(), listArgumentsNative, nameArgumentsNative);
throw ('Not found externalStaticFunctionCaller and externalStaticPropertyReader: ${_vmclass.identifier}.$identifier');
} else {
return (internalStaticPropertyOperator as VmValue).runFunction(positionalArguments, namedArguments);
}
} else {
//执行实例函数
if (isExternal) {
final instanceNative = VmObject.readValue(instance);
final listArgumentsNative = positionalArguments?.map((e) => VmObject.readValue(e)).toList();
final nameArgumentsNative = namedArguments?.map((key, value) => MapEntry(key, VmObject.readValue(value)));
if (externalInstanceFunctionCaller != null) return Function.apply(externalInstanceFunctionCaller!, [instanceNative, ...(listArgumentsNative ?? const [])], nameArgumentsNative);
if (externalInstancePropertyReader != null) return Function.apply(externalInstancePropertyReader!(instanceNative), listArgumentsNative, nameArgumentsNative);
throw ('Not found externalInstanceFunctionCaller and externalInstancePropertyReader: ${_vmclass.identifier}.$identifier');
} else {
return (VmObject.readLogic(instance) as VmValue).getProperty(identifier).runFunction(positionalArguments, namedArguments);
}
}
}