Пример #1
0
        public void TestUnknownNative()
        {
            var nativeDB = NativeDB.FromJson(@"
            {
                ""TranslationTable"": [[1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317, 1234605617868164317]],
                ""HashToRows"": [{ ""Hash"": 1234605617868164317, ""Rows"": [ 0 ] }],
                ""Commands"": [{
                      ""Hash"": 1234605617868164317,
                      ""Name"": ""TEST"",
                      ""Build"": 323,
                      ""Parameters"": [{ ""Type"": ""int"", ""Name"": ""a""}, { ""Type"": ""int"", ""Name"": ""b""}],
                      ""ReturnType"": ""void""
                    }
                ]
            }");

            var d = ParseAndIdentify($@"
                NATIVE PROC UNKNOWN_TEST(INT a, INT b)

                SCRIPT test_script
                ENDSCRIPT
            ", nativeDB);

            Assert.True(d.HasErrors);
            Assert.Single(d.Errors);
        }
Пример #2
0
        public static void DoTest()
        {
            //NativeDB.Fetch(new Uri("https://raw.githubusercontent.com/alloc8or/gta5-nativedb-data/master/natives.json"), "ScriptHookV_1.0.2060.1.zip")
            //    .ContinueWith(t => File.WriteAllText("nativedb.json", t.Result.ToJson()))
            //    .Wait();

            var nativeDB = NativeDB.FromJson(File.ReadAllText("nativedb.json"));

            using var reader = new StringReader(Code);
            var comp = new Compilation {
                NativeDB = nativeDB
            };

            comp.SetMainModule(reader);
            comp.Compile();
            File.WriteAllText("test_script.ast.txt", comp.MainModule.GetAstDotGraph());

            var d       = comp.GetAllDiagnostics();
            var symbols = comp.MainModule.SymbolTable;

            Console.WriteLine($"Errors:   {d.HasErrors} ({d.Errors.Count()})");
            Console.WriteLine($"Warnings: {d.HasWarnings} ({d.Warnings.Count()})");
            foreach (var diagnostic in d.AllDiagnostics)
            {
                diagnostic.Print(Console.Out);
            }

            foreach (var s in symbols.Symbols)
            {
                if (s is TypeSymbol t && t.Type is StructType struc)
                {
                    Console.WriteLine($"  > '{t.Name}' Size = {struc.SizeOf}");
                }
            }

            Console.WriteLine();
            new Dumper(comp.CompiledScript).Dump(Console.Out, true, true, true, true, true);

            YscFile ysc = new YscFile
            {
                Script = comp.CompiledScript
            };

            string outputPath = "test_script.ysc";

            byte[] data = ysc.Save(Path.GetFileName(outputPath));
            File.WriteAllBytes(outputPath, data);

            outputPath = Path.ChangeExtension(outputPath, "unencrypted.ysc");
            data       = ysc.Save();
            File.WriteAllBytes(outputPath, data);
            ;
        }
Пример #3
0
        public static void DoTest()
        {
            //NativeDB.Fetch(new Uri("https://raw.githubusercontent.com/alloc8or/gta5-nativedb-data/master/natives.json"), "ScriptHookV_1.0.2060.1.zip")
            //    .ContinueWith(t => File.WriteAllText("nativedb.json", t.Result.ToJson()))
            //    .Wait();

            var nativeDB = NativeDB.FromJson(System.IO.File.ReadAllText("nativesdb.json"));

            const string BaseDir = "D:\\sources\\gtav-sc-tools\\examples\\language_sample\\";

            Parse(BaseDir + "language_sample_main.sc", nativeDB);
            Parse(BaseDir + "language_sample_child.sc", nativeDB);
            //Parse(BaseDir + "language_sample_shared.sch");

            ;
        }