コード例 #1
0
        public override HeronValue Apply(VM vm, HeronValue[] args)
        {
            // Create a stack frame
            using (vm.CreateFrame(fun, GetClassInstance(), GetModuleInstance()))
            {
                try
                {
                    // Convert the arguments into appropriate types
                    PerformCoercions(args);

                    // Push the arguments into the current scope
                    PushArgs(vm, args);

                    // Copy free vars
                    if (freeVars != null)
                    {
                        vm.AddVars(freeVars);
                    }

                    // Eval the function body
                    vm.Eval(fun.body);
                }
                catch (Exception e)
                {
                    throw new VMException(fun, fun.FileName, vm.CurrentStatement, e);
                }
            }

            // Gets last result and resets it
            return(vm.GetAndResetResult());
        }
コード例 #2
0
        public override HeronValue Apply(VM vm, HeronValue[] args)
        {
            // Create a stack frame 
            using (vm.CreateFrame(fun, GetClassInstance(), GetModuleInstance()))
            {
                try
                {
                    // Convert the arguments into appropriate types
                    PerformCoercions(args);

                    // Push the arguments into the current scope
                    PushArgs(vm, args);

                    // Copy free vars
                    if (freeVars != null)
                        vm.AddVars(freeVars);

                    // Eval the function body
                    vm.Eval(fun.body);
                }
                catch (Exception e)
                {
                    throw new VMException(fun, fun.FileName, vm.CurrentStatement, e);
                }
            }

            // Gets last result and resets it
            return vm.GetAndResetResult();
        }