Exemple #1
0
        internal void SaveCompiledCode()
        {
            string savePath = _context.RubyOptions.SavePath;

            if (savePath != null)
            {
                lock (_compiledFileMutex) {
                    var assemblyPath = Path.Combine(savePath, Path.GetFileName(_context.RubyOptions.MainFile) + ".dll");

                    Utils.Log(String.Format("SAVING to {0}", Path.GetFullPath(assemblyPath)), "LOADER");

                    // TODO: allocate eagerly (as soon as config gets fixed)
                    if (_compiledFiles == null)
                    {
                        _compiledFiles = new Dictionary <string, CompiledFile>();
                    }

                    ScriptCode[] codes = new ScriptCode[_compiledFiles.Count];
                    int          i     = 0;
                    foreach (CompiledFile file in _compiledFiles.Values)
                    {
                        codes[i++] = file.CompiledCode;
                    }

                    ScriptCode.SaveToAssembly(assemblyPath, codes);
                }
            }
        }