* Saving work

* Move shit to engine

* lord

* merg

* awa

* bql is kill

* forgot the fucking bike rack

* bql is kill for real

* pjb will kill me

* aughfhbdj

* yo ho here we go on my way to the MINES

* a

* adgddf

* gdsgvfvxshngfgh

* b

* hfsjhghj

* hbfdjjh

* tf you mean i have to document it

* follow C# standards

* Assorted cleanup and documentation pass, minor bugfix in ValueRefParser.

* Start porting old commands, remove that pesky prefix in favor of integrating with the shell.

* Fix valueref up a bit, improve autocomplete for it.

* e

* Toolshed type system adventure.

* a log

* a

* a e i o u

* awa

* fix tests

* Arithmetic commands.

* a

* parse improvements

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
This commit is contained in:
Moony
2023-08-02 16:06:16 -05:00
committed by GitHub
parent a7315b1c95
commit 0e1328675c
125 changed files with 6280 additions and 873 deletions

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Reflection.Emit;
using ILReader;
using ILReader.Readers;
using Robust.Shared.Toolshed;
namespace Robust.Shared.Scripting;
[ToolshedCommand]
public sealed class ILCommand : ToolshedCommand
{
[CommandImplementation("dumpil")]
public void DumpIL(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] MethodInfo info
)
{
var reader = GetReader(info);
foreach (var instruction in reader)
{
if (instruction is null)
break;
ctx.WriteLine(instruction.ToString()!);
}
}
private IILReader GetReader(MethodBase method)
{
IILReaderConfiguration cfg = ILReader.Configuration.Resolve(method);
return cfg.GetReader(method);
}
}

View File

@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILReader.Core" Version="1.0.0.4" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />

View File

@@ -10,7 +10,10 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Utility;
namespace Robust.Shared.Scripting
@@ -19,7 +22,7 @@ namespace Robust.Shared.Scripting
[SuppressMessage("ReSharper", "IdentifierTypo")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "CA1822")]
public abstract class ScriptGlobalsShared
public abstract class ScriptGlobalsShared : IInvocationContext
{
private const BindingFlags DefaultHelpFlags =
BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
@@ -30,6 +33,8 @@ namespace Robust.Shared.Scripting
[field: Dependency] public IMapManager map { get; } = default!;
[field: Dependency] public IDependencyCollection dependencies { get; } = default!;
[field: Dependency] public ToolshedManager shed { get; } = default!;
protected ScriptGlobalsShared(IDependencyCollection dependencies)
{
dependencies.InjectDependencies(this);
@@ -161,6 +166,24 @@ namespace Robust.Shared.Scripting
public abstract void write(object toString);
public abstract void show(object obj);
public object? tsh(string toolshedCommand)
{
shed.InvokeCommand(this, toolshedCommand, null, out var res);
return res;
}
public T tsh<T>(string toolshedCommand)
{
shed.InvokeCommand(this, toolshedCommand, null, out var res);
return (T)res!;
}
public TOut tsh<TIn, TOut>(TIn value, string toolshedCommand)
{
shed.InvokeCommand(this, toolshedCommand, value, out var res);
return (TOut)res!;
}
#region EntityManager proxy methods
public T Comp<T>(EntityUid uid) where T : Component
=> ent.GetComponent<T>(uid);
@@ -227,5 +250,34 @@ namespace Robust.Shared.Scripting
return ent.EntityQuery<TComp1, TComp2, TComp3>(includePaused);
}
#endregion
public bool CheckInvokable(CommandSpec command, out IConError? error)
{
error = null;
return true; // Do as I say!
}
public ICommonSession? Session => null;
public void WriteLine(string line)
{
write(line);
}
public void ReportError(IConError err)
{
write(err);
}
public IEnumerable<IConError> GetErrors()
{
return Array.Empty<IConError>();
}
public void ClearErrors()
{
}
public Dictionary<string, object?> Variables { get; } = new();
}
}