Esempio n. 1
0
        /// <summary>
        /// Generates code that stores an element of a multidimensional array.
        /// </summary>
        internal void EmitArrayElementStore(Cci.IArrayTypeReference arrayType, SyntaxNode syntaxNode, DiagnosticBag diagnostics)
        {
            var store = module.ArrayMethods.GetArraySet(arrayType);

            // this, idx1, value --> void
            this.EmitOpCode(ILOpCode.Call, -3);
            this.EmitToken(store, syntaxNode, diagnostics);
        }
Esempio n. 2
0
        internal void EmitArrayElementStore(Cci.IArrayTypeReference arrayType, SyntaxNode syntaxNode, DiagnosticBag diagnostics)
        {
            Debug.Assert(!arrayType.IsSZArray, "should be used only with multidimensional arrays");

            var store = module.ArrayMethods.GetArraySet(arrayType);

            // this, idx1, idx2, value --> void
            this.EmitOpCode(ILOpCode.Call, -(2 + (int)arrayType.Rank));
            this.EmitToken(store, syntaxNode, diagnostics);
        }
        private static void VisitTypeReference(Cci.ITypeReference typeReference, EmitContext context)
        {
            Debug.Assert(typeReference != null);

            Cci.IArrayTypeReference arrayType = typeReference as Cci.IArrayTypeReference;
            if (arrayType != null)
            {
                VisitTypeReference(arrayType.GetElementType(context), context);
                return;
            }

            Cci.IPointerTypeReference pointerType = typeReference as Cci.IPointerTypeReference;
            if (pointerType != null)
            {
                VisitTypeReference(pointerType.GetTargetType(context), context);
                return;
            }

            Debug.Assert(!(typeReference is Cci.IManagedPointerTypeReference));
            //Cci.IManagedPointerTypeReference managedPointerType = typeReference as Cci.IManagedPointerTypeReference;
            //if (managedPointerType != null)
            //{
            //    VisitTypeReference(managedPointerType.GetTargetType(this.context));
            //    return;
            //}

            Cci.IModifiedTypeReference modifiedType = typeReference as Cci.IModifiedTypeReference;
            if (modifiedType != null)
            {
                foreach (var custModifier in modifiedType.CustomModifiers)
                {
                    VisitTypeReference(custModifier.GetModifier(context), context);
                }
                VisitTypeReference(modifiedType.UnmodifiedType, context);
                return;
            }

            // Visit containing type
            Cci.INestedTypeReference nestedType = typeReference.AsNestedTypeReference;
            if (nestedType != null)
            {
                VisitTypeReference(nestedType.GetContainingType(context), context);
            }

            // Visit generic arguments
            Cci.IGenericTypeInstanceReference genericInstance = typeReference.AsGenericTypeInstanceReference;
            if (genericInstance != null)
            {
                foreach (var arg in genericInstance.GetGenericArguments(context))
                {
                    VisitTypeReference(arg, context);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// lazily fetches or creates a new array method.
        /// </summary>
        private ArrayMethod GetArrayMethod(Cci.IArrayTypeReference arrayType, ArrayMethodKind id)
        {
            var         key = ValueTuple.Create((byte)id, arrayType);
            ArrayMethod result;

            var dict = _dict;

            if (!dict.TryGetValue(key, out result))
            {
                result = MakeArrayMethod(arrayType, id);
                result = dict.GetOrAdd(key, result);
            }

            return(result);
        }
Esempio n. 5
0
        private static ArrayMethod MakeArrayMethod(Cci.IArrayTypeReference arrayType, ArrayMethodKind id)
        {
            switch (id)
            {
            case ArrayMethodKind.CTOR:
                return(new ArrayConstructor(arrayType));

            case ArrayMethodKind.GET:
                return(new ArrayGet(arrayType));

            case ArrayMethodKind.SET:
                return(new ArraySet(arrayType));

            case ArrayMethodKind.ADDRESS:
                return(new ArrayAddress(arrayType));
            }

            throw ExceptionUtilities.UnexpectedValue(id);
        }
Esempio n. 6
0
 public ArrayConstructor(Cci.IArrayTypeReference arrayType) : base(arrayType)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Acquires an element referencer method for a given array type
 /// </summary>
 public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType)
 {
     return(GetArrayMethod(arrayType, ArrayMethodKind.ADDRESS));
 }
Esempio n. 8
0
 /// <summary>
 /// Acquires an element setter method for a given array type
 /// </summary>
 public ArrayMethod GetArraySet(Cci.IArrayTypeReference arrayType)
 {
     return(GetArrayMethod(arrayType, ArrayMethodKind.SET));
 }
Esempio n. 9
0
 /// <summary>
 /// Acquires an array constructor for a given array type
 /// </summary>
 public ArrayMethod GetArrayConstructor(Cci.IArrayTypeReference arrayType)
 {
     return(GetArrayMethod(arrayType, ArrayMethodKind.CTOR));
 }
Esempio n. 10
0
 protected ArrayMethod(Cci.IArrayTypeReference arrayType)
 {
     this.arrayType = arrayType;
     _parameters    = MakeParameters();
 }
Esempio n. 11
0
 internal ArraySetValueParameterInfo(ushort index, Cci.IArrayTypeReference arrayType)
     : base(index)
 {
     _arrayType = arrayType;
 }
Esempio n. 12
0
 public ArraySet(Cci.IArrayTypeReference arrayType) : base(arrayType)
 {
 }
Esempio n. 13
0
 public ArrayAddress(Cci.IArrayTypeReference arrayType) : base(arrayType)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Acquires an element referencer method for a given array type
 /// </summary>
 public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType)
 => GetArrayMethod(arrayType, ArrayMethodKind.ADDRESS);
Esempio n. 15
0
 /// <summary>
 /// Acquires an element setter method for a given array type
 /// </summary>
 public ArrayMethod GetArraySet(Cci.IArrayTypeReference arrayType)
 => GetArrayMethod(arrayType, ArrayMethodKind.SET);
Esempio n. 16
0
 protected ArrayMethod(Cci.IArrayTypeReference arrayType)
 {
     this.arrayType = arrayType;
     _parameters = MakeParameters();
 }
Esempio n. 17
0
 internal ArraySetValueParameterInfo(ushort index, Cci.IArrayTypeReference arrayType)
     : base(index)
 {
     _arrayType = arrayType;
 }