public DynValue AttachShellToDevice(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); if (!Kernel.Instance.NetworkConnectionStack.TryPeek(out var entity)) { return(new DynValue(SystemReturnCodes.Network.NotLinked)); } if (!(entity is Device device)) { return(new DynValue(SystemReturnCodes.Network.NotADevice)); } if (!Kernel.Instance.CurrentSystemContext.IsLocal && Kernel.Instance.CurrentSystemContext.RemoteDevice == device) { return(new DynValue(SystemReturnCodes.Network.ShellStillOpen)); } if (!device.ShellEnabled) { return(new DynValue(SystemReturnCodes.Network.ShellDisabled)); } Kernel.Instance.AttachShell(device); return(new DynValue(SystemReturnCodes.Success)); }
public DynValue ScanCurrentNeighborhood(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); var tbl = new Table(); var position = Vector2.Zero; if (Kernel.Instance.NetworkConnectionStack.TryPeek(out var entity)) { if (entity is Device dev) { position = dev.GetNetPositionVector(); } else if (entity is Node node) { position = node.Owner.GetNetPositionVector(); } } var devices = UserProfile.Instance.Internet.GetDevicesInRange(position, 10); for (var i = 0; i < devices.Count; i++) { tbl[i] = new DynValue(devices[i].Address.Value.ToString()); } return(new DynValue(tbl)); }
public DynValue Clear(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); Kernel.Instance.Vga.ClearScreen(false); return(DynValue.Zero); }
public DynValue Stamp(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); var stamp = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; return(new DynValue(stamp)); }
public DynValue ResetTextModeForeground(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); Kernel.Instance.Vga.ActiveForegroundColor = Kernel.Instance.Vga.DefaultForegroundColor; return(DynValue.Zero); }
public DynValue LastReturnValue(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); if (!Kernel.Instance.ProcessManager.ReturnValues.TryPeek(out var value)) { return(DynValue.Zero); } return(value); }
public static DynValue Strace(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); var trace = interpreter.Environment.StackTrace(); var tbl = new Table(); for (var i = 0; i < trace.Count; i++) { tbl[i] = new DynValue($"{trace.Count - i - 1}: {trace[i].FunctionName}"); } return(new DynValue(tbl)); }
public DynValue UnbindFromNode(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); if (!Kernel.Instance.NetworkConnectionStack.TryPeek(out var entity)) { return(new DynValue(SystemReturnCodes.Network.NotLinked)); } if (!(entity is Node)) { return(new DynValue(SystemReturnCodes.Network.NotANode)); } Kernel.Instance.UnbindFromNode(); return(new DynValue(SystemReturnCodes.Success)); }
public DynValue DetachShellFromDevice(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); if (!Kernel.Instance.NetworkConnectionStack.TryPeek(out var entity)) { return(new DynValue(SystemReturnCodes.Network.NotLinked)); } if (!(entity is Device)) { return(new DynValue(SystemReturnCodes.Network.NotADevice)); } if (Kernel.Instance.CurrentSystemContext.IsLocal) { return(new DynValue(SystemReturnCodes.Network.ShellNotOpen)); } Kernel.Instance.DetachShell(); return(new DynValue(SystemReturnCodes.Success)); }
public DynValue ProcList(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); var tbl = new Table(); var sb = new StringBuilder(); for (var i = 0; i < Kernel.Instance.ProcessManager.Processes.Values.Count; i++) { var proc = Kernel.Instance.ProcessManager.Processes.Values.ElementAt(i); sb.Append("["); sb.Append(proc.Pid); sb.Append("] "); sb.Append(proc.FilePath); sb.Append(" "); sb.Append(proc.CommandLine); tbl[i] = new DynValue(sb.ToString()); sb.Clear(); } return(new DynValue(tbl)); }
public DynValue GetHostName(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); return(new DynValue(Kernel.Instance.GetHostName())); }
public DynValue Pid(Interpreter interpreter, ClrFunctionArguments args) { args.ExpectNone(); return(new DynValue(Kernel.Instance.ProcessManager.GetPid(interpreter))); }