// Pushes ancestors into the stack until it has found one of type T. public bool GetAncestors <T>(ref Stack <object> ancestors) { ancestors.Push(this); if (GetParent(out T value)) { ancestors.Push(value); return(true); } return(Parent != null && Parent.GetAncestors <T>(ref ancestors)); }
public static bool IsFieldValueType(this ASTRecord record) { var ancestors = new Stack <object>(); if (!record.GetAncestors <Field>(ref ancestors)) { return(false); } var field = (Field)ancestors.Pop(); return(field.Type.Desugar().TryGetClass(out var decl) && decl.IsValueType); }
public static bool FunctionReturnsClassByValue(this ASTRecord record) { var ancestors = new Stack <object>(); if (!record.GetAncestors <Function>(ref ancestors)) { return(false); } var function = (Function)ancestors.Pop(); var tagType = function.ReturnType.Type.Desugar() as TagType; return(tagType?.Declaration is Class); }
public static bool IsFieldValueType(this ASTRecord record) { var ancestors = new Stack <object>(); if (!record.GetAncestors <Field>(ref ancestors)) { return(false); } var field = (Field)ancestors.Pop(); Class decl; if (!field.Type.Desugar().IsTagDecl(out decl)) { return(false); } return(decl.IsValueType); }