public static void EmitBodyBeginForGetTable(this ILGenerator ilgen, FunctionData func)
      {
         ilgen.Emit(OpCodes.Ldarg_0);
         ilgen.Emit(OpCodes.Ldarg_0);

         var getCurrentMethod = typeof(MethodBase).GetMethod("GetCurrentMethod", BindingFlags.Static | BindingFlags.Public);
         ilgen.Emit(OpCodes.Call, getCurrentMethod);
         ilgen.Emit(OpCodes.Castclass, typeof(MethodInfo));

         ilgen.Emit(OpCodes.Ldc_I4, func.ArgumentCount);
         ilgen.Emit(OpCodes.Newarr, typeof(object));
      }
      public static void EmitBodyBeginForGetEnumerable(this ILGenerator ilgen, FunctionData func, FunctionReturnTypeInfo funcReturnTypeInfo)
      {
         ilgen.Emit(OpCodes.Ldarg_0);
         ilgen.Emit(OpCodes.Ldarg_0);

         var getMapperMethod = typeof(TypedDataContextBase).GetMethod("GetMapper", BindingFlags.NonPublic | BindingFlags.Instance)
            .MakeGenericMethod(funcReturnTypeInfo.ElementType);
         ilgen.Emit(OpCodes.Call, getMapperMethod);

         ilgen.Emit(OpCodes.Ldstr, func.Name);

         ilgen.Emit(OpCodes.Ldc_I4, func.ArgumentCount); // Array length
         ilgen.Emit(OpCodes.Newarr, typeof(DataParameter));
      }
Пример #3
0
        private static void Parse(
            string[] lines,
            List <EnumData> enums,
            List <FunctionData> functions,
            List <CallbackData> callbacks,
            List <StructData> structs)
        {
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("#define "))
                {
                    string[] parts = lines[i].Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length == 3)
                    {
                        var @enum = new EnumData()
                        {
                            Name  = parts[1],
                            Value = parts[2]
                        };

                        enums.Add(@enum);

                        ParseDocs(lines, i, @enum);
                    }
                }
                else if (lines[i].StartsWith("GLFWAPI "))
                {
                    FunctionData function = ParseFunction(lines, i);
                    functions.Add(function);
                }
                else if (lines[i].StartsWith("typedef "))
                {
                    if (lines[i].Contains("(* "))
                    {
                        CallbackData callback = ParseCallback(lines, i);
                        callbacks.Add(callback);
                    }
                    else if (lines[i].StartsWith("typedef struct "))
                    {
                        StructData @struct = ParseStruct(lines, ref i);
                        structs.Add(@struct);
                    }
                }
            }
        }
Пример #4
0
        internal void beginFunction()
        {
            StatementData statement = getCurStatement();
            FunctionData  func      = getLastFunction();

            if (func.IsValid())
            {
                //语句的多元函数的其它元函数名
                FunctionData newFunc = new FunctionData();
                CallData     call    = new CallData();
                ValueData    name    = new ValueData();
                call.Name    = name;
                newFunc.Call = call;

                statement.Functions.Add(newFunc);
            }
        }
Пример #5
0
        protected override void Load(FunctionData funcData)
        {
            var cd = funcData.Call;

            Load(cd);
            foreach (var comp in funcData.Statements)
            {
                var fcd = comp as Dsl.CallData;
                if (null != fcd)
                {
                    var        key = fcd.GetId();
                    StoryValue val = new StoryValue();
                    val.InitFromDsl(fcd.GetParam(0));
                    m_LoadedOptArgs[key] = val;
                }
            }
        }
Пример #6
0
        public void Generator_ForSequence3()
        {
            FunctionData <double> temp = new FunctionData <double>(1, 2, (x, y) => y + x / y);

            double[] actual = SequenceGenerator <double> .Generate(temp).ToArray();

            double[] expected =
            {
                1,                2, 2.5, 3.3, 4.05757575757576, 4.87086926018965, 5.70389834408211, 6.55785277425587,
                7.42763417076325, 8.31053343902137
            };

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(actual[i], expected[i], 0.000000000001);
            }
        }
Пример #7
0
        public TransformViewModel(FunctionData data)
        {
            SignalData                   = data;
            FourierTransformResult       = new FunctionData(continuous: false);
            WalshHadamardTransformResult = new FunctionData(continuous: false);

            FourierTransforms = new List <FourierTransform>(new FourierTransform[]
                                                            { new DiscreteFourierTransform(), new FastFourierTransform() });
            WalshHadamardTransforms = new List <WalshHadamardTransform>(new WalshHadamardTransform[]
                                                                        { new DiscreteWalshHadamardTransform(), new FastWalshHadamardTransform() });

            SelectedFourierTransform       = FourierTransforms.ElementAt(0);
            SelectedWalshHadamardTransform = WalshHadamardTransforms.ElementAt(0);

            ElapsedTime = new Parameter(0.0d, "LAST OPERATION DURATION");
            Parameters  = new List <Parameter>(new [] { ElapsedTime });
        }
