@@ -45,6 +45,12 @@ namespace sol {
4545
4646 template <>
4747 struct is_automagical <std::filesystem::path> : std::false_type {};
48+
49+ template <>
50+ struct is_automagical <OptimizerModuleLua> : std::false_type {};
51+
52+ template <>
53+ struct is_automagical <OptimizerModuleBase::Node> : std::false_type {};
4854}
4955
5056
@@ -237,10 +243,24 @@ LuaHandler::LuaHandler() {
237243
238244 auto result = comp.preprocessScript (path.generic_string (), (" \\ " / pathRelative).generic_string ());
239245 return result;
240- }
246+ },
247+
248+ " CompileScriptToFile" , [](ScriptCompiler& comp, const std::filesystem::path& path, const std::filesystem::path& outputFile, OptimizerModuleLua& luaOptimizer) {
249+ auto rootDir = path.root_path ();
250+ auto pathRelative = path.lexically_relative (rootDir);
241251
252+ comp.compileScriptLua (path.generic_string (), (" \\ " / pathRelative).generic_string (), luaOptimizer, outputFile);
253+ }
242254 );
243255
256+ lua.new_usertype <OptimizerModuleLua>(
257+ " OptimizerModuleLua" , sol::no_constructor,
258+ " new" , [](sol::protected_function func) {
259+ OptimizerModuleLua opt;
260+ opt.nodeHandler = func;
261+ return opt;
262+ }
263+ );
244264
245265
246266 lua.new_usertype <sqf::runtime::parser::macro>(
@@ -337,17 +357,17 @@ LuaHandler::LuaHandler() {
337357
338358 lua.new_usertype <OptimizerModuleBase::Node>(
339359 " OptimizerNode" , sol::no_constructor,
340- " type" , sol::var (&OptimizerModuleBase::Node::type),
341- " file" , sol::var (&OptimizerModuleBase::Node::file),
342- " line" , sol::var (&OptimizerModuleBase::Node::line),
343- " offset" , sol::var (&OptimizerModuleBase::Node::offset),
344- " children" , sol::var (&OptimizerModuleBase::Node::children),
345- " constant" , sol::var (&OptimizerModuleBase::Node::constant),
360+ " type" , &OptimizerModuleBase::Node::type,
361+ " file" , &OptimizerModuleBase::Node::file,
362+ " line" , &OptimizerModuleBase::Node::line,
363+ " offset" , &OptimizerModuleBase::Node::offset,
364+ " children" , &OptimizerModuleBase::Node::children,
365+ " constant" , &OptimizerModuleBase::Node::constant,
366+ " value" , &OptimizerModuleBase::Node::value,
346367 " areChildrenConstant" , &OptimizerModuleBase::Node::areChildrenConstant
347368 );
348369
349- lua.new_enum (" InstructionType"
350- " OptimizerNode" , sol::no_constructor,
370+ lua.new_enum (" InstructionType" ,
351371 " endStatement" , InstructionType::endStatement,
352372 " push" , InstructionType::push,
353373 " callUnary" , InstructionType::callUnary,
@@ -359,6 +379,11 @@ LuaHandler::LuaHandler() {
359379 " makeArray" , InstructionType::makeArray
360380 );
361381
382+ lua.new_usertype <ScriptConstantArray>(
383+ " ScriptConstantArray" , sol::default_constructor
384+ );
385+
386+
362387 lua[" ASC" ] = LuaASC{};
363388}
364389
0 commit comments