示例#1
0
 public override string ToString(LuaDocumentNode documentNode)
 {
     if (!comment.Contains("\n"))
     {
         return($"--{comment}");
     }
     return($"--[[{comment}]]--");
 }
示例#2
0
        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());
        }
示例#3
0
        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());
        }
示例#4
0
        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());
        }
示例#5
0
 public override string ToString(LuaDocumentNode documentNode)
 {
     return(script.ToString());
 }
示例#6
0
 public override string ToString(LuaDocumentNode documentNode)
 {
     return($"module(\"{modelName}\", package.seeall)");
 }
示例#7
0
 public override string ToString(LuaDocumentNode documentNode)
 {
     return($"require \"{requireName}\"");
 }
示例#8
0
 /// <summary>
 /// 转换为字符串
 /// </summary>
 /// <param name="documentNode"></param>
 /// <returns></returns>
 public abstract string ToString(LuaDocumentNode documentNode);