Пример #8
0
    private void Refresh()
    {
        int id    = 0;
        int index = 0;

        for (int i = 0, count = transformList.Count; i < count; i++)
        {
            id = (int)functionOpenList[i];

            if (_curOpenIdDic.ContainsKey(id))
            {
                transformList[i].gameObject.SetActive(false);
                continue;
            }

            FunctionData data = FunctionData.GetFunctionDataByID(id);

            if (!FunctionOpenProxy.instance.IsFunctionOpen(functionOpenList[i])) //未开放
            {
                if (data.show_animation_status == 0)                             //正常显示
                {
                    transformList[i].localPosition = originPositionDic[index];
                    index++;
                }
                else
                {
                    transformList[i].localPosition = originPositionDic[i];
                    transformList[i].gameObject.SetActive(false);
                }
            }
            else             //开放
            {
                transformList[i].gameObject.SetActive(true);
                transformList[i].localPosition = originPositionDic[index];
                index++;
            }
        }
        if (_curOpenIdDic.Count > 0)
        {
            StartCoroutine(StartAnimationCoroutine());
        }
        else
        {
            _isExecute = false;
        }
    }
Пример #9
0
        internal void setMemberId()
        {
            int    type;
            string name = pop(out type);

            if (type == CallData.ID_TOKEN)
            {
                type = CallData.STRING_TOKEN;
            }
            FunctionData func = getLastFunction();

            if (!func.IsValid())
            {
                func.Call.Name.SetId(name);
                func.Call.Name.SetType(type);
            }
        }
      internal static IEnumerable<ShareInfo> EnumerateSharesCore(string host, ShareType shareType, bool continueOnException)
      {
         // When host == null, the local computer is used.
         // However, the resulting Host property will be empty.
         // So, explicitly state Environment.MachineName to prevent this.
         // Furthermore, the UNC prefix: \\ is not required and always removed.
         var stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(Path.UncPrefix, string.Empty);

         var fd = new FunctionData();
         var hasItems = false;
         var yieldAll = shareType == ShareType.All;

         // Try SHARE_INFO_503 structure.
         foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_503 structure, SafeGlobalMemoryBufferHandle buffer) =>
            new ShareInfo(stripUnc, ShareInfoLevel.Info503, structure),
            (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
               NativeMethods.NetShareEnum(stripUnc, 503, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType))
         {
            yield return si;
            hasItems = true;
         }

         // SHARE_INFO_503 is requested, but not supported/possible.
         // Try again with SHARE_INFO_2 structure.
         if (!hasItems)
            foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_2 structure, SafeGlobalMemoryBufferHandle buffer) =>
               new ShareInfo(stripUnc, ShareInfoLevel.Info2, structure),
               (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
                  NativeMethods.NetShareEnum(stripUnc, 2, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType))
            {
               yield return si;
               hasItems = true;
            }

         // SHARE_INFO_2 is requested, but not supported/possible.
         // Try again with SHARE_INFO_1 structure.
         if (!hasItems)
            foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_1 structure, SafeGlobalMemoryBufferHandle buffer) =>
               new ShareInfo(stripUnc, ShareInfoLevel.Info1, structure),
               (FunctionData functionData, out  SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
                  NativeMethods.NetShareEnum(stripUnc, 1, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType))
            {
               yield return si;
            }
      }
Пример #11
0
        private void createFunction_Click_1(object sender, EventArgs e)
        {
            var functionHelper = new FunctionData(Nametxt.Text, returnTypeTxt.Text,
                                                  scriptTb.Text);
            var sql = tManager.CreateQuery(functionHelper);

            try
            {
                connection.ExecuteCommand(sql, new string[] { });
            }
            catch (SqlException error)
            {
                MessageBox.Show(error.Message);
                return;
            }

            MessageBox.Show("Query Executed Correctly!");
        }
Пример #12
0
        void frmWorkBench_SelectedNodeChanged(object sender, EventArgs e)
        {
            FunctionData functionData = sender as FunctionData;

            if (functionData != null)
            {
                RunFunction(functionData.FunctionType);
            }
            else
            {
                IEntityData data = sender as IEntityData;
                if (data == null)
                {
                    return;
                }
                frmLeft.SetTreeNodeSelected(data.ID);
            }
        }
Пример #13
0
        private static void SimpleSubtract(FunctionData first, FunctionData second)
        {
            if (first.Continuous.Value && second.Continuous.Value)
            {
                foreach (var point in first.Points)
                {
                    if (second.Points.Any(p => Math.Abs(p.X - point.X) < double.Epsilon))
                    {
                        point.Y -= second.Points.First(p => Math.Abs(p.X - point.X) < double.Epsilon).Y;
                    }
                    else
                    {
                        point.Y -=
                            (second.Points.First(
                                 a => Math.Abs(a.X - second.Points.Where(p => p.X < point.X).Max(p => p.X))
                                 < double.Epsilon).Y + second.Points.First(
                                 a => Math.Abs(a.X - second.Points.Where(p => p.X > point.X).Min(p => p.X))
                                 < double.Epsilon).Y) / 2.0d;
                    }
                }
            }
            else
            {
                foreach (var point in first.Points)
                {
                    if (second.Points.Any(p => Math.Abs(p.X - point.X) < double.Epsilon))
                    {
                        point.Y -= second.Points.First(p => Math.Abs(p.X - point.X) < double.Epsilon).Y;
                    }
                }

                first.Points.AddRange(
                    second.Points.Where(p => !first.Points.Select(a => a.X).Contains(p.X))
                    .Select(p => new Point(p.X, p.Y * -1)));
            }

            foreach (var point in first.Points)
            {
                if (Math.Abs(point.Y) < 10E-10)
                {
                    point.Y = 0;
                }
            }
        }
