mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-07 19:18:19 +02:00
Added Compiler.Identifier.GetSourceName
This commit is contained in:
parent
936dd656c8
commit
79a67c2d0c
3 changed files with 37 additions and 2 deletions
|
@ -8,6 +8,32 @@ namespace System
|
|||
{
|
||||
static class Compiler
|
||||
{
|
||||
public class Identifier
|
||||
{
|
||||
public static HashSet<String> sReservedNameSet = new .() ~ delete _;
|
||||
|
||||
const String[?] cReservedNames = .("abstract", "alignof", "alloctype", "append", "as", "asm", "base", "break",
|
||||
"case", "catch", "checked", "class", "comptype", "const", "continue", "decltype", "default", "defer", "delegate",
|
||||
"delete", "do", "else", "enum", "explicit", "extension", "extern", "false", "finally", "fixed", "for", "function",
|
||||
"if", "implicit", "in", "interface", "internal", "is", "isconst", "mixin", "namespace", "new", "null", "nullable",
|
||||
"offsetof", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref",
|
||||
"rettype", "return", "scope", "sealed", "sizeof", "static", "strideof", "struct", "switch", "this", "true", "try",
|
||||
"typealias", "typeof", "unchecked", "using", "var", "virtual", "volatile", "where", "while");
|
||||
|
||||
public static this()
|
||||
{
|
||||
for (var name in cReservedNames)
|
||||
sReservedNameSet.Add(name);
|
||||
}
|
||||
|
||||
public static void GetSourceName(StringView name, String outStr)
|
||||
{
|
||||
if (sReservedNameSet.ContainsAlt(name))
|
||||
outStr.Append('@');
|
||||
outStr.Append(name);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Generator
|
||||
{
|
||||
public enum Flags
|
||||
|
|
|
@ -609,7 +609,7 @@ namespace System
|
|||
entryTableCode.Append(", \"");
|
||||
entryTableCode.Append(fieldName);
|
||||
entryTableCode.Append("\", .");
|
||||
entryTableCode.Append(fieldInfo.Name);
|
||||
fieldInfo.GetSourceName(entryTableCode);
|
||||
entryTableCode.Append(", ");
|
||||
entryTableCode.Append((nextCases[caseIdx] == -1) ? "false" : "true");
|
||||
entryTableCode.Append(")");
|
||||
|
@ -622,7 +622,11 @@ namespace System
|
|||
if (caseHasPayload)
|
||||
code.AppendF($"\t\t\t\tmatchIdx = {caseIdx};\n");
|
||||
else
|
||||
code.AppendF($"\t\t\t\treturn .Ok(.{fieldInfo.Name});\n");
|
||||
{
|
||||
code.Append("\t\t\t\treturn .Ok(.");
|
||||
fieldInfo.GetSourceName(code);
|
||||
code.Append(");\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -38,6 +38,11 @@ namespace System.Reflection
|
|||
mFieldData.mCustomAttributesIdx :
|
||||
-1;
|
||||
|
||||
public void GetSourceName(String outStr)
|
||||
{
|
||||
Compiler.Identifier.GetSourceName(Name, outStr);
|
||||
}
|
||||
|
||||
public Result<void, Error> SetValue(Object obj, Object value)
|
||||
{
|
||||
void* dataAddr = ((uint8*)Internal.UnsafeCastToPtr(obj));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue