mirror of
https://github.com/Wack0/IFPSTools.NET.git
synced 2025-06-19 03:05:40 -04:00
asm: fix culture issues by setting current thread culture when inside the assembler
This commit is contained in:
parent
0f6e7a5bcb
commit
7202da81ea
@ -9,6 +9,8 @@ using IFPSLib.Emit.FDecl;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace IFPSAsmLib
|
namespace IFPSAsmLib
|
||||||
{
|
{
|
||||||
@ -98,6 +100,7 @@ namespace IFPSAsmLib
|
|||||||
|
|
||||||
public static class Assembler
|
public static class Assembler
|
||||||
{
|
{
|
||||||
|
private static readonly CultureInfo s_Culture = new CultureInfo("en");
|
||||||
private static IEnumerable<ParsedBody> OfType(this IEnumerable<ParsedBody> self, ElementParentType type)
|
private static IEnumerable<ParsedBody> OfType(this IEnumerable<ParsedBody> self, ElementParentType type)
|
||||||
{
|
{
|
||||||
return self.Where(x => x.Element.ParentType == type);
|
return self.Where(x => x.Element.ParentType == type);
|
||||||
@ -856,7 +859,7 @@ namespace IFPSAsmLib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Script Assemble(List<ParsedBody> parsed)
|
private static Script AssembleImpl(List<ParsedBody> parsed)
|
||||||
{
|
{
|
||||||
int version = Script.VERSION_HIGHEST;
|
int version = Script.VERSION_HIGHEST;
|
||||||
{
|
{
|
||||||
@ -939,6 +942,21 @@ namespace IFPSAsmLib
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Script Assemble(List<ParsedBody> parsed)
|
||||||
|
{
|
||||||
|
// Set the current thread's culture to english when assembling, to ensure float/double/decimal parsing works correctly.
|
||||||
|
var currentCulture = Thread.CurrentThread.CurrentCulture;
|
||||||
|
Thread.CurrentThread.CurrentCulture = s_Culture;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return AssembleImpl(parsed);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Thread.CurrentThread.CurrentCulture = currentCulture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Script Assemble(string str) => Assemble(Parser.Parse(str));
|
public static Script Assemble(string str) => Assemble(Parser.Parse(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user