Пример #14
0
    //玩家使用卡牌
    public bool UseCard(CardDataObj card, int role)
    {
        if (role == 1 && state != RoundState.PlayerRurn)
        {
            return(false);
        }
        if (role == 2 && state != RoundState.NpcTurn)
        {
            return(false);
        }
        RoleProperty self  = null;
        RoleProperty enemy = null;

        if (state == RoundState.PlayerRurn)
        {
            self  = PlayerAtt.property;
            enemy = NPCAtt.property;
        }
        else if (state == RoundState.NpcTurn)
        {
            self  = NPCAtt.property;
            enemy = PlayerAtt.property;
        }
        Debug.Log(card.data.CardName);
        for (int i = 0; i < card.data.functions.Length; i++)
        {
            FunctionData data = card.data.functions[i];
            if (data.target == EnumProperty.TargetType.Self || data.target == EnumProperty.TargetType.All)
            {
                CaculateSystem.Instance.Caculate(data.type, data.func, ref self, data.Values);
            }
            if (data.target == EnumProperty.TargetType.Enemy || data.target == EnumProperty.TargetType.All)
            {
                CaculateSystem.Instance.Caculate(data.type, data.func, ref enemy, data.Values);
            }
        }

        EntityCenter.Instance.ReleaseCard(card.gameObject);
        UIRound round = (UIRound)UIPage.GetPageInstatnce <UIRound>();

        UIRoundData[3] = RemainRound;
        round.UpdateDataShow();
        return(true);
    }
Пример #15
0
    private static ExpressionData CompileExpression_Unary(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_UnaryExpression expr
        )
    {
        var innerExpr = CompileExpression(ref passData, ref funcData, expr.ExprInner);

        StripFirstConst(ref innerExpr);

        return(innerExpr.Type->TypeTag switch {
            ES_TypeTag.Bool => CompileExpression_UnaryBool(ref passData, expr, ref innerExpr),
            ES_TypeTag.Int => CompileExpression_UnaryInt(ref passData, expr, ref innerExpr),
            ES_TypeTag.Float => CompileExpression_UnaryFloat(ref passData, expr, ref innerExpr),

            ES_TypeTag.Reference => CompileExpression_UnaryRef(ref passData, expr, ref innerExpr),

            _ => throw new CompilationException("Binary expression not supported."),
        });
Пример #16
0
        private void buildOperator()
        {
            int    type;
            string name = pop(out type);

            StatementData    arg     = popStatement();
            ISyntaxComponent argComp = simplifyStatement(arg);

            StatementData _statement = newStatementWithOneFunction();
            FunctionData  first      = _statement.First;

            first.Name.SetLine(getLastLineNumber());

            _statement.CopyFirstComments(argComp);
            argComp.FirstComments.Clear();

            mStatementSemanticStack.Push(_statement);

            StatementData statement = getCurStatement();
            FunctionData  func      = getLastFunction();

            if (!func.IsValid())
            {
                if (name.Length > 0 && name[0] == '`')
                {
                    func.SetParamClass((int)(FunctionData.ParamClassEnum.PARAM_CLASS_WRAP_INFIX_CALL_MASK | FunctionData.ParamClassEnum.PARAM_CLASS_OPERATOR));

                    func.Name.SetId(name.Substring(1));
                    func.Name.SetType(type);
                }
                else
                {
                    func.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_OPERATOR);

                    func.Name.SetId(name);
                    func.Name.SetType(type);
                }
                if (argComp.IsValid())
                {
                    func.AddParam(argComp);
                }
            }
        }
Пример #17
0
 private AbstractSyntaxComponent simplifyStatement(FunctionData data)
 {
     if (!data.HaveStatement() && !data.HaveExternScript())
     {
         //没有语句部分的函数退化为函数调用(再按函数调用进一步退化)。
         CallData call = data.Call;
         if (null != call)
         {
             call.CopyComments(data);
             return(simplifyStatement(call));
         }
         else
         {
             //error
             return(NullSyntax.Instance);
         }
     }
     return(data);
 }
Пример #18
0
        public static void Quantization(FunctionData first, FunctionData second, double quantizationLevels)
        {
            var levels = new List <double>();
            var step   = first.Amplitude.Value * 2.0d / (quantizationLevels - 1);

            for (var i = 0; i <= quantizationLevels - 1; i++)
            {
                levels.Add(-first.Amplitude.Value + i * step);
            }

            second.AssignSignal(first);

            foreach (var point in second.Points)
            {
                point.Y = levels.OrderBy(l => Math.Abs(point.Y - l)).First();
            }

            second.PointsUpdate();
        }
