示例#1
0
        // 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));
        }
示例#2
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);
        }
示例#3
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);
        }
示例#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();

            Class decl;

            if (!field.Type.Desugar().IsTagDecl(out decl))
            {
                return(false);
            }

            return(decl.IsValueType);
        }