示例#1
0
文件: driver.cs 项目: rblenis/cudafy
        void Parse(CompilationSourceFile file, ModuleContainer module)
        {
            Stream input;

            try {
                input = File.OpenRead(file.Name);
            } catch {
                Report.Error(2001, "Source file `{0}' could not be found", file.Name);
                return;
            }

            // Check 'MZ' header
            if (input.ReadByte() == 77 && input.ReadByte() == 90)
            {
                Report.Error(2015, "Source file `{0}' is a binary file and not a text file", file.Name);
                input.Close();
                return;
            }

            input.Position = 0;
            SeekableStreamReader reader = new SeekableStreamReader(input, ctx.Settings.Encoding);

            Parse(reader, file, module);
            reader.Dispose();
            input.Close();
        }
示例#2
0
        public void Parse(SourceFile file, ModuleContainer module, ParserSession session, Report report)
        {
            Stream input;

            try {
                // input = File.OpenRead (file.Name);
                input = file.GetDataStream(); // aeroson's edit
            } catch {
                report.Error(2001, "Source file `{0}' could not be found", file.Name);
                return;
            }

            // Check 'MZ' header
            if (input.ReadByte() == 77 && input.ReadByte() == 90)
            {
                report.Error(2015, "Source file `{0}' is a binary file and not a text file", file.Name);
                input.Close();
                return;
            }

            input.Position = 0;
            SeekableStreamReader reader = new SeekableStreamReader(input, ctx.Settings.Encoding, session.StreamReaderBuffer);

            Parse(reader, file, module, session, report);

            if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum)
            {
                input.Position = 0;
                var checksum = session.GetChecksumAlgorithm();
                file.SetChecksum(checksum.ComputeHash(input));
            }

            reader.Dispose();
            input.Close();
        }
示例#3
0
		public void Parse (SourceFile file, ModuleContainer module)
		{
			Stream input;

			try {
				input = File.OpenRead (file.Name);
			} catch {
				Report.Error (2001, "Source file `{0}' could not be found", file.Name);
				return;
			}

			// Check 'MZ' header
			if (input.ReadByte () == 77 && input.ReadByte () == 90) {

				Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
				input.Close ();
				return;
			}

			input.Position = 0;
			SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);

			Parse (reader, file, module);

			if (ctx.Settings.GenerateDebugInfo && ctx.Report.Errors == 0 && !file.HasChecksum) {
				input.Position = 0;
				if (md5 == null)
					md5 = MD5.Create ();

				file.SetChecksum (md5.ComputeHash (input));
			}

			reader.Dispose ();
			input.Close ();
		}
        void Parse(CompilationUnit file, ModuleContainer module)
        {
            Stream input;

            try {
                input = File.OpenRead (file.Name);
            } catch {
                Report.Error (2001, "Source file `{0}' could not be found", file.Name);
                return;
            }

            // Check 'MZ' header
            if (input.ReadByte () == 77 && input.ReadByte () == 90) {
                Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
                input.Close ();
                return;
            }

            input.Position = 0;
            SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);

            Parse (reader, file, module);
            reader.Dispose ();
            input.Close ();
        }
示例#5
0
文件: driver.cs 项目: Ein/monodevelop
		void Parse (CompilationUnit file)
		{
			Stream input;

			try {
				input = File.OpenRead (file.Name);
			} catch {
				Report.Error (2001, "Source file `{0}' could not be found", file.Name);
				return;
			}

			SeekableStreamReader reader = new SeekableStreamReader (input, encoding);

			// Check 'MZ' header
			if (reader.Read () == 77 && reader.Read () == 90) {
				Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
				input.Close ();
				return;
			}

			reader.Position = 0;
			Parse (reader, file);
			reader.Dispose ();
			input.Close ();
		}	
示例#6
0
文件: driver.cs 项目: Profit0004/mono
		public void Parse (SourceFile file, ModuleContainer module, ParserSession session, Report report)
		{
			Stream input;

			try {
				input = File.OpenRead (file.Name);
			} catch {
				report.Error (2001, "Source file `{0}' could not be found", file.Name);
				return;
			}

			// Check 'MZ' header
			if (input.ReadByte () == 77 && input.ReadByte () == 90) {

				report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
				input.Close ();
				return;
			}

			input.Position = 0;
			SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding, session.StreamReaderBuffer);

			Parse (reader, file, module, session, report);

			if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) {
				input.Position = 0;
				var checksum = session.GetChecksumAlgorithm ();
				file.SetChecksum (checksum.ComputeHash (input));
			}

			reader.Dispose ();
			input.Close ();
		}