示例#1
0
        public AST.QualifiedType VisitQualified(QualifiedType qualType)
        {
            var _qualType = new AST.QualifiedType
            {
                Qualifiers = new AST.TypeQualifiers
                {
                    IsConst    = qualType.Qualifiers.IsConst,
                    IsRestrict = qualType.Qualifiers.IsRestrict,
                    IsVolatile = qualType.Qualifiers.IsVolatile,
                },
                Type = Visit(qualType.Type)
            };

            return(_qualType);
        }
示例#2
0
        public static IList <Parameter> GatherInternalParams(this Function function,
                                                             bool isItaniumLikeAbi, bool universalDelegate = false)
        {
            var @params = new List <Parameter>();

            var method           = (function.OriginalFunction ?? function) as Method;
            var isInstanceMethod = method != null && !method.IsStatic;

            var pointer = new QualifiedType(new PointerType(new QualifiedType(new BuiltinType(PrimitiveType.Void))));

            if (isInstanceMethod && !isItaniumLikeAbi)
            {
                @params.Add(new Parameter
                {
                    QualifiedType = pointer,
                    Name          = "instance",
                    Namespace     = function
                });
            }

            if (!function.HasIndirectReturnTypeParameter &&
                isInstanceMethod && isItaniumLikeAbi)
            {
                @params.Add(new Parameter
                {
                    QualifiedType = pointer,
                    Name          = "instance",
                    Namespace     = function
                });
            }

            var i = 0;

            foreach (var param in function.Parameters.Where(
                         p => p.Kind != ParameterKind.OperatorParameter && p.Kind != ParameterKind.Extension))
            {
                @params.Add(new Parameter
                {
                    QualifiedType = universalDelegate && param.Kind == ParameterKind.IndirectReturnType ?
                                    pointer : param.QualifiedType,
                    Kind      = param.Kind,
                    Usage     = param.Usage,
                    Name      = universalDelegate ? $"arg{++i}": param.Name,
                    Namespace = param.Namespace
                });

                if (param.Kind == ParameterKind.IndirectReturnType &&
                    isInstanceMethod && isItaniumLikeAbi)
                {
                    @params.Add(new Parameter
                    {
                        QualifiedType = pointer,
                        Name          = "instance",
                        Namespace     = function
                    });
                }
            }

            if (method != null && method.IsConstructor)
            {
                var @class = (Class)method.Namespace;
                if (!isItaniumLikeAbi && @class.Layout.HasVirtualBases)
                {
                    @params.Add(new Parameter
                    {
                        QualifiedType = new QualifiedType(new BuiltinType(PrimitiveType.Int)),
                        Name          = "__forBases",
                        Namespace     = function
                    });
                }
            }

            return(@params);
        }
示例#3
0
 public virtual QualifiedType TransformType(CppSharp.AST.QualifiedType type) => type;
示例#4
0
 public TemplateParameterSubstitutionType(TemplateParameterSubstitutionType type)
     : base(type)
 {
     Replacement = new QualifiedType((Type)type.Replacement.Type.Clone(), type.Replacement.Qualifiers);
 }
示例#5
0
 public AttributedType(AttributedType type)
     : base(type)
 {
     Modified   = new QualifiedType((Type)type.Modified.Type.Clone(), type.Modified.Qualifiers);
     Equivalent = new QualifiedType((Type)type.Equivalent.Type.Clone(), type.Equivalent.Qualifiers);
 }
示例#6
0
 public MemberPointerType(MemberPointerType type)
     : base(type)
 {
     QualifiedPointee = new QualifiedType((Type)type.QualifiedPointee.Type.Clone(),
                                          type.QualifiedPointee.Qualifiers);
 }
示例#7
0
 public PointerType(QualifiedType pointee = new QualifiedType())
 {
     Modifier         = TypeModifier.Pointer;
     QualifiedPointee = pointee;
 }
示例#8
0
 public ArrayType(QualifiedType qualifiedType)
 {
     QualifiedType = qualifiedType;
 }