public override string ToString(LuaDocumentNode documentNode) { if (!comment.Contains("\n")) { return($"--{comment}"); } return($"--[[{comment}]]--"); }
public override string ToString(LuaDocumentNode documentNode) { StringBuilder builder = new StringBuilder(); //field LuaFieldNode field = new LuaFieldNode($"_{propertyName}", memberType, initStatementNode); builder.Append(field.ToString(documentNode)).Append(nextLine); //get function LuaFunctionNode getFunctionNode = new LuaFunctionNode($"get{propertyName}", memberType, null, new List <LuaBaseStatementNode>()); if (getStatementNodes == null || getStatementNodes.Count == 0) { var getStatementNode = new LuaScriptStatementNode(defualtGetStatement); getFunctionNode.statementNodes.Add(getStatementNode); } for (int i = 0; i < getStatementNodes.Count; i++) { getFunctionNode.statementNodes.Add(getStatementNodes[i]); } builder.Append(getFunctionNode.ToString(documentNode)).Append(nextLine); //set function LuaFunctionNode setFunctionNode = new LuaFunctionNode($"set{propertyName}", memberType, new List <string>(), new List <LuaBaseStatementNode>()); setFunctionNode.functionArg.Add(propertyName); if (setStatementNodes == null || setStatementNodes.Count == 0) { var setStatementNode = new LuaScriptStatementNode(defualtSetStatement); setFunctionNode.statementNodes.Add(setStatementNode); } for (int i = 0; i < setStatementNodes.Count; i++) { setFunctionNode.statementNodes.Add(setStatementNodes[i]); } builder.Append(setFunctionNode.ToString(documentNode)); return(builder.ToString()); }
public override string ToString(LuaDocumentNode documentNode) { StringBuilder builder = new StringBuilder(); if (memberType == LuaMemberType.Local) { builder.Append("local "); } builder.Append(fieldName); if (initStatementNode != null) { builder.Append(" = ").Append(initStatementNode.ToString(documentNode)); } return(builder.ToString()); }
public override string ToString(LuaDocumentNode documentNode) { StringBuilder builder = new StringBuilder(); builder.Append("function "); if (memberType == LuaMemberType.Local) { builder.Append(documentNode.ClassName).Append(":"); } builder.Append(functionName).Append("("); if (functionArg != null && functionArg.Count > 0) { for (int i = 0; i < functionArg.Count; i++) { if (i != 0) { builder.Append(","); } builder.Append(functionArg[i]); } } builder.Append($"){childNextLine}"); builder.Append(childNextLine); if (statementNodes != null && statementNodes.Count > 0) { for (int i = 0; i < statementNodes.Count; i++) { statementNodes[i].stateLayer = stateLayer + 1; } for (int i = 0; i < statementNodes.Count; i++) { builder.Append(statementNodes[i].ToString(documentNode)) .Append(statementNodes[i].nextLine); } } builder.Append(nextLine); builder.Append($"end {LuaDocumentNode.Lua_FUNC_END}"); return(builder.ToString()); }
public override string ToString(LuaDocumentNode documentNode) { return(script.ToString()); }
public override string ToString(LuaDocumentNode documentNode) { return($"module(\"{modelName}\", package.seeall)"); }
public override string ToString(LuaDocumentNode documentNode) { return($"require \"{requireName}\""); }
/// <summary> /// 转换为字符串 /// </summary> /// <param name="documentNode"></param> /// <returns></returns> public abstract string ToString(LuaDocumentNode documentNode);