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)) });
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)) });
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)); }
public Arg(LatteParser.TypeContext type, string id) { Type = type; Id = id; }
public NewObject(LatteParser.ENewObjectContext context) { Type = context.type(); }
public RegisterLabelContext(string register, string label, LatteParser.TypeContext type) { Register = register; Label = label; Type = type; }
public Field(LatteParser.TypeContext type, string id, int number) : base(type, id) { Number = number; }
public VarDef(LatteParser.TypeContext type, string name, bool isDefinedInCurrentBlock) { Type = type; Name = name; IsDefinedInCurrentBlock = isDefinedInCurrentBlock; }
public VarDef(LatteParser.TypeContext type, string name) { Type = type; Name = name; IsDefinedInCurrentBlock = true; }