Exemplo n.º 1
0
        private static void DecodeScripts()
        {
            Tuple <ScriptFile, string> scriptTuple;

            while (DecodeList.Count > 0)
            {
                lock (Program.ReadLock)
                    scriptTuple = DecodeList.Dequeue();

                try
                {
                    Console.WriteLine("Decoding: " + scriptTuple.Item1.Header.ScriptName + " > " + scriptTuple.Item2);
                    ScriptFile scriptFile = scriptTuple.Item1.BuildAggregation().Decode();
                    SaveScriptFile(scriptFile, scriptTuple.Item2).Close();

                    if (AggregateFunctions)
                    {
                        scriptFile.CompileAggregate();
                    }
                }
                catch (Exception ex)
                {
                    throw new SystemException("Error decoding script " + scriptTuple.Item1.Header.ScriptName + " - " + ex.Message);
                }
            }
            Program.ThreadCount--;
        }
Exemplo n.º 2
0
        private static void Decompile()
        {
            while (CompileList.Count > 0)
            {
                string scriptToDecode;
                lock (Program.ThreadLock)
                {
                    scriptToDecode = CompileList.Dequeue();
                }
                try
                {
                    string suffix  = ".c" + (Program.CompressedOutput ? ".gz" : "");
                    string outname = Path.GetFileNameWithoutExtension(scriptToDecode);
                    if (Path.GetExtension(scriptToDecode) == ".gz") // Ensure the extension without compression is removed.
                    {
                        outname = Path.GetFileNameWithoutExtension(outname);
                    }

                    string output = Path.Combine(SaveDirectory, outname + suffix);
                    Console.WriteLine("Decompiling: " + scriptToDecode + " > " + output);

                    ScriptFile scriptFile = ProcessScriptfile(scriptToDecode, output);
                    if (Program.AggregateFunctions) /* Compile aggregation statistics for each function. */
                    {
                        scriptFile.CompileAggregate();
                    }

                    scriptFile.Close();
                    if ((_gcCount.Value++) % 25 == 0)
                    {
                        GC.Collect();
                    }
                }
                catch (Exception ex)
                {
                    throw new SystemException("Error decompiling script " + Path.GetFileNameWithoutExtension(scriptToDecode) + " - " + ex.Message);
                }
            }
            Program.ThreadCount--;
        }