using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using GDWeave;
using GDWeave.Godot;
using GDWeave.Godot.Variants;
using GDWeave.Modding;
using Seent.util.LexicalTransformer;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("Seent")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+f174f365624eea7179e97ec395ee51f7f83cc854")]
[assembly: AssemblyProduct("Seent")]
[assembly: AssemblyTitle("Seent")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Seent
{
public class Config
{
}
public class Mod : IMod, global::System.IDisposable
{
public Config Config;
public Mod(IModInterface mi)
{
Config = mi.ReadConfig<Config>();
mi.RegisterScriptMod((IScriptMod)(object)new TransformationRuleScriptModBuilder().ForMod(mi).Named("Seent").Patching("res://Scenes/Entities/Player/player_label.gdc")
.AddRule(new TransformationRuleBuilder().Named("Var declare").Do(Operation.Append).Matching(TransformationPatternFactory.CreateGdSnippetPattern("var player_id = - 1"))
.With("\r\nonready var Seent = get_node(\"/root/ToesSeent\")\r\n")
.When(eligible: true))
.AddRule(new TransformationRuleBuilder().Named("Rename name label").Do(Operation.Append).Matching(TransformationPatternFactory.CreateGdSnippetPattern("_name = _name.replace(\"]\", \"\")\n"))
.With("\n_name = (Seent.get_times_seen_badge(str(player_id)) + _name)\n$VBoxContainer/Label.fit_content_height = true\n", 1u)
.When(eligible: true))
.Build());
}
public void Dispose()
{
}
}
}
namespace Seent.util
{
public static class ScriptTokenizer
{
[StructLayout(3)]
[CompilerGenerated]
private struct <>c__DisplayClass6_0
{
public string previous;
public global::System.Collections.Generic.IEnumerator<string> enumerator;
public List<Token> finalTokens;
public List<Token> toFlush;
public string idName;
}
[StructLayout(3)]
[CompilerGenerated]
private struct <>c__DisplayClass8_0
{
public StringBuilder builder;
}
[CompilerGenerated]
private sealed class <SanitizeInput>d__7 : global::System.Collections.Generic.IEnumerable<string>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<string>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private string <>2__current;
private int <>l__initialThreadId;
private global::System.Collections.Generic.IEnumerable<string> tokens;
public global::System.Collections.Generic.IEnumerable<string> <>3__tokens;
private global::System.Collections.Generic.IEnumerator<string> <>7__wrap1;
string global::System.Collections.Generic.IEnumerator<string>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SanitizeInput>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
}
private bool MoveNext()
{
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>7__wrap1 = tokens.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
}
while (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext())
{
string current = <>7__wrap1.Current;
if (!(current != "\n") || !string.IsNullOrWhiteSpace(current))
{
<>2__current = current;
<>1__state = 1;
return true;
}
}
<>m__Finally1();
<>7__wrap1 = null;
return false;
}
catch
{
//try-fault
((global::System.IDisposable)this).Dispose();
throw;
}
}
bool global::System.Collections.IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap1 != null)
{
((global::System.IDisposable)<>7__wrap1).Dispose();
}
}
[DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
[DebuggerHidden]
global::System.Collections.Generic.IEnumerator<string> global::System.Collections.Generic.IEnumerable<string>.GetEnumerator()
{
<SanitizeInput>d__7 <SanitizeInput>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<SanitizeInput>d__ = this;
}
else
{
<SanitizeInput>d__ = new <SanitizeInput>d__7(0);
}
<SanitizeInput>d__.tokens = <>3__tokens;
return <SanitizeInput>d__;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<string>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <Tokenize>d__6 : global::System.Collections.Generic.IEnumerable<Token>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<Token>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private Token <>2__current;
private int <>l__initialThreadId;
private string gdScript;
public string <>3__gdScript;
private uint baseIndent;
public uint <>3__baseIndent;
private Enumerator<Token> <>7__wrap1;
Token global::System.Collections.Generic.IEnumerator<Token>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Tokenize>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
}
private bool MoveNext()
{
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Expected O, but got Unknown
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Expected O, but got Unknown
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Expected O, but got Unknown
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Expected O, but got Unknown
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
<>c__DisplayClass6_0 <>c__DisplayClass6_ = default(<>c__DisplayClass6_0);
<>c__DisplayClass6_.finalTokens = new List<Token>();
global::System.Collections.Generic.IEnumerable<string> enumerable = SanitizeInput(TokenizeString(gdScript + " "));
<>c__DisplayClass6_.previous = string.Empty;
<>c__DisplayClass6_.idName = string.Empty;
<>c__DisplayClass6_.toFlush = new List<Token>(2);
<>c__DisplayClass6_.enumerator = enumerable.GetEnumerator();
bool flag = false;
TokenType val = default(TokenType);
bool flag2 = default(bool);
while (flag || ((global::System.Collections.IEnumerator)<>c__DisplayClass6_.enumerator).MoveNext())
{
flag = false;
if (<>c__DisplayClass6_.enumerator.Current == "\n")
{
InsertNewLine(<>c__DisplayClass6_.enumerator, baseIndent, <>c__DisplayClass6_.toFlush);
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else if (<>c__DisplayClass6_.enumerator.Current == "_")
{
BuildIdentifierName(<>c__DisplayClass6_.enumerator, <>c__DisplayClass6_.toFlush, out string found);
if (found == string.Empty)
{
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
continue;
}
<>c__DisplayClass6_.idName += found;
<Tokenize>g__end|6_0(ref <>c__DisplayClass6_);
}
else if (char.IsDigit(<>c__DisplayClass6_.enumerator.Current[0]))
{
BuildNumber(<>c__DisplayClass6_.enumerator, <>c__DisplayClass6_.toFlush, out var foundFull);
flag = !foundFull;
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else if (BuiltinFunctions.Contains(<>c__DisplayClass6_.enumerator.Current))
{
<>c__DisplayClass6_.toFlush.Add(new Token((TokenType)5, (uint?)(uint)BuiltinFunctions.IndexOf(<>c__DisplayClass6_.enumerator.Current)));
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else if (Tokens.TryGetValue(<>c__DisplayClass6_.enumerator.Current, ref val))
{
<>c__DisplayClass6_.toFlush.Add(new Token(val, (uint?)null));
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else if (<>c__DisplayClass6_.enumerator.Current.StartsWith('"'))
{
string current = <>c__DisplayClass6_.enumerator.Current;
<>c__DisplayClass6_.toFlush.Add((Token)new ConstantToken((Variant)new StringVariant(current.Substring(1, current.Length - 2))));
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else if (bool.TryParse(<>c__DisplayClass6_.enumerator.Current, ref flag2))
{
<>c__DisplayClass6_.toFlush.Add((Token)new ConstantToken((Variant)new BoolVariant(flag2)));
<Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_);
}
else
{
<>c__DisplayClass6_.idName += <>c__DisplayClass6_.enumerator.Current;
<Tokenize>g__end|6_0(ref <>c__DisplayClass6_);
}
}
<>7__wrap1 = <>c__DisplayClass6_.finalTokens.GetEnumerator();
<>1__state = -3;
break;
}
case 1:
<>1__state = -3;
break;
}
if (<>7__wrap1.MoveNext())
{
Token current2 = <>7__wrap1.Current;
<>2__current = current2;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap1 = default(Enumerator<Token>);
return false;
}
catch
{
//try-fault
((global::System.IDisposable)this).Dispose();
throw;
}
}
bool global::System.Collections.IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((global::System.IDisposable)<>7__wrap1).Dispose();
}
[DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
[DebuggerHidden]
global::System.Collections.Generic.IEnumerator<Token> global::System.Collections.Generic.IEnumerable<Token>.GetEnumerator()
{
<Tokenize>d__6 <Tokenize>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Tokenize>d__ = this;
}
else
{
<Tokenize>d__ = new <Tokenize>d__6(0);
}
<Tokenize>d__.gdScript = <>3__gdScript;
<Tokenize>d__.baseIndent = <>3__baseIndent;
return <Tokenize>d__;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<Token>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <TokenizeString>d__8 : global::System.Collections.Generic.IEnumerable<string>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<string>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private string <>2__current;
private int <>l__initialThreadId;
private string text;
public string <>3__text;
private <>c__DisplayClass8_0 <>8__1;
private int <i>5__2;
private int <start>5__3;
private Enumerator<string> <>7__wrap3;
private string <delimiter>5__5;
string global::System.Collections.Generic.IEnumerator<string>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TokenizeString>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 6) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
}
private bool MoveNext()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
try
{
bool flag;
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1.builder = new StringBuilder(20);
<i>5__2 = 0;
goto IL_0397;
case 1:
<>1__state = -1;
<>8__1.builder.Append('"');
<i>5__2++;
while (<i>5__2 < text.Length)
{
<>8__1.builder.Append(text[<i>5__2]);
if (text[<i>5__2] == '"')
{
break;
}
<i>5__2++;
}
<>2__current = <TokenizeString>g__ClearBuilder|8_0(ref <>8__1);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
goto IL_0385;
case 3:
<>1__state = -1;
<start>5__3 = <i>5__2;
<i>5__2++;
while (<i>5__2 < text.Length && text[<i>5__2] == '\t')
{
<i>5__2++;
}
<i>5__2--;
<>2__current = "\n";
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = $"{<i>5__2 - <start>5__3}";
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
goto IL_0385;
case 6:
<>1__state = -3;
<>2__current = <delimiter>5__5;
<>1__state = 7;
return true;
case 7:
<>1__state = -3;
<i>5__2 += <delimiter>5__5.Length - 1;
flag = true;
goto IL_0314;
case 8:
<>1__state = -1;
goto IL_0385;
case 9:
{
<>1__state = -1;
return false;
}
IL_0397:
if (<i>5__2 < text.Length)
{
switch (text[<i>5__2])
{
case '"':
<>2__current = <TokenizeString>g__ClearBuilder|8_0(ref <>8__1);
<>1__state = 1;
return true;
case '\n':
<>2__current = <TokenizeString>g__ClearBuilder|8_0(ref <>8__1);
<>1__state = 3;
return true;
}
flag = false;
<>7__wrap3 = Symbols.GetEnumerator();
<>1__state = -3;
while (<>7__wrap3.MoveNext())
{
<delimiter>5__5 = <>7__wrap3.Current;
if (Match(text, <i>5__2, <delimiter>5__5))
{
<>2__current = <TokenizeString>g__ClearBuilder|8_0(ref <>8__1);
<>1__state = 6;
return true;
}
<delimiter>5__5 = null;
}
goto IL_0314;
}
<>2__current = "\n";
<>1__state = 9;
return true;
IL_0385:
<i>5__2++;
goto IL_0397;
IL_0314:
<>m__Finally1();
<>7__wrap3 = default(Enumerator<string>);
if (!flag)
{
if (text[<i>5__2] == ' ')
{
<>2__current = <TokenizeString>g__ClearBuilder|8_0(ref <>8__1);
<>1__state = 8;
return true;
}
<>8__1.builder.Append(text[<i>5__2]);
}
goto IL_0385;
}
}
catch
{
//try-fault
((global::System.IDisposable)this).Dispose();
throw;
}
}
bool global::System.Collections.IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((global::System.IDisposable)<>7__wrap3).Dispose();
}
[DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
[DebuggerHidden]
global::System.Collections.Generic.IEnumerator<string> global::System.Collections.Generic.IEnumerable<string>.GetEnumerator()
{
<TokenizeString>d__8 <TokenizeString>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<TokenizeString>d__ = this;
}
else
{
<TokenizeString>d__ = new <TokenizeString>d__8(0);
}
<TokenizeString>d__.text = <>3__text;
return <TokenizeString>d__;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<string>)this).GetEnumerator();
}
}
private static readonly Dictionary<string, TokenType> Tokens;
private static readonly HashSet<string> Symbols;
private static readonly List<string> BuiltinFunctions;
private static void InsertNewLine(global::System.Collections.Generic.IEnumerator<string> enumerator, uint baseIndent, List<Token> toFlush)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
if (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
uint num = uint.Parse(enumerator.Current);
toFlush.Add(new Token((TokenType)89, (uint?)(num + baseIndent)));
}
}
private static void BuildIdentifierName(global::System.Collections.Generic.IEnumerator<string> enumerator, List<Token> toFlush, out string? found)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
found = string.Empty;
if (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
if (enumerator.Current == ":")
{
toFlush.Add(new Token((TokenType)92, (uint?)null));
toFlush.Add(new Token((TokenType)83, (uint?)null));
}
else
{
found = "_" + enumerator.Current;
}
}
}
private static void BuildNumber(global::System.Collections.Generic.IEnumerator<string> enumerator, List<Token> toFlush, out bool foundFull)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
foundFull = true;
int num = 1;
if (enumerator.Current == "-")
{
num = -1;
if (!((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
return;
}
}
long num2 = default(long);
if (!long.TryParse(enumerator.Current, ref num2))
{
toFlush.Add(new Token((TokenType)17, (uint?)null));
foundFull = false;
}
else if (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
long num3 = default(long);
if (enumerator.Current != ".")
{
toFlush.Add((Token)new ConstantToken((Variant)new IntVariant(num2 * num, false)));
foundFull = false;
}
else if (((global::System.Collections.IEnumerator)enumerator).MoveNext() && long.TryParse(enumerator.Current, ref num3))
{
double num4 = (double)num2 + (double)num3 / Math.Pow(10.0, (double)num3.ToString().Length);
toFlush.Add((Token)new ConstantToken((Variant)new RealVariant(num4 * (double)num, false)));
}
}
}
[IteratorStateMachine(typeof(<Tokenize>d__6))]
public static global::System.Collections.Generic.IEnumerable<Token> Tokenize(string gdScript, uint baseIndent = 0u)
{
List<Token> finalTokens = new List<Token>();
global::System.Collections.Generic.IEnumerable<string> enumerable = SanitizeInput(TokenizeString(gdScript + " "));
string previous = string.Empty;
string idName = string.Empty;
List<Token> toFlush = new List<Token>(2);
global::System.Collections.Generic.IEnumerator<string> enumerator = enumerable.GetEnumerator();
bool flag = false;
TokenType val = default(TokenType);
bool flag2 = default(bool);
while (flag || ((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
flag = false;
if (enumerator.Current == "\n")
{
InsertNewLine(enumerator, baseIndent, toFlush);
endAndFlushId();
}
else if (enumerator.Current == "_")
{
BuildIdentifierName(enumerator, toFlush, out string found);
if (found == string.Empty)
{
endAndFlushId();
continue;
}
idName += found;
end();
}
else if (char.IsDigit(enumerator.Current[0]))
{
BuildNumber(enumerator, toFlush, out var foundFull);
flag = !foundFull;
endAndFlushId();
}
else if (BuiltinFunctions.Contains(enumerator.Current))
{
toFlush.Add(new Token((TokenType)5, (uint?)(uint)BuiltinFunctions.IndexOf(enumerator.Current)));
endAndFlushId();
}
else if (Tokens.TryGetValue(enumerator.Current, ref val))
{
toFlush.Add(new Token(val, (uint?)null));
endAndFlushId();
}
else if (enumerator.Current.StartsWith('"'))
{
string current = enumerator.Current;
toFlush.Add((Token)new ConstantToken((Variant)new StringVariant(current.Substring(1, current.Length - 2))));
endAndFlushId();
}
else if (bool.TryParse(enumerator.Current, ref flag2))
{
toFlush.Add((Token)new ConstantToken((Variant)new BoolVariant(flag2)));
endAndFlushId();
}
else
{
idName += enumerator.Current;
end();
}
}
Enumerator<Token> enumerator2 = finalTokens.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
yield return enumerator2.Current;
}
}
finally
{
((global::System.IDisposable)enumerator2).Dispose();
}
[CompilerGenerated]
void end()
{
previous = enumerator.Current;
finalTokens.AddRange((global::System.Collections.Generic.IEnumerable<Token>)toFlush);
toFlush.Clear();
}
[CompilerGenerated]
void endAndFlushId()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Expected O, but got Unknown
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Expected O, but got Unknown
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Expected O, but got Unknown
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Expected O, but got Unknown
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Expected O, but got Unknown
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Expected O, but got Unknown
string text;
char c;
if (idName != string.Empty)
{
if (idName.Trim() == "return")
{
finalTokens.Add(new Token((TokenType)46, (uint?)null));
}
else if (idName.Trim() == "self")
{
finalTokens.Add(new Token((TokenType)3, (uint?)null));
}
else
{
text = idName.Trim();
if (text == null)
{
goto IL_0301;
}
switch (text.Length)
{
case 5:
break;
case 3:
goto IL_00f3;
case 4:
goto IL_016c;
case 7:
goto IL_0181;
case 10:
goto IL_0196;
default:
goto IL_0301;
}
c = text[0];
if ((uint)c <= 98u)
{
if (c != 'C')
{
if (c != 'b' || !(text == "break"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)43, (uint?)null));
}
else
{
if (!(text == "Color"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)4, (uint?)14u));
}
}
else if (c != 'm')
{
if (c != 'p' || !(text == "print"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)5, (uint?)63u));
}
else
{
if (!(text == "match"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)47, (uint?)null));
}
}
goto IL_031c;
}
goto IL_0327;
IL_0301:
finalTokens.Add((Token)new IdentifierToken(idName.Trim()));
goto IL_031c;
IL_0181:
if (!(text == "Vector3"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)4, (uint?)7u));
goto IL_031c;
IL_031c:
idName = string.Empty;
goto IL_0327;
IL_00f3:
c = text[0];
if (c != 'a')
{
if (c != 'i')
{
if (c != 'p' || !(text == "pow"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)5, (uint?)19u));
}
else
{
if (!(text == "int"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)4, (uint?)2u));
}
}
else
{
if (!(text == "abs"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)5, (uint?)17u));
}
goto IL_031c;
IL_016c:
if (!(text == "null"))
{
goto IL_0301;
}
finalTokens.Add((Token)new ConstantToken((Variant)new NilVariant()));
goto IL_031c;
IL_0327:
end();
return;
IL_0196:
if (!(text == "lerp_angle"))
{
goto IL_0301;
}
finalTokens.Add(new Token((TokenType)5, (uint?)31u));
goto IL_031c;
}
}
[IteratorStateMachine(typeof(<SanitizeInput>d__7))]
private static global::System.Collections.Generic.IEnumerable<string> SanitizeInput(global::System.Collections.Generic.IEnumerable<string> tokens)
{
global::System.Collections.Generic.IEnumerator<string> enumerator = tokens.GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
string current = enumerator.Current;
if (!(current != "\n") || !string.IsNullOrWhiteSpace(current))
{
yield return current;
}
}
}
finally
{
((global::System.IDisposable)enumerator)?.Dispose();
}
}
[IteratorStateMachine(typeof(<TokenizeString>d__8))]
private static global::System.Collections.Generic.IEnumerable<string> TokenizeString(string text)
{
StringBuilder builder = new StringBuilder(20);
for (int j = 0; j < text.Length; j++)
{
switch (text[j])
{
case '"':
yield return ClearBuilder();
builder.Append('"');
for (j++; j < text.Length; j++)
{
builder.Append(text[j]);
if (text[j] == '"')
{
break;
}
}
yield return ClearBuilder();
continue;
case '\n':
{
yield return ClearBuilder();
int start = j;
for (j++; j < text.Length && text[j] == '\t'; j++)
{
}
j--;
yield return "\n";
yield return $"{j - start}";
continue;
}
}
bool flag = false;
Enumerator<string> enumerator = Symbols.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
string delimiter = enumerator.Current;
if (Match(text, j, delimiter))
{
yield return ClearBuilder();
yield return delimiter;
j += delimiter.Length - 1;
flag = true;
break;
}
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
if (!flag)
{
if (text[j] == ' ')
{
yield return ClearBuilder();
}
else
{
builder.Append(text[j]);
}
}
}
yield return "\n";
[CompilerGenerated]
string ClearBuilder()
{
string result = ((object)builder).ToString();
builder.Clear();
return result;
}
}
private static bool Match(string text, int index, string match)
{
if (index + match.Length > text.Length)
{
return false;
}
for (int i = 0; i < match.Length; i++)
{
if (text[index + i] != match[i])
{
return false;
}
}
return true;
}
static ScriptTokenizer()
{
Dictionary<string, TokenType> obj = new Dictionary<string, TokenType>();
obj.Add("continue", (TokenType)44);
obj.Add("return", (TokenType)46);
obj.Add("break", (TokenType)43);
obj.Add("match", (TokenType)47);
obj.Add("while", (TokenType)42);
obj.Add("elif", (TokenType)39);
obj.Add("else", (TokenType)40);
obj.Add("pass", (TokenType)45);
obj.Add("for", (TokenType)41);
obj.Add("if", (TokenType)38);
obj.Add("const", (TokenType)58);
obj.Add("var", (TokenType)59);
obj.Add("func", (TokenType)48);
obj.Add("class", (TokenType)49);
obj.Add("extends", (TokenType)51);
obj.Add("is", (TokenType)52);
obj.Add("as", (TokenType)60);
obj.Add("onready", (TokenType)53);
obj.Add("@tool", (TokenType)54);
obj.Add("@export", (TokenType)56);
obj.Add("yield", (TokenType)65);
obj.Add("setget", (TokenType)57);
obj.Add("static", (TokenType)55);
obj.Add("void", (TokenType)61);
obj.Add("enum", (TokenType)62);
obj.Add("preload", (TokenType)63);
obj.Add("assert", (TokenType)64);
obj.Add("signal", (TokenType)66);
obj.Add("breakpoint", (TokenType)67);
obj.Add("sync", (TokenType)69);
obj.Add("remote", (TokenType)68);
obj.Add("master", (TokenType)70);
obj.Add("slave", (TokenType)71);
obj.Add("puppet", (TokenType)72);
obj.Add("remotesync", (TokenType)73);
obj.Add("mastersync", (TokenType)74);
obj.Add("puppetsync", (TokenType)75);
obj.Add("\n", (TokenType)89);
obj.Add("PI", (TokenType)90);
obj.Add("TAU", (TokenType)91);
obj.Add("INF", (TokenType)93);
obj.Add("NAN", (TokenType)94);
obj.Add("error", (TokenType)95);
obj.Add("cursor", (TokenType)97);
obj.Add("self", (TokenType)3);
obj.Add("in", (TokenType)6);
obj.Add("_", (TokenType)92);
obj.Add("[", (TokenType)76);
obj.Add("]", (TokenType)77);
obj.Add("{", (TokenType)78);
obj.Add("}", (TokenType)79);
obj.Add("(", (TokenType)80);
obj.Add(")", (TokenType)81);
obj.Add(",", (TokenType)82);
obj.Add(";", (TokenType)83);
obj.Add(".", (TokenType)84);
obj.Add("?", (TokenType)85);
obj.Add(":", (TokenType)86);
obj.Add("$", (TokenType)87);
obj.Add("->", (TokenType)88);
obj.Add(">>=", (TokenType)30);
obj.Add("<<=", (TokenType)29);
obj.Add(">>", (TokenType)22);
obj.Add("<<", (TokenType)21);
obj.Add("==", (TokenType)7);
obj.Add("!=", (TokenType)8);
obj.Add("&&", (TokenType)13);
obj.Add("||", (TokenType)14);
obj.Add("!", (TokenType)15);
obj.Add("+=", (TokenType)24);
obj.Add("-=", (TokenType)25);
obj.Add("*=", (TokenType)26);
obj.Add("/=", (TokenType)27);
obj.Add("%=", (TokenType)28);
obj.Add("&=", (TokenType)31);
obj.Add("|=", (TokenType)32);
obj.Add("^=", (TokenType)33);
obj.Add("+", (TokenType)16);
obj.Add("-", (TokenType)17);
obj.Add("*", (TokenType)18);
obj.Add("/", (TokenType)19);
obj.Add("%", (TokenType)20);
obj.Add("~", (TokenType)37);
obj.Add("&", (TokenType)34);
obj.Add("|", (TokenType)35);
obj.Add("^", (TokenType)36);
obj.Add("<=", (TokenType)10);
obj.Add(">=", (TokenType)12);
obj.Add("<", (TokenType)9);
obj.Add(">", (TokenType)11);
obj.Add("=", (TokenType)23);
Tokens = obj;
HashSet<string> obj2 = new HashSet<string>();
obj2.Add("->");
obj2.Add(">>=");
obj2.Add("<<=");
obj2.Add(">>");
obj2.Add("<<");
obj2.Add("==");
obj2.Add("!=");
obj2.Add("&&");
obj2.Add("||");
obj2.Add("!");
obj2.Add("+=");
obj2.Add("-=");
obj2.Add("*=");
obj2.Add("/=");
obj2.Add("%=");
obj2.Add("&=");
obj2.Add("|=");
obj2.Add("^=");
obj2.Add("_");
obj2.Add("[");
obj2.Add("]");
obj2.Add("{");
obj2.Add("}");
obj2.Add("(");
obj2.Add(")");
obj2.Add(",");
obj2.Add(";");
obj2.Add(".");
obj2.Add("?");
obj2.Add(":");
obj2.Add("$");
obj2.Add("+");
obj2.Add("-");
obj2.Add("*");
obj2.Add("/");
obj2.Add("%");
obj2.Add("~");
obj2.Add("&");
obj2.Add("|");
obj2.Add("^");
obj2.Add("<=");
obj2.Add(">=");
obj2.Add("<");
obj2.Add(">");
obj2.Add("=");
Symbols = obj2;
BuiltinFunctions = Enumerable.ToList<string>((global::System.Collections.Generic.IEnumerable<string>)global::System.Enum.GetNames<BuiltinFunction>());
}
[CompilerGenerated]
internal static void <Tokenize>g__end|6_0(ref <>c__DisplayClass6_0 P_0)
{
P_0.previous = P_0.enumerator.Current;
P_0.finalTokens.AddRange((global::System.Collections.Generic.IEnumerable<Token>)P_0.toFlush);
P_0.toFlush.Clear();
}
[CompilerGenerated]
internal static void <Tokenize>g__endAndFlushId|6_1(ref <>c__DisplayClass6_0 P_0)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Expected O, but got Unknown
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Expected O, but got Unknown
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Expected O, but got Unknown
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Expected O, but got Unknown
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Expected O, but got Unknown
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Expected O, but got Unknown
string text;
char c;
if (P_0.idName != string.Empty)
{
if (P_0.idName.Trim() == "return")
{
P_0.finalTokens.Add(new Token((TokenType)46, (uint?)null));
}
else if (P_0.idName.Trim() == "self")
{
P_0.finalTokens.Add(new Token((TokenType)3, (uint?)null));
}
else
{
text = P_0.idName.Trim();
if (text == null)
{
goto IL_0301;
}
switch (text.Length)
{
case 5:
break;
case 3:
goto IL_00f3;
case 4:
goto IL_016c;
case 7:
goto IL_0181;
case 10:
goto IL_0196;
default:
goto IL_0301;
}
c = text[0];
if ((uint)c <= 98u)
{
if (c != 'C')
{
if (c != 'b' || !(text == "break"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)43, (uint?)null));
}
else
{
if (!(text == "Color"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)4, (uint?)14u));
}
}
else if (c != 'm')
{
if (c != 'p' || !(text == "print"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)5, (uint?)63u));
}
else
{
if (!(text == "match"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)47, (uint?)null));
}
}
goto IL_031c;
}
goto IL_0327;
IL_0301:
P_0.finalTokens.Add((Token)new IdentifierToken(P_0.idName.Trim()));
goto IL_031c;
IL_0181:
if (!(text == "Vector3"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)4, (uint?)7u));
goto IL_031c;
IL_031c:
P_0.idName = string.Empty;
goto IL_0327;
IL_00f3:
c = text[0];
if (c != 'a')
{
if (c != 'i')
{
if (c != 'p' || !(text == "pow"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)5, (uint?)19u));
}
else
{
if (!(text == "int"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)4, (uint?)2u));
}
}
else
{
if (!(text == "abs"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)5, (uint?)17u));
}
goto IL_031c;
IL_016c:
if (!(text == "null"))
{
goto IL_0301;
}
P_0.finalTokens.Add((Token)new ConstantToken((Variant)new NilVariant()));
goto IL_031c;
IL_0327:
<Tokenize>g__end|6_0(ref P_0);
return;
IL_0196:
if (!(text == "lerp_angle"))
{
goto IL_0301;
}
P_0.finalTokens.Add(new Token((TokenType)5, (uint?)31u));
goto IL_031c;
}
[CompilerGenerated]
internal static string <TokenizeString>g__ClearBuilder|8_0(ref <>c__DisplayClass8_0 P_0)
{
string result = ((object)P_0.builder).ToString();
P_0.builder.Clear();
return result;
}
}
}
namespace Seent.util.LexicalTransformer
{
public static class TransformationPatternFactory
{
public static Func<Token, bool>[] CreateGlobalsPattern()
{
return new Func<Token, bool>[3]
{
(Token t) => (int)t.Type == 51,
(Token t) => (int)t.Type == 1,
(Token t) => (int)t.Type == 89
};
}
public static Func<Token, bool>[] CreateFunctionDefinitionPattern(string name, string[]? args = null)
{
string name2 = name;
List<Func<Token, bool>> val = new List<Func<Token, bool>>();
val.Add((Func<Token, bool>)((Token t) => (int)t.Type == 48));
val.Add((Func<Token, bool>)delegate(Token t)
{
IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
return val3 != null && val3.Name == name2;
});
val.Add((Func<Token, bool>)((Token t) => (int)t.Type == 80));
if (args != null && args.Length > 0)
{
foreach (string arg in args)
{
val.Add((Func<Token, bool>)delegate(Token t)
{
IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
return val2 != null && val2.Name == arg;
});
val.Add((Func<Token, bool>)((Token t) => (int)t.Type == 82));
}
val.RemoveAt(val.Count - 1);
}
val.Add((Func<Token, bool>)((Token t) => (int)t.Type == 81));
val.Add((Func<Token, bool>)((Token t) => (int)t.Type == 86));
return val.ToArray();
}
public static Func<Token, bool>[] CreateGdSnippetPattern(string snippet, uint indent = 0u)
{
return Enumerable.ToArray<Func<Token, bool>>(Enumerable.Select<Token, Func<Token, bool>>(ScriptTokenizer.Tokenize(snippet, indent), (Func<Token, Func<Token, bool>>)((Token snippetToken) => delegate(Token t)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if ((int)t.Type == 1)
{
Token obj = snippetToken;
IdentifierToken val = (IdentifierToken)(object)((obj is IdentifierToken) ? obj : null);
if (val != null)
{
IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
if (val2 != null)
{
return val.Name == val2.Name;
}
}
return false;
}
if ((int)t.Type == 2)
{
Token obj2 = snippetToken;
ConstantToken val3 = (ConstantToken)(object)((obj2 is ConstantToken) ? obj2 : null);
if (val3 != null)
{
ConstantToken val4 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
if (val4 != null)
{
return val3.Value.Equals(val4.Value);
}
}
return false;
}
return t.Type == snippetToken.Type;
})));
}
}
public enum Operation
{
None,
ReplaceAll,
ReplaceLast,
Append,
Prepend
}
public static class OperationExtensions
{
public static bool RequiresBuffer(this Operation operation)
{
if (operation == Operation.ReplaceAll || operation == Operation.Prepend)
{
return true;
}
return false;
}
public static bool YieldTokenBeforeOperation(this Operation operation)
{
if (operation == Operation.None || operation == Operation.Append)
{
return true;
}
return false;
}
public static bool YieldTokenAfterOperation(this Operation operation)
{
if (!operation.RequiresBuffer() && !operation.YieldTokenBeforeOperation())
{
return operation != Operation.ReplaceLast;
}
return false;
}
}
public record TransformationRule(string Name, Func<Token, bool>[] Pattern, Func<Token, bool>[] ScopePattern, global::System.Collections.Generic.IEnumerable<Token> Tokens, Operation Operation, uint Times, Func<bool> Predicate)
{
[CompilerGenerated]
protected virtual global::System.Type EqualityContract
{
[CompilerGenerated]
get
{
return typeof(TransformationRule);
}
}
public MultiTokenWaiter CreateMultiTokenWaiter()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
return new MultiTokenWaiter(Pattern, false, false);
}
public MultiTokenWaiter CreateMultiTokenWaiterForScope()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
return new MultiTokenWaiter(ScopePattern, false, false);
}
[CompilerGenerated]
public override string ToString()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
StringBuilder val = new StringBuilder();
val.Append("TransformationRule");
val.Append(" { ");
if (PrintMembers(val))
{
val.Append(' ');
}
val.Append('}');
return ((object)val).ToString();
}
[CompilerGenerated]
protected virtual bool PrintMembers(StringBuilder builder)
{
RuntimeHelpers.EnsureSufficientExecutionStack();
builder.Append("Name = ");
builder.Append((object)Name);
builder.Append(", Pattern = ");
builder.Append((object)Pattern);
builder.Append(", ScopePattern = ");
builder.Append((object)ScopePattern);
builder.Append(", Tokens = ");
builder.Append((object)Tokens);
builder.Append(", Operation = ");
builder.Append(((object)Operation).ToString());
builder.Append(", Times = ");
builder.Append(((object)Times).ToString());
builder.Append(", Predicate = ");
builder.Append((object)Predicate);
return true;
}
[CompilerGenerated]
public virtual bool Equals(TransformationRule? other)
{
if ((object)this != other)
{
if ((object)other != null && EqualityContract == other.EqualityContract && EqualityComparer<string>.Default.Equals(Name, other.Name) && EqualityComparer<Func<Token, bool>[]>.Default.Equals(Pattern, other.Pattern) && EqualityComparer<Func<Token, bool>[]>.Default.Equals(ScopePattern, other.ScopePattern) && EqualityComparer<global::System.Collections.Generic.IEnumerable<Token>>.Default.Equals(Tokens, other.Tokens) && EqualityComparer<Operation>.Default.Equals(Operation, other.Operation) && EqualityComparer<uint>.Default.Equals(Times, other.Times))
{
return EqualityComparer<Func<bool>>.Default.Equals(Predicate, other.Predicate);
}
return false;
}
return true;
}
}
public class TransformationRuleBuilder
{
private string? _name;
private Func<Token, bool>[]? _pattern;
private Func<Token, bool>[] _scopePattern = global::System.Array.Empty<Func<Token, bool>>();
private global::System.Collections.Generic.IEnumerable<Token>? _tokens;
private uint _times = 1u;
private Operation _operation = Operation.Append;
private Func<bool> _predicate = () => true;
public TransformationRuleBuilder Named(string name)
{
_name = name;
return this;
}
public TransformationRuleBuilder Matching(Func<Token, bool>[] pattern)
{
_pattern = pattern;
return this;
}
public TransformationRuleBuilder With(global::System.Collections.Generic.IEnumerable<Token> tokens)
{
_tokens = tokens;
return this;
}
public TransformationRuleBuilder With(Token token)
{
_tokens = new <>z__ReadOnlySingleElementList<Token>(token);
return this;
}
public TransformationRuleBuilder With(string snippet, uint indent = 0u)
{
_tokens = ScriptTokenizer.Tokenize(snippet, indent);
return this;
}
public TransformationRuleBuilder Do(Operation operation)
{
_operation = operation;
return this;
}
public TransformationRuleBuilder ExpectTimes(uint times)
{
_times = times;
return this;
}
public TransformationRuleBuilder ScopedTo(Func<Token, bool>[] scopePattern)
{
_scopePattern = scopePattern;
return this;
}
public TransformationRuleBuilder When(Func<bool> predicate)
{
_predicate = predicate;
return this;
}
public TransformationRuleBuilder When(bool eligible)
{
_predicate = () => eligible;
return this;
}
public TransformationRule Build()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(_name))
{
throw new ArgumentNullException("_name", "Name cannot be null or empty");
}
if (_pattern == null)
{
throw new ArgumentNullException("_pattern", "Pattern cannot be null");
}
if (_tokens == null)
{
throw new ArgumentNullException("_tokens", "Tokens cannot be null");
}
return new TransformationRule(_name, _pattern, _scopePattern, _tokens, _operation, _times, _predicate);
}
}
public class TransformationRuleScriptMod : IScriptMod
{
[CompilerGenerated]
private IModInterface <mod>P;
[CompilerGenerated]
private string <name>P;
[CompilerGenerated]
private string <scriptPath>P;
[CompilerGenerated]
private Func<bool> <predicate>P;
[CompilerGenerated]
private TransformationRule[] <rules>P;
public TransformationRuleScriptMod(IModInterface mod, string name, string scriptPath, Func<bool> predicate, TransformationRule[] rules)
{
<mod>P = mod;
<name>P = name;
<scriptPath>P = scriptPath;
<predicate>P = predicate;
<rules>P = rules;
base..ctor();
}
public bool ShouldRun(string path)
{
if (path != <scriptPath>P)
{
return false;
}
if (!<predicate>P.Invoke())
{
<mod>P.Logger.Warning(string.Concat(Enumerable.Repeat<string>("!", 15)));
<mod>P.Logger.Warning("[" + <name>P + "] Predicate failed!!!!!!, not patching.");
<mod>P.Logger.Warning(string.Concat(Enumerable.Repeat<string>("!", 15)));
return false;
}
return true;
}
public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Invalid comparison between Unknown and I4
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_047c: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Invalid comparison between Unknown and I4
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
List<TransformationRule> obj = Enumerable.ToList<TransformationRule>(Enumerable.Where<TransformationRule>((global::System.Collections.Generic.IEnumerable<TransformationRule>)<rules>P, (Func<TransformationRule, bool>)([CompilerGenerated] (TransformationRule rule) =>
{
bool num2 = rule.Predicate.Invoke();
if (!num2)
{
<mod>P.Logger.Information($"[{<name>P}] Skipping patch {rule.Name}...");
}
return num2;
})));
List<ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>> val = Enumerable.ToList<ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>>(Enumerable.Select<TransformationRule, ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>>((global::System.Collections.Generic.IEnumerable<TransformationRule>)obj, (Func<TransformationRule, ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>>)((TransformationRule rule) => new ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>(rule, rule.CreateMultiTokenWaiter(), new List<Token>()))));
<mod>P.Logger.Information("[" + <name>P + "] Patching " + path);
Dictionary<string, ValueTuple<int, uint>> val2 = Enumerable.ToDictionary<TransformationRule, string, ValueTuple<int, uint>>((global::System.Collections.Generic.IEnumerable<TransformationRule>)obj, (Func<TransformationRule, string>)((TransformationRule r) => r.Name), (Func<TransformationRule, ValueTuple<int, uint>>)((TransformationRule r) => new ValueTuple<int, uint>(0, r.Times)));
bool flag = true;
List<Token> val3 = new List<Token>();
val3.AddRange(tokens);
List<Token> val4 = new List<Token>();
Enumerator<ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>>> enumerator = val.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ValueTuple<TransformationRule, MultiTokenWaiter, List<Token>> current = enumerator.Current;
bool flag2 = current.Item1.ScopePattern.Length != 0;
bool flag3 = !flag2;
uint? num = null;
MultiTokenWaiter val5 = current.Item1.CreateMultiTokenWaiterForScope();
Enumerator<Token> enumerator2 = val3.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
Token current2 = enumerator2.Current;
if (flag3 && flag2)
{
if (!num.HasValue && (int)current2.Type == 89)
{
num = current2.AssociatedData.GetValueOrDefault();
}
else if (num.HasValue && (int)current2.Type == 89)
{
flag3 = current2.AssociatedData.GetValueOrDefault() >= num;
}
}
else if (flag2 && val5.Check(current2))
{
val5.Reset();
flag3 = true;
}
if (!flag3)
{
val4.Add(current2);
continue;
}
current.Item2.Check(current2);
if (current.Item2.Step == 0)
{
val4.AddRange((global::System.Collections.Generic.IEnumerable<Token>)current.Item3);
current.Item3.Clear();
}
else
{
if (current.Item1.Operation.RequiresBuffer())
{
current.Item3.Add(current2);
flag = false;
}
if (current.Item2.Matched)
{
current.Item2.Reset();
if (current.Item1.Operation.YieldTokenBeforeOperation())
{
val4.Add(current2);
flag = false;
}
else
{
flag = current.Item1.Operation.YieldTokenAfterOperation();
}
switch (current.Item1.Operation)
{
case Operation.Prepend:
val4.AddRange(current.Item1.Tokens);
val4.AddRange((global::System.Collections.Generic.IEnumerable<Token>)current.Item3);
current.Item3.Clear();
break;
case Operation.ReplaceAll:
case Operation.ReplaceLast:
case Operation.Append:
current.Item3.Clear();
val4.AddRange(current.Item1.Tokens);
break;
}
<mod>P.Logger.Information($"[{<name>P}] Patch {current.Item1.Name} OK!");
string name = current.Item1.Name;
ValueTuple<int, uint> val6 = val2[current.Item1.Name];
val6.Item1 = val2[current.Item1.Name].Item1 + 1;
val2[name] = val6;
}
}
if (flag)
{
val4.Add(current2);
}
else
{
flag = true;
}
}
}
finally
{
((global::System.IDisposable)enumerator2).Dispose();
}
val3.Clear();
val3.AddRange((global::System.Collections.Generic.IEnumerable<Token>)val4);
val4.Clear();
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
global::System.Collections.Generic.IEnumerator<KeyValuePair<string, ValueTuple<int, uint>>> enumerator3 = Enumerable.Where<KeyValuePair<string, ValueTuple<int, uint>>>((global::System.Collections.Generic.IEnumerable<KeyValuePair<string, ValueTuple<int, uint>>>)val2, (Func<KeyValuePair<string, ValueTuple<int, uint>>, bool>)((KeyValuePair<string, ValueTuple<int, uint>> result) => result.Value.Item1 != result.Value.Item2)).GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator3).MoveNext())
{
KeyValuePair<string, ValueTuple<int, uint>> current3 = enumerator3.Current;
<mod>P.Logger.Error($"[{<name>P}] Patch {current3.Key} FAILED!!!!!!! Times expected={current3.Value.Item2}, actual={current3.Value.Item1}");
}
return (global::System.Collections.Generic.IEnumerable<Token>)val3;
}
finally
{
((global::System.IDisposable)enumerator3)?.Dispose();
}
}
}
public class TransformationRuleScriptModBuilder
{
private IModInterface? _mod;
private string? _name;
private string? _scriptPath;
private Func<bool> _predicate = () => true;
private List<TransformationRule> _rules = new List<TransformationRule>();
public TransformationRuleScriptModBuilder ForMod(IModInterface mod)
{
_mod = mod;
return this;
}
public TransformationRuleScriptModBuilder When(Func<bool> predicate)
{
_predicate = predicate;
return this;
}
public TransformationRuleScriptModBuilder Named(string name)
{
_name = name;
return this;
}
public TransformationRuleScriptModBuilder Patching(string scriptPath)
{
_scriptPath = scriptPath;
return this;
}
public TransformationRuleScriptModBuilder AddRule(TransformationRule rule)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (Enumerable.Contains<string>(Enumerable.Select<TransformationRule, string>((global::System.Collections.Generic.IEnumerable<TransformationRule>)_rules, (Func<TransformationRule, string>)((TransformationRule r) => r.Name)), rule.Name))
{
throw new InvalidOperationException("Another rule with the name '" + rule.Name + "' already exists!");
}
_rules.Add(rule);
return this;
}
public TransformationRuleScriptModBuilder AddRule(TransformationRuleBuilder rule)
{
return AddRule(rule.Build());
}
public TransformationRuleScriptMod Build()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (_mod == null)
{
throw new ArgumentNullException("_mod", "Mod cannot be null");
}
if (string.IsNullOrEmpty(_name))
{
throw new ArgumentNullException("_name", "Name cannot be null or empty");
}
if (string.IsNullOrEmpty(_scriptPath))
{
throw new ArgumentNullException("_scriptPath", "Script path cannot be null or empty");
}
return new TransformationRuleScriptMod(_mod, _name, _scriptPath, _predicate, _rules.ToArray());
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : global::System.Collections.IEnumerable, global::System.Collections.ICollection, global::System.Collections.IList, global::System.Collections.Generic.IEnumerable<T>, global::System.Collections.Generic.IReadOnlyCollection<T>, global::System.Collections.Generic.IReadOnlyList<T>, global::System.Collections.Generic.ICollection<T>, global::System.Collections.Generic.IList<T>
{
private sealed class Enumerator : global::System.IDisposable, global::System.Collections.IEnumerator, global::System.Collections.Generic.IEnumerator<T>
{
object global::System.Collections.IEnumerator.Current => _item;
T global::System.Collections.Generic.IEnumerator<T>.Current => _item;
public Enumerator(T item)
{
_item = item;
}
bool global::System.Collections.IEnumerator.MoveNext()
{
if (!_moveNextCalled)
{
return _moveNextCalled = true;
}
return false;
}
void global::System.Collections.IEnumerator.Reset()
{
_moveNextCalled = false;
}
void global::System.IDisposable.Dispose()
{
}
}
int global::System.Collections.ICollection.Count => 1;
bool global::System.Collections.ICollection.IsSynchronized => false;
object global::System.Collections.ICollection.SyncRoot => this;
object global::System.Collections.IList.this[int index]
{
get
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
}
bool global::System.Collections.IList.IsFixedSize => true;
bool global::System.Collections.IList.IsReadOnly => true;
int global::System.Collections.Generic.IReadOnlyCollection<T>.Count => 1;
T global::System.Collections.Generic.IReadOnlyList<T>.this[int index]
{
get
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
}
int global::System.Collections.Generic.ICollection<T>.Count => 1;
bool global::System.Collections.Generic.ICollection<T>.IsReadOnly => true;
T global::System.Collections.Generic.IList<T>.this[int index]
{
get
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
}
public <>z__ReadOnlySingleElementList(T item)
{
_item = item;
}
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return new Enumerator(_item);
}
void global::System.Collections.ICollection.CopyTo(global::System.Array array, int index)
{
array.SetValue((object)_item, index);
}
int global::System.Collections.IList.Add(object? value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
void global::System.Collections.IList.Clear()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
bool global::System.Collections.IList.Contains(object? value)
{
return EqualityComparer<T>.Default.Equals(_item, (T)value);
}
int global::System.Collections.IList.IndexOf(object? value)
{
if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
{
return -1;
}
return 0;
}
void global::System.Collections.IList.Insert(int index, object? value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
void global::System.Collections.IList.Remove(object? value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
void global::System.Collections.IList.RemoveAt(int index)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
global::System.Collections.Generic.IEnumerator<T> global::System.Collections.Generic.IEnumerable<T>.GetEnumerator()
{
return new Enumerator(_item);
}
void global::System.Collections.Generic.ICollection<T>.Add(T item)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
void global::System.Collections.Generic.ICollection<T>.Clear()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
bool global::System.Collections.Generic.ICollection<T>.Contains(T item)
{
return EqualityComparer<T>.Default.Equals(_item, item);
}
void global::System.Collections.Generic.ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
array[arrayIndex] = _item;
}
bool global::System.Collections.Generic.ICollection<T>.Remove(T item)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
int global::System.Collections.Generic.IList<T>.IndexOf(T item)
{
if (!EqualityComparer<T>.Default.Equals(_item, item))
{
return -1;
}
return 0;
}
void global::System.Collections.Generic.IList<T>.Insert(int index, T item)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
void global::System.Collections.Generic.IList<T>.RemoveAt(int index)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
}