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))
     });
Exemple #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))
     });
Exemple #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));
        }
Exemple #4
0
 public Arg(LatteParser.TypeContext type, string id)
 {
     Type = type;
     Id   = id;
 }
Exemple #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;
 }
Exemple #7
0
 public Field(LatteParser.TypeContext type, string id, int number) : base(type, id)
 {
     Number = number;
 }
Exemple #8
0
 public VarDef(LatteParser.TypeContext type, string name, bool isDefinedInCurrentBlock)
 {
     Type = type;
     Name = name;
     IsDefinedInCurrentBlock = isDefinedInCurrentBlock;
 }
Exemple #9
0
 public VarDef(LatteParser.TypeContext type, string name)
 {
     Type = type;
     Name = name;
     IsDefinedInCurrentBlock = true;
 }