Пример #19
0
        /// <summary>
        /// thread pool main logic function
        /// thread scheduling management function
        /// </summary>
        /// <param name="pParam"></param>
        private void ThreadProc(object pParam)
        {
            FunctionData functions = null;

            WaitHandle[] hWaits      = new WaitHandle[2];
            ThreadData   pThreadData = pParam as ThreadData;

            hWaits[0] = pThreadData.WaitHandle;
            hWaits[1] = this.m_hNotifyShutdown;

            while (true)
            {
                EventWaitHandle.WaitAny(hWaits);

                if (this.m_bPoolIsDestroying == true)
                {
                    break;
                }

                this.BusyNotify(pThreadData);

                while ((functions = GetThreadProc()) != null)
                {
                    try
                    {
                        if (functions.RunObject != null)
                        {
                            functions.RunObject.Run();
                        }
                        else
                        {
                            functions.ThreadFunc(functions.param);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                this.FinishNotify(pThreadData);
            }
        }
Пример #20
0
    private void FunctionsGUI()
    {
        if (m_ScriptPrescription.m_Functions == null)
        {
            GUILayout.FlexibleSpace();
            return;
        }

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Functions", GUILayout.Width(kLabelWidth - 4));

            EditorGUILayout.BeginVertical(m_Styles.m_LoweredBox);
            m_OptionsScroll = EditorGUILayout.BeginScrollView(m_OptionsScroll);
            {
                bool expanded = FunctionHeader("General", true);

                for (int i = 0; i < m_ScriptPrescription.m_Functions.Length; i++)
                {
                    FunctionData func = m_ScriptPrescription.m_Functions[i];

                    if (func.name == null)
                    {
                        expanded = FunctionHeader(func.comment, false);
                    }
                    else if (expanded)
                    {
                        Rect toggleRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.toggle);
                        toggleRect.x     += 15;
                        toggleRect.width -= 15;
                        bool include = GUI.Toggle(toggleRect, func.include, new GUIContent(func.name, func.comment));
                        if (include != func.include)
                        {
                            m_ScriptPrescription.m_Functions[i].include = include;
                            SetFunctionIsIncluded(m_BaseClass, func.name, include);
                        }
                    }
                }
            } EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        } EditorGUILayout.EndHorizontal();
    }
Пример #21
0
 protected override bool Load(FunctionData funcData)
 {
     if (null != funcData)
     {
         foreach (var comp in funcData.Params)
         {
             var exp = Interpreter.Load(comp);
             if (null != exp)
             {
                 m_Statements.Add(exp);
             }
             else
             {
                 Interpreter.Log("[error] can't load {0}", comp.ToScriptString(false));
             }
         }
         return(true);
     }
     return(false);
 }
Пример #22
0
 private static void RefreshTypeIndex(ISequenceStep sequenceStep, ITypeDataCollection typeDataCollection)
 {
     if (sequenceStep.HasSubSteps)
     {
         foreach (ISequenceStep subStep in sequenceStep.SubSteps)
         {
             RefreshTypeIndex(subStep, typeDataCollection);
         }
     }
     else
     {
         FunctionData functionData = sequenceStep.Function as FunctionData;
         functionData.ClassTypeIndex = typeDataCollection.IndexOf(functionData.ClassType);
         foreach (IArgument argument in functionData.ParameterType)
         {
             RefreshTypeIndex(argument, typeDataCollection);
         }
         RefreshTypeIndex(functionData.ReturnType, typeDataCollection);
     }
 }
Пример #23
0
        //换一种数据结构存储
        private Dictionary <UnitFunctionGroupType, List <IEntityData> > GetNewDataStructure(List <IEntityData> lstAllData)
        {
            Dictionary <UnitFunctionGroupType, List <IEntityData> > groupData = null;

            if (groupData == null)
            {
                groupData = new Dictionary <UnitFunctionGroupType, List <IEntityData> >();
            }
            else
            {
                groupData.Clear();
            }

            foreach (int enumIndex in Enum.GetValues(typeof(UnitFunctionGroupType)))
            {
                UnitFunctionGroupType unitContentGroupType = (UnitFunctionGroupType)enumIndex;
                List <IEntityData>    lstData = null;
                foreach (IEntityData item in lstAllData)
                {
                    if (lstData == null)
                    {
                        lstData = new List <IEntityData>();
                    }

                    FunctionData data = item as FunctionData;
                    if (data != null && unitContentGroupType == InternalMethods.GetUnitFunctionGroupType(data.FunctionType))
                    {
                        lstData.Add(item);
                    }
                }

                if (lstData == null || lstData.Count <= 0)
                {
                    continue;
                }

                groupData.Add(unitContentGroupType, lstData);
            }

            return(groupData);
        }
Пример #24
0
        internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal)
        {
            int n;

#if MONOTOUCH
            var data = new FunctionData();
            data.Func      = func;
            data.FuncStep  = funcstep;
            data.FuncFinal = funcfinal;
            SQLiteCallback      func_callback      = func == null ? null : new SQLiteCallback(scalar_callback);
            SQLiteCallback      funcstep_callback  = funcstep == null ? null : new SQLiteCallback(step_callback);
            SQLiteFinalCallback funcfinal_callback = funcfinal == null ? null : new SQLiteFinalCallback(final_callback);

            IntPtr user_data;
            user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data));
            n         = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 4, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback);

            if (n == 0)
            {
                // sqlite3_create_function_v2 will call 'destroy_callback' if it fails, so we need to recreate the gchandle here.
                user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data));
                n         = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 1, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback);
            }
