Beispiel #1
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     List<Node> arguments = function.GetArguments(1);
     LabelNode gosubTargetLabel = VerifyType<LabelNode>(arguments[0]);
     walker.scriptBuilder.EmitStatement($"call {gosubTargetLabel.labelName}");
 }
Beispiel #2
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     walker.sawJumpfCommand = true;
     walker.scriptBuilder.EmitStatement($"jump {GetJumpfLabelNameFromID(walker.jumpfTargetCount)}");
 }
Beispiel #3
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     List<Node> arguments = function.GetArguments(1);
     walker.functionLookup.RegisterUserFunction(VerifyType<AliasNode>(arguments[0]).aliasName);
 }
Beispiel #4
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     TreeWalker.HandleAliasNode(walker, function, isNumAlias:true);
 }
Beispiel #5
0
 public abstract void HandleFunctionNode(TreeWalker walker, FunctionNode function);
Beispiel #6
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     List<Node> arguments = function.GetArguments(1);
     string lvalue = walker.TranslateExpression(arguments[0]);
     walker.scriptBuilder.EmitPython($"{lvalue} -= 1");
 }
Beispiel #7
0
        static bool CompileScript(string[] lines, SubroutineDatabase subroutineDatabase)
        {
#if true
            RenpyScriptBuilder scriptBuilder = new RenpyScriptBuilder();
            TreeWalker         walker        = new TreeWalker(scriptBuilder);

            //CodeBlocks cbs = ReadSegments(lines);

            StringBuilder    simpleWriter   = new StringBuilder();
            StringBuilder    debugBuilder   = new StringBuilder();
            HashSet <string> modified_lines = new HashSet <string>();

            bool error = ParseSection(lines, subroutineDatabase, isProgramBlock: true, out List <List <Node> > allLines);
            if (error)
            {
                return(error);
            }

            if (lines.Length != allLines.Count())
            {
                throw new Exception("lines weren't decoded correctly");
            }

            string debugPath = @"C:\drojf\large_projects\ponscripter_parser\renpy\ponscripty\game\debug.txt";
            string savePath  = @"C:\drojf\large_projects\ponscripter_parser\renpy\ponscripty\game\script.rpy";
            scriptBuilder.SaveFile("prelude.rpy", savePath);

            using (StreamWriter writer = File.CreateText(savePath))
            {
                writer.Write(simpleWriter.ToString());
            }

            using (StreamWriter writer = File.CreateText(debugPath))
            {
                writer.WriteLine("Unique Modified Lines:");
                foreach (string s in modified_lines)
                {
                    writer.WriteLine(s.ToString());
                }
                writer.WriteLine("\n\n");

                writer.WriteLine("Possibly Missed lines:");
                writer.Write(debugBuilder.ToString());
            }
#else
            RenpyScriptBuilder scriptBuilder = new RenpyScriptBuilder();
            TreeWalker         walker        = new TreeWalker(scriptBuilder);

            CodeBlocks cbs = ReadSegments(lines);

            StringBuilder    simpleWriter   = new StringBuilder();
            StringBuilder    debugBuilder   = new StringBuilder();
            HashSet <string> modified_lines = new HashSet <string>();

            // Write to Init Region
            //scriptBuilder.SetBodyRegion();
            foreach (string line in cbs.header)
            {
                AppendSLToForwardSlashAndBlankLine(line, subroutineDatabase, scriptBuilder, walker, simpleWriter, debugBuilder, modified_lines, isProgramBlock: true);
            }

            foreach (string line in cbs.definition)
            {
                AppendSLToForwardSlashAndBlankLine(line, subroutineDatabase, scriptBuilder, walker, simpleWriter, debugBuilder, modified_lines, isProgramBlock: true);
            }

            // Write to Body Region
            //scriptBuilder.SetBodyRegion();
            foreach (string line in cbs.program)
            {
                AppendSLToForwardSlashAndBlankLine(line, subroutineDatabase, scriptBuilder, walker, simpleWriter, debugBuilder, modified_lines, isProgramBlock: true);
            }

            string debugPath = @"C:\drojf\large_projects\ponscripter_parser\renpy\ponscripty\game\debug.txt";
            string savePath  = @"C:\drojf\large_projects\ponscripter_parser\renpy\ponscripty\game\script.rpy";
            scriptBuilder.SaveFile("prelude.rpy", savePath);

            using (StreamWriter writer = File.CreateText(savePath))
            {
                writer.Write(simpleWriter.ToString());
            }

            using (StreamWriter writer = File.CreateText(debugPath))
            {
                writer.WriteLine("Unique Modified Lines:");
                foreach (string s in modified_lines)
                {
                    writer.WriteLine(s.ToString());
                }
                writer.WriteLine("\n\n");

                writer.WriteLine("Possibly Missed lines:");
                writer.Write(debugBuilder.ToString());
            }
#endif
            return(true);
        }