コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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();
                }
            }
        }