Exemple #1
0
        public void Init(InstDeclController controller)
        {
            _controller = controller;
            _cli        = CliOptions.GetInstance();
            _nl         = Environment.NewLine;
            _externFncs = new List <string>();

            if (CliOptions.Arch.Arch == System.Reflection.ProcessorArchitecture.Amd64)
            {
                byteWidth     = 1;
                shortWidth    = 2;
                intWidth      = 4;
                longWidth     = 8;
                longlongWidth = 16;

                bitMode = 64;
            }
            else if (CliOptions.Arch.Arch == System.Reflection.ProcessorArchitecture.X86)
            {
                byteWidth     = 1;
                shortWidth    = 2;
                intWidth      = 4;
                longWidth     = 8;
                longlongWidth = 16;

                bitMode = 32;
            }
        }
Exemple #2
0
        public void FilesExist()
        {
            CliOptions.GetInstance().Refresh(new string[] { "--src=" + helloPath + ".kcc" });
            Utils.CallSystem("kcc", "--src=" + helloPath);

            Assert.IsTrue(File.Exists(helloPath + ".kcc"), $"{helloPath}.kcc not found");
            Assert.IsTrue(File.Exists(helloPath + ".s"), $"{helloPath}.s not found");
            Assert.IsTrue(File.Exists(helloPath + ".exe") || File.Exists(helloPath), $"{helloPath}(.exe) not found");
        }
Exemple #3
0
        public void HelloWorld()
        {
            CliOptions cli = CliOptions.GetInstance();

            cli.Refresh(new string[] { "--src=" + KCCEnv.BaseUri + "/" + helloPath + ".kcc" });
            var    exec     = CliOptions.Arch.OS == CommonLangLib.OS.Windows ? ".exe" : "";
            string actual   = Utils.CallSystem($"{KCCEnv.BaseUri}/src/prints/helloworld{exec}", "");
            string expected = "Hello, world \r\nGoodbye\r\n";

            Assert.AreEqual(expected, actual, "Hello world output not as expected");
        }
Exemple #4
0
 public LocaleArchFrags(ArchId arch)
 {
     _arch = arch;
     _mode = Mode.InactMode;
     _cli  = CliOptions.GetInstance();
 }
Exemple #5
0
        private static int Main(string[] args)
        {
            KCCEnv.Init();

            //Parse CLI options
            var cliOptions = CliOptions.GetInstance();

            cliOptions.ParseCli(args);
            cliOptions.ReadHelpFile();

            //Initialize
            Debug.Init(cliOptions.EnableDebugMessages);
            var errorReporter = ErrorReporter.GetInstance();
            var pageDistro    = PageDistro.GetInstance();

            errorReporter.ValidateAndFlush();

            //TODO replace with ErrorReporter.FatalError?
            if (!cliOptions.IsValid())
            {
                ColorIO.WriteLineError("Fatal Errors Found: Cannot Continue");
                return(-1);
            }

            if (cliOptions.Src == null)
            {
                ColorIO.WriteLineError("Source file is either unspecified or unable to be read");
                return(-1);
            }

            var preProcessor = new PreProcessor.PreProcessor();

            preProcessor.PreCompileProject(cliOptions.Src);

            var translator = new Translator();

            PageInfo pageInfo;

            while ((pageInfo = pageDistro.GetNextPage()) != null)
            {
                translator.Translate(pageInfo.ToString());
            }


            if (errorReporter.ValidateAndFlush())
            {
                ColorIO.WriteLineError("Fatal Errors Found: Cannot Continue");
                return(-1);
            }

            var converter = new Converter();

            converter.LogInternalTranslation();

            if (errorReporter.ValidateAndFlush())
            {
                ColorIO.WriteLineError("Fatal Errors Found: Cannot Continue");
                return(-1);
            }

            converter.Build();

            return(0);
        }
Exemple #6
0
 public Converter()
 {
     _asm        = new List <string>();
     _cli        = CliOptions.GetInstance();
     _controller = InstDeclController.GetInstance();
 }