static class · System

Console

public static class Console
Tipo
static class
Espacio de nombres
System
Ensamblado
System.Core
Acceso
public, static, abstract
Archivo fuente
Console.ant

Herencia

Clases base
Any Console

Propiedades

TextWriter Out { get; }
#

static read-only

The standard output as a TextWriter (it flushes after every write).

TextWriter Error { get; }
#

static read-only

The standard error as a TextWriter (it flushes after every write).

TextReader In { get; }
#

static read-only

The standard input as a TextReader.

Métodos

OpenStandardInput() : Stream
#

static

The standard input as a stream of bytes (do not mix it with ReadLine, which reads it on its own).

OpenStandardOutput() : Stream
#

static

The standard output as a stream of bytes (what goes through it and through Write keeps its order).

OpenStandardError() : Stream
#

static

Write(str text)
#

static

Write(i8 value)
#

static

Write(i16 value)
#

static

Write(i32 value)
#

static

Write(i64 value)
#

static

Write(i128 value)
#

static

Write(i256 value)
#

static

Write(u8 value)
#

static

Write(u16 value)
#

static

Write(u32 value)
#

static

Write(u64 value)
#

static

Write(u128 value)
#

static

Write(u256 value)
#

static

Write(f16 value)
#

static

Write(f32 value)
#

static

Write(f64 value)
#

static

Write(f128 value)
#

static

Write(f256 value)
#

static

Write(bool value)
#

static

Write(any value)
#

static

Any object or boxed value: its text when it has one of its own (IToString), else its class's.

ReadLine() : str?
#

static

The next line of the standard input (without its line break), or null at its end.

WriteLine()
#

static

WriteLine(str text)
#

static

WriteLine(i8 value)
#

static

WriteLine(i16 value)
#

static

WriteLine(i32 value)
#

static

WriteLine(i64 value)
#

static

WriteLine(i128 value)
#

static

WriteLine(i256 value)
#

static

WriteLine(u8 value)
#

static

WriteLine(u16 value)
#

static

WriteLine(u32 value)
#

static

WriteLine(u64 value)
#

static

WriteLine(u128 value)
#

static

WriteLine(u256 value)
#

static

WriteLine(f16 value)
#

static

WriteLine(f32 value)
#

static

WriteLine(f64 value)
#

static

WriteLine(f128 value)
#

static

WriteLine(f256 value)
#

static

WriteLine(bool value)
#

static

WriteLine(any value)
#

static

Miembros privados e internos (10)

StreamWriter? output
#

private static

StreamWriter? error
#

private static

StreamReader? input
#

private static

extern("print.utf8") PrintUtf8(u8[] bytes)
#

private static

extern("print.i64") PrintInteger(i64 value)
#

private static

extern("print.u64") PrintUnsigned(u64 value)
#

private static

extern("print.bool") PrintBool(bool value)
#

private static

extern("print.line") PrintLine()
#

private static

extern("read.line") ReadInto() : i64
#

private static

extern("read.unit") ReadUnit(i64 index) : i64
#

private static

Miembros heredados (5)

Código fuente

Console en Antril, descompilado a partir de su Larva HIR.

System.Console.ant
// System.Console — System.Core (decompiled from Larva HIR)

import System.IO;