#elif !SQLITE_STANDARD
            n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
            if (n == 0)
            {
                n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
            }
#else
            n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal);
            if (n == 0)
            {
                n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal);
            }
#endif
            if (n > 0)
            {
                throw new SqliteException(n, SQLiteLastError());
            }
        }
Пример #25
0
      public static IEnumerable<DfsInfo> EnumerateDfsLinks(string dfsName)
      {
         if (!Filesystem.NativeMethods.IsAtLeastWindowsVista)
            throw new PlatformNotSupportedException(Resources.RequiresWindowsVistaOrHigher);

         if (Utils.IsNullOrWhiteSpace(dfsName))
            throw new ArgumentNullException("dfsName");

         var fd = new FunctionData();

         return EnumerateNetworkObjectInternal(fd, (NativeMethods.DfsInfo4 structure, IntPtr buffer) =>

            new DfsInfo(structure),

            (FunctionData functionData, out IntPtr buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle1) =>
            {
               totalEntries = 0;
               return NativeMethods.NetDfsEnum(dfsName, 4, prefMaxLen, out buffer, out entriesRead, out resumeHandle1);

            }, false);
      }
Пример #26
0
        internal void markStatement()
        {
            FunctionData func = getLastFunction();

            bool           commentOnNewLine;
            IList <string> cmts = GetComments(out commentOnNewLine);

            if (cmts.Count > 0)
            {
                if (func.IsHighOrder)
                {
                    func.LowerOrderFunction.Comments.AddRange(cmts);
                }
                else
                {
                    func.Comments.AddRange(cmts);
                }
            }

            func.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_STATEMENT);
        }
Пример #27
0
        private void markExternScript()
        {
            FunctionData func = getLastFunction();

            bool           commentOnNewLine;
            IList <string> cmts = GetComments(out commentOnNewLine);

            if (cmts.Count > 0)
            {
                if (func.IsHighOrder)
                {
                    func.LowerOrderFunction.Comments.AddRange(cmts);
                }
                else
                {
                    func.Comments.AddRange(cmts);
                }
            }

            func.SetParamClass((int)FunctionData.ParamClassEnum.PARAM_CLASS_EXTERN_SCRIPT);
        }
