public void Make(string file, string outputFilePath, int heapSize)
        {
            TypeChecker       checker   = new TypeChecker();
            AssemblyConverter converter = new AssemblyConverter();

            using (Stream stream = File.Open(file, FileMode.Open))
            {
                Parser p = Parser.CreateParser(stream);

                if (p.Parse())
                {
                    Console.WriteLine("Parsing sucessful.");
                }
                else
                {
                    Console.WriteLine("Parsing unsuccessful.");
                    return;
                }

                List <MethodNode> lmnode = p.Result;

                try
                {
                    checker.TypeCheckMethods(lmnode);
                    Console.WriteLine("Type checking passed.");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Type checking failed.");
                    Console.WriteLine(e.ToString());
                    return;
                }


                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }

                using (FileStream fs = File.Create(outputFilePath))
                {
                    try
                    {
                        string compiled = converter.ConvertMethodNodes(lmnode) + "\n \n"
                                          + GetData(heapSize);

                        Byte[] text = new UTF8Encoding(true).GetBytes(compiled);
                        fs.Write(text, 0, text.Length);

                        Console.WriteLine("Compilation succeeded.");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Compilation failed.");
                        Console.WriteLine(e.ToString());
                        return;
                    }
                }
            }
        }
Example #2
0
 public BinaryOperationConverter(AssemblyConverter converter)
 {
     this.converter = converter;
 }
Example #3
0
 public ArrayConverter(AssemblyConverter converter)
 {
     this.converter = converter;
 }