Example #1
0
        public static bool IsBaseClass(this ASTRecord record)
        {
            if (!record.GetParent(out Class decl))
            {
                return(false);
            }

            return(record.Object is Class recordDecl && recordDecl == decl.BaseClass);
        }
Example #2
0
        public static bool IsEnumNestedInClass(this ASTRecord <Declaration> record)
        {
            var @enum     = record.Value as Enumeration;
            var typedDecl = record.Value as ITypedDecl;

            if (@enum != null || (typedDecl?.Type?.TryGetEnum(out @enum)).GetValueOrDefault())
            {
                return(@enum?.Namespace is Class);
            }

            return(false);
        }
Example #3
0
        public static bool IsBaseClass(this ASTRecord record)
        {
            Class decl;

            if (!record.GetParent(out decl))
            {
                return(false);
            }

            var recordDecl = record.Object as Class;

            return(recordDecl != null && recordDecl == decl.BaseClass);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        public ASTRecord <T> Push <T>(T value)
        {
            ASTRecord parent = null;

            if (recordStack.Count > 0)
            {
                parent = recordStack.Peek();
            }

            var record = new ASTRecord <T>()
            {
                Parent = parent,
                Object = value
            };

            recordStack.Push(record);
            return(record);
        }
Example #7
0
        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);
        }
Example #8
0
        public static bool IsBaseClass(this ASTRecord record)
        {
            Class decl;

            return(record.GetParent(out decl) && decl.BaseClass == record.Object);
        }
Example #9
0
 public static bool IsDelegate(this ASTRecord record)
 {
     return(record.Object is TypedefDecl typedef && typedef.Type.GetPointee() is FunctionType);
 }
Example #10
0
        public static bool IsDelegate(this ASTRecord record)
        {
            var typedef = record.Object as TypedefDecl;

            return(typedef != null && typedef.Type.GetPointee() is FunctionType);
        }