Пример #28
0
        private static void SimpleCompose(FunctionData first, FunctionData second, Operation operation)
        {
            switch (operation)
            {
            case Operation.Add:
                SimpleAdd(first, second);
                break;

            case Operation.Subtract:
                SimpleSubtract(first, second);
                break;

            case Operation.Multiply:
                SimpleMultiply(first, second);
                break;

            case Operation.Divide:
                SimpleDivide(first, second);
                break;
            }
        }
    private static ExpressionData CompileExpression_MemberAccess(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_MemberAccessExpression expr
        )
    {
        var parentExpr = CompileExpression(ref passData, ref funcData, expr.ExprParent);

        StripFirstConst(ref parentExpr);

        Debug.Assert(parentExpr.Type is not null);

        return(parentExpr.Type->TypeTag switch {
            ES_TypeTag.UNKNOWN => throw new CompilationException(ES_BackendErrors.FrontendError),

            ES_TypeTag.Struct => CompileExpression_MemberAccess_Struct(ref passData, ref funcData, expr, parentExpr),
            ES_TypeTag.Array => CompileExpression_MemberAccess_Array(ref passData, ref funcData, expr, parentExpr),
            ES_TypeTag.Reference => throw new CompilationException("Reference types must be dereferenced manually before access."),

            _ => throw new NotImplementedException("Type not implemented."),
        });
Пример #30
0
        internal void buildSecondTernaryOperator()
        {
            int    type;
            string name = pop(out type);

            StatementData statement = getCurStatement();
            FunctionData  newFunc   = new FunctionData();

            statement.Functions.Add(newFunc);

            FunctionData func = getLastFunction();

            if (!func.IsValid())
            {
                func.Call.SetParamClass((int)CallData.ParamClassEnum.PARAM_CLASS_TERNARY_OPERATOR);
                func.SetExtentClass((int)FunctionData.ExtentClassEnum.EXTENT_CLASS_STATEMENT);

                func.Call.Name.SetId(name);
                func.Call.Name.SetType(type);
            }
        }
Пример #31
0
        public ConvolutionFiltrationCorrelationViewModel(SignalViewModel first)
        {
            firstSignalViewModel = first;
            SecondSignalData     = new FunctionData();
            filter = new Filter();

            filters = new Dictionary <FilterType, string>();
            filters.Add(FilterType.LowPassFilter, "LOW-PASS FILTER");
            filters.Add(FilterType.HighPassFilter, "HIGH-PASS FILTER");

            selectedFilter = FilterType.LowPassFilter;
            window         = new RectangularWindow();
            windows        = new List <IWindow>(new IWindow[]
                                                { new RectangularWindow(), new HanningWindow() /*, new HammingWindow(), new BlackmanWindow()*/ });

            filterOrder     = new FunctionAttribute <int>(5, true, 1, 500, "FILTER ORDER");
            cutoffFrequency = new FunctionAttribute <double>(400.0d, true, 10.0d, 25000.0d, "CUTOFF FREQUENCY");

            Attributes = new List <object>(new[] { filterOrder, (object)cutoffFrequency });

            firstSignalViewModel.SignalGenerated += (sender, args) => FilterCommand.RaiseCanExecuteChanged();
        }
Пример #32
0
        public static void ZeroOrderHold(FunctionData first, FunctionData second)
        {
            second.AssignSignal(first);
            second.Continuous.Value = true;
            second.Samples.Value    = 500;

            second.Function = (data, t) =>
            {
                var ret = 0.0d;
                if (first.Points.Any(p => p.X < t))
                {
                    ret = first.Points.Where(p => p.X < t).OrderBy(p => - p.X).First().Y;
                }
                else
                {
                    ret = first.Points.OrderBy(p => Math.Abs(p.X - t)).First().Y;
                }

                return(ret);
            };
            Generator.GenerateSignal(second);
        }
Пример #33
0
        private void OnHomeShowFunction(object data)
        {
            FunctionData functionData = data as FunctionData;

            UIButton functionBtn = null;

            if (functionData.id == (int)FunctionType.Weapon)
            {
                functionBtn = weaponBtn;
            }
            else if (functionData.id == (int)FunctionType.Dungeon)
            {
                functionBtn = dungeonBtn;
            }

            if (functionBtn != null)
            {
                functionBtn.gameObject.SetActive(true);
                TweenScale tween = TweenScale.Begin(functionBtn.gameObject, 0.5f, Vector3.one);
                tween.from = Vector3.zero;
            }
        }
Пример #34
0
      private static IEnumerable<OpenResourceInfo> EnumerateOpenResourcesInternal(string host, string basePath, string typeName, bool continueOnException)
      {
         basePath = Utils.IsNullOrWhiteSpace(basePath) ? null : Path.GetRegularPathInternal(basePath, GetFullPathOptions.CheckInvalidPathChars);
         typeName = Utils.IsNullOrWhiteSpace(typeName) ? null : typeName;


         var fd = new FunctionData { ExtraData1 = basePath, ExtraData2 = typeName };

         return EnumerateNetworkObjectInternal(fd, (NativeMethods.FileInfo3 structure, IntPtr buffer) =>

            new OpenResourceInfo(host, structure),

            (FunctionData functionData, out IntPtr buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
            {
               // When host == null, the local computer is used.
               // However, the resulting OpenResourceInfo.Host property will be empty.
               // So, explicitly state Environment.MachineName to prevent this.
               // Furthermore, the UNC prefix: \\ is not required and always removed.
               string stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathInternal(host, GetFullPathOptions.CheckInvalidPathChars).Replace(Path.UncPrefix, string.Empty);

               return NativeMethods.NetFileEnum(stripUnc, fd.ExtraData1, fd.ExtraData2, 3, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle);

            },
            continueOnException);
      }
Пример #35
0
        internal void buildSecondTernaryOperator()
        {
            int type;
            string name = pop(out type);

            StatementData statement = getCurStatement();
            FunctionData newFunc = new FunctionData();
            CallData call = new CallData();
            ValueData nname = new ValueData();
            call.Name = nname;
            newFunc.Call = call;
            statement.Functions.Add(newFunc);

            FunctionData func = getLastFunction();
            if (!func.IsValid()) {
                func.Call.SetParamClass((int)CallData.ParamClassEnum.PARAM_CLASS_TERNARY_OPERATOR);
                func.SetExtentClass((int)FunctionData.ExtentClassEnum.EXTENT_CLASS_STATEMENT);

                func.Call.Name.SetId(name);
                func.Call.Name.SetType(type);
                func.Call.Name.SetLine(getLastLineNumber());
            }
        }
Пример #36
0
 private StatementData newStatement()
 {
     StatementData data = new StatementData();
     FunctionData func = new FunctionData();
     CallData call = new CallData();
     ValueData name = new ValueData();
     call.Name = name;
     func.Call = call;
     data.Functions.Add(func);
     return data;
 }
Пример #37
0
 private AbstractSyntaxComponent simplifyStatement(FunctionData data)
 {
     if (!data.HaveStatement() && !data.HaveExternScript()) {
         //没有语句部分的函数退化为函数调用(再按函数调用进一步退化)。
         CallData call = data.Call;
         if (null != call) {
             call.CopyComments(data);
             return simplifyStatement(call);
         } else {
             //error
             return NullSyntax.Instance;
         }
     } else {
         //包含语句则不会退化,只进行化简
         simplifyFunctionData(data);
         return data;
     }
 }
Пример #38
0
        internal void beginFunction()
        {
            StatementData statement = getCurStatement();
            FunctionData func = getLastFunction();
            if (func.IsValid()) {
                //语句的多元函数的其它元函数名
                FunctionData newFunc = new FunctionData();
                CallData call = new CallData();
                ValueData name = new ValueData();
                call.Name = name;
                newFunc.Call = call;

                statement.Functions.Add(newFunc);
            }
        }
Пример #39
0
    internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal)
    {
      int n;

#if MONOTOUCH
      var data = new FunctionData();
      data.Func = func;
      data.FuncStep = funcstep;
      data.FuncFinal = funcfinal;
      SQLiteCallback func_callback = func == null ? null : new SQLiteCallback(scalar_callback);
      SQLiteCallback funcstep_callback = funcstep == null ? null : new SQLiteCallback(step_callback);
      SQLiteFinalCallback funcfinal_callback = funcfinal == null ? null : new SQLiteFinalCallback(final_callback);

      IntPtr user_data;
      user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data));
      n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 4, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback);

      if (n == 0) {
        // sqlite3_create_function_v2 will call 'destroy_callback' if it fails, so we need to recreate the gchandle here.
        user_data = GCHandle.ToIntPtr(GCHandle.Alloc(data));
        n = UnsafeNativeMethods.sqlite3_create_function_v2(_sql, ToUTF8(strFunction), nArgs, 1, user_data, func_callback, funcstep_callback, funcfinal_callback, destroy_callback);
      }
