/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/ScriptEngine/Compiler/DefaultCompilerBackend.cs
52 строки
2 KB
EvilBeaver
fixes #1540 Предупреждение о неявных импортах
01 дек 2025, 12:27
01 дек 2025, 12:27
9ef7b18
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; using OneScript.Compilation; using OneScript.Compilation.Binding; using OneScript.Execution; using OneScript.Language; using OneScript.Language.SyntaxAnalysis.AstNodes; namespace ScriptEngine.Compiler { public class DefaultCompilerBackend : ICompilerBackend { private readonly StackMachineCodeGenerator _codeGen; public DefaultCompilerBackend(IErrorSink errorSink, ExplicitImportsBehavior importsOption) { _codeGen = new StackMachineCodeGenerator(errorSink, importsOption); } public IDependencyResolver DependencyResolver { get; set; } public bool GenerateDebugCode { get; set; } public bool GenerateCodeStat { get; set; } public SymbolTable Symbols { get; set; } public IExecutableModule Compile(ModuleNode parsedModule, Type classType, IBslProcess process) { _codeGen.ProduceExtraCode = GetCodeFlags(); _codeGen.DependencyResolver = DependencyResolver; return _codeGen.CreateModule(parsedModule, parsedModule.Source, Symbols, process); } private CodeGenerationFlags GetCodeFlags() { CodeGenerationFlags cs = CodeGenerationFlags.Always; if (GenerateDebugCode) cs |= CodeGenerationFlags.DebugCode; if (GenerateCodeStat) cs |= CodeGenerationFlags.CodeStatistics; return cs; } } }