update changelog and version bump
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
[0.2.4]
|
||||
|
||||
- Groundwork laid to collect and track source maps
|
||||
- IC Housing will now display the `Slang` source error line (if available)
|
||||
instead of the `IC10` source error line
|
||||
|
||||
[0.2.3]
|
||||
|
||||
- Fixed stack underflow with function invocations
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Name>Slang</Name>
|
||||
<Author>JoeDiertay</Author>
|
||||
<Version>0.2.3</Version>
|
||||
<Version>0.2.4</Version>
|
||||
<Description>
|
||||
[h1]Slang: High-Level Programming for Stationeers[/h1]
|
||||
|
||||
|
||||
@@ -44,10 +44,12 @@ public static class GlobalCode
|
||||
public static bool GetSlangErrorLineFromICError(
|
||||
Guid reference,
|
||||
uint icErrorLine,
|
||||
out uint slangSrc
|
||||
out uint slangSrc,
|
||||
out Range slangSpan
|
||||
)
|
||||
{
|
||||
slangSrc = icErrorLine;
|
||||
slangSpan = new Range { };
|
||||
|
||||
if (!sourceMaps.ContainsKey(reference))
|
||||
{
|
||||
@@ -62,6 +64,7 @@ public static class GlobalCode
|
||||
}
|
||||
|
||||
slangSrc = foundRange[0].StartLine;
|
||||
slangSpan = foundRange[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,23 @@ using StationeersIC10Editor;
|
||||
|
||||
public struct Range
|
||||
{
|
||||
public uint StartCol;
|
||||
public uint EndCol;
|
||||
public uint StartLine;
|
||||
public uint EndLine;
|
||||
public uint StartCol = 0;
|
||||
public uint EndCol = 0;
|
||||
public uint StartLine = 0;
|
||||
public uint EndLine = 0;
|
||||
|
||||
public Range(uint startLine, uint startCol, uint endLine, uint endCol)
|
||||
{
|
||||
StartLine = startLine;
|
||||
StartCol = startCol;
|
||||
EndLine = endLine;
|
||||
EndCol = endCol;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"L{StartLine}C{StartCol} - L{EndLine}C{EndCol}";
|
||||
}
|
||||
}
|
||||
|
||||
public struct Diagnostic
|
||||
@@ -27,6 +40,11 @@ public struct SourceMapEntry
|
||||
{
|
||||
public Range SlangSource;
|
||||
public uint Ic10Line;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"IC10: {Ic10Line} Slang: `{SlangSource}`";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Marshal
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
namespace Slang;
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Assets.Scripts.Objects;
|
||||
using Assets.Scripts.Objects.Electrical;
|
||||
using Assets.Scripts.Objects.Motherboards;
|
||||
using Assets.Scripts.UI;
|
||||
using HarmonyLib;
|
||||
|
||||
class LineErrorData
|
||||
{
|
||||
public AsciiString SourceRef;
|
||||
public uint IC10ErrorSource;
|
||||
public string SlangErrorReference;
|
||||
public Range SlangErrorSpan;
|
||||
|
||||
public LineErrorData(
|
||||
AsciiString sourceRef,
|
||||
uint ic10ErrorSource,
|
||||
string slangErrorRef,
|
||||
Range slangErrorSpan
|
||||
)
|
||||
{
|
||||
this.SourceRef = sourceRef;
|
||||
this.IC10ErrorSource = ic10ErrorSource;
|
||||
this.SlangErrorReference = slangErrorRef;
|
||||
this.SlangErrorSpan = slangErrorSpan;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class SlangPatches
|
||||
{
|
||||
@@ -14,6 +36,9 @@ public static class SlangPatches
|
||||
private static AsciiString? _motherboardCachedCode;
|
||||
private static Guid? _currentlyEditingGuid;
|
||||
|
||||
private static ConditionalWeakTable<ProgrammableChip, LineErrorData> _errorReferenceTable =
|
||||
new();
|
||||
|
||||
[HarmonyPatch(
|
||||
typeof(ProgrammableChipMotherboard),
|
||||
nameof(ProgrammableChipMotherboard.InputFinished)
|
||||
@@ -151,27 +176,88 @@ public static class SlangPatches
|
||||
{
|
||||
if (
|
||||
String.IsNullOrEmpty(__result)
|
||||
|| __result.LastIndexOf(GlobalCode.SLANG_REF) < 0
|
||||
|| !uint.TryParse(__result.Trim(), out var ic10ErrorLineNumber)
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sourceAscii = __instance.GetSourceCode();
|
||||
|
||||
if (_errorReferenceTable.TryGetValue(__instance, out var cache))
|
||||
{
|
||||
if (cache.SourceRef.Equals(sourceAscii) && cache.IC10ErrorSource == ic10ErrorLineNumber)
|
||||
{
|
||||
__result = cache.SlangErrorReference;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var source = System.Text.Encoding.UTF8.GetString(
|
||||
System.Text.Encoding.ASCII.GetBytes(__instance.GetSourceCode())
|
||||
);
|
||||
|
||||
var slangIndex = source.LastIndexOf(GlobalCode.SLANG_REF);
|
||||
|
||||
if (
|
||||
slangIndex < 0
|
||||
|| !Guid.TryParse(
|
||||
__result
|
||||
source
|
||||
.Substring(
|
||||
__result.LastIndexOf(GlobalCode.SLANG_REF) + GlobalCode.SLANG_REF.Length
|
||||
source.LastIndexOf(GlobalCode.SLANG_REF) + GlobalCode.SLANG_REF.Length
|
||||
)
|
||||
.Trim(),
|
||||
out var slangGuid
|
||||
)
|
||||
|| !uint.TryParse(__result.Trim(), out var ic10ErrorLineNumber)
|
||||
|| !GlobalCode.GetSlangErrorLineFromICError(
|
||||
slangGuid,
|
||||
ic10ErrorLineNumber,
|
||||
out var slangErrorLineNumber
|
||||
out var slangErrorLineNumber,
|
||||
out var slangSpan
|
||||
)
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L.Warning($"IC error at: {__result} -- Slang source error line: {slangErrorLineNumber}");
|
||||
__result = slangErrorLineNumber.ToString();
|
||||
_errorReferenceTable.Remove(__instance);
|
||||
_errorReferenceTable.Add(
|
||||
__instance,
|
||||
new LineErrorData(
|
||||
sourceAscii,
|
||||
ic10ErrorLineNumber,
|
||||
slangErrorLineNumber.ToString(),
|
||||
slangSpan
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[HarmonyPatch(
|
||||
typeof(ProgrammableChip),
|
||||
nameof(ProgrammableChip.SetSourceCode),
|
||||
new Type[] { typeof(string) }
|
||||
)]
|
||||
[HarmonyPostfix]
|
||||
public static void pgc_SetSourceCode_string(ProgrammableChip __instance, string sourceCode)
|
||||
{
|
||||
_errorReferenceTable.Remove(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(
|
||||
typeof(ProgrammableChip),
|
||||
nameof(ProgrammableChip.SetSourceCode),
|
||||
new Type[] { typeof(string), typeof(ICircuitHolder) }
|
||||
)]
|
||||
[HarmonyPostfix]
|
||||
public static void pgc_SetSourceCode_string_parent(
|
||||
ProgrammableChip __instance,
|
||||
string sourceCode,
|
||||
ICircuitHolder parent
|
||||
)
|
||||
{
|
||||
_errorReferenceTable.Remove(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Slang
|
||||
{
|
||||
public const string PluginGuid = "com.biddydev.slang";
|
||||
public const string PluginName = "Slang";
|
||||
public const string PluginVersion = "0.1.1";
|
||||
public const string PluginVersion = "0.2.4";
|
||||
|
||||
public static Mod MOD = new Mod(PluginName, PluginVersion);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>StationeersSlang</AssemblyName>
|
||||
<Description>Slang Compiler Bridge</Description>
|
||||
<Version>0.2.3</Version>
|
||||
<Version>0.2.4</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
2
rust_compiler/Cargo.lock
generated
2
rust_compiler/Cargo.lock
generated
@@ -910,7 +910,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "slang"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "slang"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
Reference in New Issue
Block a user