Example #1
0
        public IJInterpreter CreateInterpreter()
        {
            lock (_interpreters) {
                if (_typeDb == null) {
                    _typeDb = MakeTypeDatabase();
                } else if (_typeDb.DatabaseDirectory != GetConfiguredDatabasePath() && ConfigurableDatabaseExists()) {
                    // database has been generated for this interpreter, switch to the specific version.
                    _typeDb.DatabaseCorrupt -= OnDatabaseCorrupt;
                    _typeDb = new JTypeDatabase(GetConfiguredDatabasePath(), Is6x);
                    _typeDb.DatabaseCorrupt += OnDatabaseCorrupt;
                }

                var res = new CJInterpreter(this, _typeDb);

                _interpreters.Add(new WeakReference(res));

                return res;
            }
        }
Example #2
0
        private void OnDatabaseCorrupt(object sender, EventArgs args)
        {
            _typeDb = JTypeDatabase.CreateDefaultTypeDatabase(_config.Version);
            OnNewDatabaseAvailable();

            GenerateCompletionDatabaseWorker(
                GenerateDatabaseOptions.StdLibDatabase | GenerateDatabaseOptions.BuiltinDatabase,
                () => { }
            );
        }
Example #3
0
        private bool GenerateCompletionDatabaseWorker(GenerateDatabaseOptions options, Action databaseGenerationCompleted)
        {
            lock (this) {
                _generating = true;
            }
            string outPath = GetConfiguredDatabasePath();

            if (!JTypeDatabase.Generate(
                new JTypeDatabaseCreationRequest() { DatabaseOptions = options, Factory = this, OutputPath = outPath },
                () => {
                    lock (_interpreters) {
                        if (ConfigurableDatabaseExists()) {
                            if (_typeDb != null) {
                                _typeDb.DatabaseCorrupt -= OnDatabaseCorrupt;
                            }

                            _typeDb = new JTypeDatabase(outPath, Is6x);
                            _typeDb.DatabaseCorrupt += OnDatabaseCorrupt;
                            OnNewDatabaseAvailable();
                        }
                    }
                    databaseGenerationCompleted();
                    lock (this) {
                        _generating = false;
                    }
                })) {
                lock (this) {
                    _generating = false;
                }
                return false;
            }

            return true;
        }
Example #4
0
        internal JTypeDatabase MakeTypeDatabase()
        {
            if (ConfigurableDatabaseExists()) {
                var res = new JTypeDatabase(GetConfiguredDatabasePath(), Is6x);
                res.DatabaseCorrupt += OnDatabaseCorrupt;
                return res;
            }

            // default DB is "never" corrupt
            return JTypeDatabase.CreateDefaultTypeDatabase(_config.Version);
        }
Example #5
0
 public CJInterpreter(IJInterpreterFactory interpFactory, JTypeDatabase typeDb)
 {
     _typeDb = typeDb;
     _factory = interpFactory;
 }
Example #6
0
 private void EnsureInstanceDb()
 {
     if (!_typeDb.CanLoadModules) {
         _typeDb = _typeDb.Clone();
     }
 }