static class · System

Environment

public static class Environment
Kind
static class
Namespace
System
Assembly
System.Core
Access
public, static, abstract
Source file
Runtime.ant

Inheritance

Base classes
Any Environment

Properties

str NewLine { get; }
#

static read-only

i64 TickCount64 { get; }
#

static read-only

Milliseconds from an arbitrary start (it only goes forward).

i32 ProcessorCount { get; }
#

static read-only

How many processors the program can run on.

i32 CurrentManagedThreadId { get; }
#

static read-only

The number of the thread that asks (1: the program's first).

Methods

GetCommandLineArgs() : List<str>
#

static

The program's arguments (not its own name).

GetEnvironmentVariable(str name) : str?
#

static

An environment variable, or null when it is not set.

Private and internal members (8)

extern("args.count") ArgumentCount() : i64
#

private static

extern("args.length") ArgumentLength(i64 index) : i64
#

private static

extern("args.unit") ArgumentUnit(i64 index, i64 at) : i64
#

private static

extern("env.get") VariableInto(u16[] name) : i64
#

private static

extern("env.unit") VariableUnit(i64 index) : i64
#

private static

extern("time.now") Now() : i64
#

private static

extern("cpu.count") Processors() : i64
#

private static

extern("thread.id") ThreadNumber() : i64
#

private static

Inherited members (5)

Source

Environment as Antril, decompiled from its Larva HIR.

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

into namespace System
{
	public static class Environment
	{
		extern("args.count") ArgumentCount() : i64;

		extern("args.length") ArgumentLength(i64 index) : i64;

		extern("args.unit") ArgumentUnit(i64 index, i64 at) : i64;

		extern("env.get") VariableInto(u16[] name) : i64;

		extern("env.unit") VariableUnit(i64 index) : i64;

		extern("time.now") Now() : i64;

		extern("cpu.count") Processors() : i64;

		extern("thread.id") ThreadNumber() : i64;

		public:
			/// The program's arguments (not its own name).
			GetCommandLineArgs() : List<str>
			{
				i64 count = ArgumentCount();
				List<str> arguments = new List<str>((i32)count);
				loop (i64 a = 0..count)
				{
					u16[] units = new u16[(i32)ArgumentLength(a)];
					loop (i32 i = 0..units.Length)
						units[i] = (u16)ArgumentUnit(a, i);
					arguments.Add(Unicode.FromUtf16(units));
				}
				return arguments;
			}

			/// An environment variable, or null when it is not set.
			GetEnvironmentVariable(str name) : str?
			{
				i64 length = VariableInto(Unicode.ToUtf16(name));
				if (length < 0)
					return null;
				u16[] units = new u16[(i32)length];
				loop (i32 i = 0..units.Length)
					units[i] = (u16)VariableUnit(i);
				return Unicode.FromUtf16(units);
			}

			str NewLine
			{
				get => "\n";
			}

			/// Milliseconds from an arbitrary start (it only goes forward).
			i64 TickCount64
			{
				get => Now();
			}

			/// How many processors the program can run on.
			i32 ProcessorCount
			{
				get => (i32)Processors();
			}

			/// The number of the thread that asks (1: the program's first).
			i32 CurrentManagedThreadId
			{
				get => (i32)ThreadNumber();
			}
	}
}
Esc