示例#1
0
 public static string Type(LatteParser.TypeContext typeContext)
 {
     return(typeContext switch
     {
         LatteParser.TBoolContext boolContext => "i1",
         LatteParser.TIntContext intContext => "i32",
         LatteParser.TStringContext stringContext => "i8*",
         LatteParser.TTypeNameContext typeNameContext => $"%{typeNameContext.GetText()}*",
         LatteParser.TVoidContext voidContext => "void",
         _ => throw new ArgumentOutOfRangeException(nameof(typeContext))
     });
示例#2
0
 private int GetTypeSize(LatteParser.TypeContext type)
 {
     return(type switch
     {
         LatteParser.TBoolContext boolContext => 1,
         LatteParser.TIntContext intContext => 4,
         LatteParser.TStringContext stringContext => 8,
         LatteParser.TTypeNameContext typeNameContext => 8,
         LatteParser.TVoidContext voidContext => throw new NotSupportedException(),
         _ => throw new ArgumentOutOfRangeException(nameof(type))
     });