/// <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); }
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); } } }
/// <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); }
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); }
public ArrayConstructor(Cci.IArrayTypeReference arrayType) : base(arrayType) { }
/// <summary> /// Acquires an element referencer method for a given array type /// </summary> public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType) { return(GetArrayMethod(arrayType, ArrayMethodKind.ADDRESS)); }
/// <summary> /// Acquires an element setter method for a given array type /// </summary> public ArrayMethod GetArraySet(Cci.IArrayTypeReference arrayType) { return(GetArrayMethod(arrayType, ArrayMethodKind.SET)); }
/// <summary> /// Acquires an array constructor for a given array type /// </summary> public ArrayMethod GetArrayConstructor(Cci.IArrayTypeReference arrayType) { return(GetArrayMethod(arrayType, ArrayMethodKind.CTOR)); }
protected ArrayMethod(Cci.IArrayTypeReference arrayType) { this.arrayType = arrayType; _parameters = MakeParameters(); }
internal ArraySetValueParameterInfo(ushort index, Cci.IArrayTypeReference arrayType) : base(index) { _arrayType = arrayType; }
public ArraySet(Cci.IArrayTypeReference arrayType) : base(arrayType) { }
public ArrayAddress(Cci.IArrayTypeReference arrayType) : base(arrayType) { }
/// <summary> /// Acquires an element referencer method for a given array type /// </summary> public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType) => GetArrayMethod(arrayType, ArrayMethodKind.ADDRESS);
/// <summary> /// Acquires an element setter method for a given array type /// </summary> public ArrayMethod GetArraySet(Cci.IArrayTypeReference arrayType) => GetArrayMethod(arrayType, ArrayMethodKind.SET);