public DeltinScript(TranslateSettings translateSettings) { FileGetter = translateSettings.FileGetter; Diagnostics = translateSettings.Diagnostics; Language = translateSettings.OutputLanguage; OptimizeOutput = translateSettings.OptimizeOutput; GlobalScope = Scope.GetGlobalScope(); RulesetScope = GlobalScope.Child(); RulesetScope.PrivateCatch = true; Types.GetDefaults(this); Importer = new Importer(this, FileGetter, translateSettings.Root.Uri); Importer.CollectScriptFiles(translateSettings.Root); Translate(); if (!Diagnostics.ContainsErrors()) { ToWorkshop(translateSettings.AdditionalRules); } foreach (IComponent component in Components) { if (component is IDisposable disposable) { disposable.Dispose(); } } }
public DeltinScript(FileGetter fileGetter, Diagnostics diagnostics, ScriptFile rootRuleset, Func <VarCollection, Rule[]> addRules = null) { FileGetter = fileGetter; Diagnostics = diagnostics; types.AddRange(CodeType.DefaultTypes); Importer = new Importer(rootRuleset.Uri); CollectScriptFiles(rootRuleset); GlobalScope = Scope.GetGlobalScope(); RulesetScope = GlobalScope.Child(); Translate(); if (!diagnostics.ContainsErrors()) { ToWorkshop(addRules); } }
public DeltinScript(TranslateSettings translateSettings) { FileGetter = translateSettings.FileGetter; Diagnostics = translateSettings.Diagnostics; Language = translateSettings.OutputLanguage; OptimizeOutput = translateSettings.OptimizeOutput; types.AddRange(CodeType.DefaultTypes); Importer = new Importer(translateSettings.Root.Uri); CollectScriptFiles(translateSettings.Root); GlobalScope = Scope.GetGlobalScope(); RulesetScope = GlobalScope.Child(); RulesetScope.PrivateCatch = true; Translate(); if (!Diagnostics.ContainsErrors()) { ToWorkshop(translateSettings.AdditionalRules); } }
public DeltinScript(TranslateSettings translateSettings) { FileGetter = translateSettings.FileGetter; Diagnostics = translateSettings.Diagnostics; Language = translateSettings.OutputLanguage; OptimizeOutput = translateSettings.OptimizeOutput; GlobalScope = Scope.GetGlobalScope(); GlobalFunctions.GlobalFunctions.Add(this, GlobalScope); RulesetScope = GlobalScope.Child(); RulesetScope.PrivateCatch = true; Types.GetDefaults(this); Importer = new Importer(this, FileGetter, translateSettings.Root.Uri); Importer.CollectScriptFiles(translateSettings.Root); Translate(); if (!Diagnostics.ContainsErrors()) { try { ToWorkshop(translateSettings.AdditionalRules); } catch (Exception ex) { WorkshopCode = "An exception was thrown while translating to workshop.\r\n" + ex.ToString(); } } foreach (IComponent component in Components) { if (component is IDisposable disposable) { disposable.Dispose(); } } }