into namespace System
{
	public static class Console
	{
		StreamWriter? output;
		StreamWriter? error;
		StreamReader? input;

		extern("print.utf8") PrintUtf8(u8[] bytes);

		extern("print.i64") PrintInteger(i64 value);

		extern("print.u64") PrintUnsigned(u64 value);

		extern("print.bool") PrintBool(bool value);

		extern("print.line") PrintLine();

		extern("read.line") ReadInto() : i64;

		extern("read.unit") ReadUnit(i64 index) : i64;

		public:
			/// The standard input as a stream of bytes (do not mix it with ReadLine, which reads it on its own).
			OpenStandardInput() : Stream => new HandleStream(0, "the standard input", true, false);

			/// The standard output as a stream of bytes (what goes through it and through Write keeps its order).
			OpenStandardOutput() : Stream => new HandleStream(1, "the standard output", false, true);

			OpenStandardError() : Stream => new HandleStream(2, "the standard error", false, true);

			Write(str text)
			{
				PrintUtf8(text.Units());
			}

			Write(i8 value)
			{
				PrintInteger(value);
			}

			Write(i16 value)
			{
				PrintInteger(value);
			}

			Write(i32 value)
			{
				PrintInteger(value);
			}

			Write(i64 value)
			{
				PrintInteger(value);
			}

			Write(i128 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(i256 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(u8 value)
			{
				PrintUnsigned(value);
			}

			Write(u16 value)
			{
				PrintUnsigned(value);
			}

			Write(u32 value)
			{
				PrintUnsigned(value);
			}

			Write(u64 value)
			{
				PrintUnsigned(value);
			}

			Write(u128 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(u256 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(f16 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(f32 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(f64 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(f128 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(f256 value)
			{
				PrintUtf8(value.ToString().Units());
			}

			Write(bool value)
			{
				PrintBool(value);
			}

			/// Any object or boxed value: its text when it has one of its own (IToString), else its class's.
			Write(any value)
			{
				if (value is IToString own)
					PrintUtf8(own.ToString().Units());
				else
					PrintUtf8(value.ToString().Units());
			}

			/// The next line of the standard input (without its line break), or null at its end.
			ReadLine() : str?
			{
				i64 length = ReadInto();
				if (length < 0)
					return null;
				u16[] units = new u16[(i32)length];
				loop (i32 i = 0..units.Length)
					units[i] = (u16)ReadUnit(i);
				return Unicode.FromUtf16(units);
			}

			WriteLine()
			{
				PrintLine();
			}

			WriteLine(str text)
			{
				PrintUtf8(text.Units());
				PrintLine();
			}

			WriteLine(i8 value)
			{
				PrintInteger(value);
				PrintLine();
			}

			WriteLine(i16 value)
			{
				PrintInteger(value);
				PrintLine();
			}

			WriteLine(i32 value)
			{
				PrintInteger(value);
				PrintLine();
			}

			WriteLine(i64 value)
			{
				PrintInteger(value);
				PrintLine();
			}

			WriteLine(i128 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(i256 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(u8 value)
			{
				PrintUnsigned(value);
				PrintLine();
			}

			WriteLine(u16 value)
			{
				PrintUnsigned(value);
				PrintLine();
			}

			WriteLine(u32 value)
			{
				PrintUnsigned(value);
				PrintLine();
			}

			WriteLine(u64 value)
			{
				PrintUnsigned(value);
				PrintLine();
			}

			WriteLine(u128 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(u256 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(f16 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(f32 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(f64 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(f128 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(f256 value)
			{
				PrintUtf8(value.ToString().Units());
				PrintLine();
			}

			WriteLine(bool value)
			{
				PrintBool(value);
				PrintLine();
			}

			WriteLine(any value)
			{
				Write(value);
				PrintLine();
			}

			/// The standard output as a TextWriter (it flushes after every write).
			TextWriter Out
			{
				get
				{
					if (output is StreamWriter writer)
						return writer;
					StreamWriter made = new StreamWriter(OpenStandardOutput(), 256);
					made.AutoFlush = true;
					output = made;
					return made;
				}
			}

			/// The standard error as a TextWriter (it flushes after every write).
			TextWriter Error
			{
				get
				{
					if (error is StreamWriter writer)
						return writer;
					StreamWriter made = new StreamWriter(OpenStandardError(), 256);
					made.AutoFlush = true;
					error = made;
					return made;
				}
			}

			/// The standard input as a TextReader.
			TextReader In
			{
				get
				{
					if (input is StreamReader reader)
						return reader;
					StreamReader made = new StreamReader(OpenStandardInput());
					input = made;
					return made;
				}
			}
	}
}
Esc