示例#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))
     });
示例#3
0
        private bool IsTypeParent(LatteParser.TypeContext type, LatteParser.TypeContext parentToCheck)
        {
            if (!(type is LatteParser.TTypeNameContext))
            {
                return(false);
            }

            var classDef = _environment.NameToClassDef[type.GetText()];

            if (classDef.ParentId == null)
            {
                return(false);
            }

            return(classDef.ParentId == parentToCheck.GetText() ||
                   IsTypeParent(new LatteParser.TTypeNameContext(classDef.ParentId), parentToCheck));
        }
示例#4
0
 public Arg(LatteParser.TypeContext type, string id)
 {
     Type = type;
     Id   = id;
 }
示例#5
0
 public NewObject(LatteParser.ENewObjectContext context)
 {
     Type = context.type();
 }
 public RegisterLabelContext(string register, string label, LatteParser.TypeContext type)
 {
     Register = register;
     Label    = label;
     Type     = type;
 }
示例#7
0
 public Field(LatteParser.TypeContext type, string id, int number) : base(type, id)
 {
     Number = number;
 }
示例#8
0
 public VarDef(LatteParser.TypeContext type, string name, bool isDefinedInCurrentBlock)
 {
     Type = type;
     Name = name;
     IsDefinedInCurrentBlock = isDefinedInCurrentBlock;
 }
示例#9
0
 public VarDef(LatteParser.TypeContext type, string name)
 {
     Type = type;
     Name = name;
     IsDefinedInCurrentBlock = true;
 }