#elif !SQLITE_STANDARD
      n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
      if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
#else
      n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal);
      if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal);
#endif
      if (n > 0) throw new SqliteException(n, SQLiteLastError());
    }
Пример #40
0
      internal static IEnumerable<ShareInfo> EnumerateSharesInternal(string host, bool continueOnException)
      {
         // When host == null, the local computer is used.
         // However, the resulting OpenResourceInfo.Host property will be empty.
         // So, explicitly state Environment.MachineName to prevent this.
         // Furthermore, the UNC prefix: \\ is not required and always removed.
         string stripUnc = Utils.IsNullOrWhiteSpace(host)
            ? Environment.MachineName
            : Path.GetRegularPathInternal(host, GetFullPathOptions.CheckInvalidPathChars).Replace(Path.UncPrefix, string.Empty);

         var fd = new FunctionData();
         bool hasItems = false;

         // Try ShareInfo503 structure.
         foreach (var si in EnumerateNetworkObjectInternal(fd, (NativeMethods.ShareInfo503 structure, IntPtr buffer) =>
            new ShareInfo(stripUnc, ShareInfoLevel.Info503, structure),
            (FunctionData functionData, out IntPtr buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
               NativeMethods.NetShareEnum(stripUnc, 503, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException))
         {
            yield return si;
            hasItems = true;
         }

         // ShareInfo503 is requested, but not supported/possible.
         // Try again with ShareInfo2 structure.
         if (!hasItems)
            foreach (var si in EnumerateNetworkObjectInternal(fd, (NativeMethods.ShareInfo2 structure, IntPtr buffer) =>
               new ShareInfo(stripUnc, ShareInfoLevel.Info2, structure),
               (FunctionData functionData, out IntPtr buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
                  NativeMethods.NetShareEnum(stripUnc, 2, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException))
            {
               yield return si;
               hasItems = true;
            }

         // ShareInfo2 is requested, but not supported/possible.
         // Try again with ShareInfo1 structure.
         if (!hasItems)
            foreach (var si in EnumerateNetworkObjectInternal(fd, (NativeMethods.ShareInfo1 structure, IntPtr buffer) =>
               new ShareInfo(stripUnc, ShareInfoLevel.Info1, structure),
               (FunctionData functionData, out  IntPtr buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) =>
                  NativeMethods.NetShareEnum(stripUnc, 1, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException))
            {
               yield return si;
            }
      }
            public void AddFuntion(int funcIx, bool hasFootnote, String funcName, int minParams, int maxParams,
                String returnClass, String paramClasses, String volatileFlagStr)
            {
                bool isVolatile = volatileFlagStr.Length > 0;

                int funcIxKey = funcIx;
                if (_allFunctionsByIndex.ContainsKey(funcIxKey))
                {
                    throw new RuntimeException("Duplicate function index (" + funcIx + ")");
                }
                if (_allFunctionsByName.ContainsKey(funcName))
                {
                    throw new RuntimeException("Duplicate function name '" + funcName + "'");
                }

                CheckRedefinedFunction(hasFootnote, funcName, funcIxKey);
                FunctionData fd = new FunctionData(funcIx, hasFootnote, funcName,
                        minParams, maxParams, returnClass, paramClasses, isVolatile);

                _allFunctionsByIndex.Add(funcIxKey, fd);
                _allFunctionsByName.Add(funcName, fd);
            }
Пример #42
0
 private void simplifyFunctionData(FunctionData data)
 {
     if (null != data.Call) {
         simplifyCallData(data.Call);
     }
     if (data.HaveStatement()) {
         int ct = data.GetStatementNum();
         for (int i = 0; i < ct; ++i) {
             ISyntaxComponent temp = data.GetStatement(i);
             StatementData statement = temp as StatementData;
             if (null != statement) {
                 data.SetStatement(i, simplifyStatement(statement));
             } else {
                 FunctionData func = temp as FunctionData;
                 if (null != func) {
                     data.SetStatement(i, simplifyStatement(func));
                 } else {
                     CallData call = temp as CallData;
                     if (null != call) {
                         data.SetStatement(i, simplifyStatement(call));
                     }
                 }
             }
         }
     }
 }
Пример #43
0
        private void WriteFunction(FunctionData function)
        {
            string paramString = string.Empty;
            string overrideString;
            string returnTypeString;
            string functionContentString;

            switch (m_ScriptPrescription.m_Lang)
            {
            case Language.JavaScript:
                // Comment
                WriteComment (function.comment);

                // Function header
                for (int i=0; i<function.parameters.Length; i++)
                {
                    paramString += function.parameters[i].name + " : " + TranslateTypeToJavascript (function.parameters[i].type);
                    if (i < function.parameters.Length-1)
                        paramString += ", ";
                }
                overrideString = (function.isVirtual ? "override " : string.Empty);
                returnTypeString = (function.returnType == null ? " " : " : " + TranslateTypeToJavascript (function.returnType) + " ");
                m_Writer.WriteLine (m_Indentation + overrideString + "function " + function.name + " (" + paramString + ")" + returnTypeString + "{");

                // Function content
                IndentLevel++;
                functionContentString = (function.returnType == null ? string.Empty : function.returnDefault + ";");
                m_Writer.WriteLine (m_Indentation + functionContentString);
                IndentLevel--;
                m_Writer.WriteLine (m_Indentation + "}");

                break;

            case Language.CSharp:
                // Comment
                WriteComment (function.comment);

                // Function header
                for (int i=0; i<function.parameters.Length; i++)
                {
                    paramString += function.parameters[i].type + " " + function.parameters[i].name;
                    if (i < function.parameters.Length-1)
                        paramString += ", ";
                }
                overrideString = (function.isVirtual ? "public override " : string.Empty);
                returnTypeString = (function.returnType == null ? "void " : function.returnType + " ");
                m_Writer.WriteLine (m_Indentation + overrideString + returnTypeString + function.name + " (" + paramString + ") {");

                // Function content
                IndentLevel++;
                functionContentString = (function.returnType == null ? string.Empty : function.returnDefault + ";");
                m_Writer.WriteLine (m_Indentation + functionContentString);
                IndentLevel--;
                m_Writer.WriteLine (m_Indentation + "}");

                break;

            /*case Language.Boo:
                // Comment
                WriteComment (function.comment);

                // Function header
                for (int i=0; i<function.parameters.Length; i++)
                {
                    paramString += function.parameters[i].name + " as " + TranslateTypeToBoo (function.parameters[i].type);
                    if (i < function.parameters.Length-1)
                        paramString += ", ";
                }
                overrideString = (function.isVirtual ? "public override " : string.Empty);
                returnTypeString = (function.returnType == null ? string.Empty : " as " + TranslateTypeToJavascript (function.returnType));
                m_Writer.WriteLine (m_Indentation + overrideString + "def " + function.name + " (" + paramString + ")" + returnTypeString + ":");

                // Function content
                IndentLevel++;
                functionContentString = (function.returnType == null ? "pass" : function.returnDefault);
                m_Writer.WriteLine (m_Indentation + functionContentString);
                IndentLevel--;

                break;*/
            }
        }
Пример #44
0
        /// <summary>
        /// post an object to the thread pool, and start execution thread pool
        /// </summary>
        /// <param name="runObject">Pointer to an instance of class which implements IRunObject interface.</param>
        /// <param name="priority">Low or high. Based on this the object will be added to the front or back of the list.</param>
        public void Run(IRunObject runObject, ThreadPriority priority = ThreadPriority.Low)
        {
            FunctionData functions = new FunctionData();
            functions.RunObject = runObject;
            functions.ThreadFunc = null;
            functions.param = null;

            lock (this)
            {
                if (priority == ThreadPriority.Low)
                {
                    m_functionList.AddLast(functions);
                }
                else
                {
                    m_functionList.AddFirst(functions);
                }

                foreach (ThreadData pThreadData in m_threads)
                {
                    if (pThreadData.bFree == true)
                    {
                        pThreadData.bFree = false;
                        pThreadData.WaitHandle.Set();
                        break;
                    }
                }
            }
        }