Skip to content

Commit

Permalink
metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Akarinnnnn committed Mar 1, 2021
1 parent 57ddf5e commit 5fa89f6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
1 change: 0 additions & 1 deletion UniGal.Compiler.Frontend/Response/rtenv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ internal static EnvironmentInfo.Display on_display(XmlReader r, List<CompilerErr
uint w = 1920;
uint h = 1080;
bool fullscr = true;

while (r.Read())
{
if(r.NodeType == XmlNodeType.Element)
Expand Down
58 changes: 56 additions & 2 deletions UniGal.Compiler.Frontend/Response/toplevel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -22,8 +23,61 @@ internal static string on_comment(XmlReader r)
internal static Metadata on_metadata(XmlReader r, List<CompilerError> errors)
{
Metadata ret = new();

// r.
while (r.Read())
{
if(r.NodeType == XmlNodeType.Element)
{
while (r.Read() && r.NodeType != XmlNodeType.EndElement)
{
if (r.NodeType == XmlNodeType.Element)
{
try
{
switch (r.Name)
{
case "src":
ret.Source = r.Value;
break;
case "dst":
ret.Target = r.Value;
break;
case "src_engine":
ret.SourceEngine = r.Value;
break;
case "dst_engine":
ret.TargetEngine = r.Value;
break;
case "src_characterset":
ret.SourceEncoding = Encoding.GetEncoding(r.Value);
break;
case "dst_characterset":
ret.TargetEncoding = Encoding.GetEncoding(r.Value);
break;
case "src_language":
ret.SourceCulture = CultureInfo.GetCultureInfo(r.Value);
break;
case "dst_language":
ret.SourceCulture = CultureInfo.GetCultureInfo(r.Value);
break;
case "comment":
ret.Comment = on_comment(r);
break;
default:
break;
}
}
catch (CultureNotFoundException e)
{
errors.Add(new parser_error(9002, ErrorServiety.Warning, new string[] { e.Message, e.InvalidCultureName! }, "出现脚本编译器不支持的语言"));
}
catch (ArgumentException e)
{
errors.Add(new parser_error(9002, ErrorServiety.Warning, new string[] { e.Message, e.ParamName! }, "出现脚本编译器不支持的编码"));
}
}
}
}
}
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion UniGal.Compiler.IR/BasicElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace UniGal.Compiler.IR
public class BasicElement
{
/// <summary>直观编辑器所使用的注释</summary>
public StringView Comment = new StringView();
public string Comment = "";
/// <summary>
/// 原始表示
/// </summary>
Expand Down

0 comments on commit 5fa89f6

Please sign in to comment.