private void ExportManifestFile(List <string> modules, string outFolder) { const string kDir = "dir"; const string kDirInitCode = "dir = (dir and #dir > 0) and (dir .. '.') or \"\""; const string kRequire = "require"; const string kLoadCode = "local load = function(module) return require(dir .. module) end"; const string kLoad = "load"; const string kInit = "System.init"; const string kManifestFile = "manifest.lua"; if (modules.Count > 0) { modules.Sort(); var types = GetExportTypes(); if (types.Count > 0) { LuaFunctionExpressionSyntax functionExpression = new LuaFunctionExpressionSyntax(); functionExpression.AddParameter(new LuaIdentifierNameSyntax(kDir)); functionExpression.AddStatement(new LuaIdentifierNameSyntax(kDirInitCode)); LuaIdentifierNameSyntax requireIdentifier = new LuaIdentifierNameSyntax(kRequire); functionExpression.AddStatement(new LuaLocalVariableDeclaratorSyntax(requireIdentifier, requireIdentifier)); functionExpression.AddStatement(new LuaIdentifierNameSyntax(kLoadCode)); functionExpression.AddStatement(LuaBlankLinesStatement.One); LuaIdentifierNameSyntax loadIdentifier = new LuaIdentifierNameSyntax(kLoad); foreach (string module in modules) { var argument = new LuaStringLiteralExpressionSyntax(new LuaIdentifierNameSyntax(module)); var invocation = new LuaInvocationExpressionSyntax(loadIdentifier, argument); functionExpression.AddStatement(invocation); } functionExpression.AddStatement(LuaBlankLinesStatement.One); LuaTableInitializerExpression typeTable = new LuaTableInitializerExpression(); foreach (var type in types) { LuaIdentifierNameSyntax typeName = XmlMetaProvider.GetTypeShortName(type); typeTable.Items.Add(new LuaSingleTableItemSyntax(new LuaStringLiteralExpressionSyntax(typeName))); } LuaInvocationExpressionSyntax initInvocation = new LuaInvocationExpressionSyntax(new LuaIdentifierNameSyntax(kInit), typeTable); FillManifestInitConf(initInvocation); functionExpression.AddStatement(initInvocation); LuaCompilationUnitSyntax luaCompilationUnit = new LuaCompilationUnitSyntax(); luaCompilationUnit.Statements.Add(new LuaReturnStatementSyntax(functionExpression)); string outFile = Path.Combine(outFolder, kManifestFile); Write(luaCompilationUnit, outFile); } } }
internal void Render(LuaStringLiteralExpressionSyntax node) { Write(node.OpenParenToken); node.Identifier.Render(this); Write(node.CloseParenToken); }