Ejemplo n.º 1
0
        public static void ExecuteFunction(string funcName, Value[] args, ObjectContext scope, ActionContext context)
        {
            if (scope == null)
            {
                logger.Error($"Cannot execute function \"{funcName}\" on null object");
                return;
            }

            if (scope.IsBuiltInFunction(funcName))
            {
                scope.CallBuiltInFunction(context, funcName, args);
            }
            else
            {
                var funcVal = scope.GetMember(funcName);

                if (funcVal.Type != ValueType.Undefined)
                {
                    var func = funcVal.ToFunction();
                    var vm   = context.Apt.Avm;
                    var ret  = vm.Execute(func, args, scope);

                    if (ret != null)
                    {
                        context.Stack.Push(ret);
                    }
                }
                else
                {
                    logger.Warn($"Can't find function: {funcName}");
                }
            }
        }
Ejemplo n.º 2
0
        public static void ExecuteFunction(string funcName, Value[] args, ObjectContext scope, ActionContext context)
        {
            if (scope == null)
            {
                Debug.WriteLine("[ERROR] cannot execute function \"" + funcName + "\" on null object");
                return;
            }

            if (scope.IsBuiltInFunction(funcName))
            {
                scope.CallBuiltInFunction(funcName, args);
            }
            else
            {
                var funcVal = scope.GetMember(funcName);

                if (funcVal.Type != ValueType.Undefined)
                {
                    var func = funcVal.ToFunction();
                    var vm   = context.Apt.AVM;
                    var ret  = vm.Execute(func, args, scope);

                    if (ret.Type != ValueType.Undefined)
                    {
                        context.Stack.Push(ret);
                    }
                }
                else
                {
                    Debug.WriteLine("[WARN] can't find function: " + funcName);
                }
            }
        }
Ejemplo n.º 3
0
        public static void ExecuteFunction(string funcName, Value[] args, ObjectContext scope, ActionContext context)
        {
            if (scope == null)
            {
                logger.Error($"Cannot execute function \"{funcName}\" on null object");
                return;
            }

            if (scope.IsBuiltInFunction(funcName))
            {
                scope.CallBuiltInFunction(context, funcName, args);
            }
            else
            {
                var funcVal = scope.GetMember(funcName);
                ExecuteFunction(funcVal, args, scope, context);
            }
        }