Exemplo n.º 1
0
        private void GenerateBlocks()
        {
            return; // it can brake scripts so fak it

            for (int m = 0; m < ScriptContent.Length; m++)
            {
                try
                {
                    if (ScriptContent[m] == "{" && !ScriptContent[m - 1].Contains("func"))
                    {
                        int     methodStartIdx = m + 1;
                        int     end            = 0;
                        EMethod blockMethod    = new EMethod();
                        blockMethod.Name    = "Block_" + GlobalVars.RandomString(10);
                        blockMethod.Options = new List <string>()
                        {
                            "Hidden", "ESCRIPT"
                        };

                        for (int c = methodStartIdx; c < ScriptContent.Length; c++)
                        {
                            if (!ScriptContent[c].StartsWith("}"))
                            {
                                if (ScriptContent[c].Length <= 0)
                                {
                                    continue;
                                }
                                if (ScriptContent[c].StartsWith("//"))
                                {
                                    continue;
                                }

                                blockMethod.Code.Add(ScriptContent[c]);
                            }
                            else
                            {
                                end = c;
                                break;
                            }
                        }

                        GlobalVars.Methods.Add(blockMethod);
                        ScriptContent    = GlobalVars.RemoveEntries(ScriptContent, m + 1, end);
                        ScriptContent[m] = ScriptContent[m].Replace("{", blockMethod.Name);
                        Program.Debug($"Added block: {blockMethod.Name} at {m} line");
                    }
                }
                catch { }
            }
        }