private uint GetArrayTypeIndex(TypeDesc type) { System.Diagnostics.Debug.Assert(type.IsArray, "GetArrayTypeIndex was called with wrong type"); ArrayType arrayType = (ArrayType)type; uint elementSize = (uint)type.Context.Target.PointerSize; LayoutInt layoutElementSize = arrayType.GetElementSize(); if (!layoutElementSize.IsIndeterminate) { elementSize = (uint)layoutElementSize.AsInt; } ArrayTypeDescriptor arrayTypeDescriptor = new ArrayTypeDescriptor { Rank = (uint)arrayType.Rank, ElementType = GetVariableTypeIndex(arrayType.ElementType, false), Size = elementSize, IsMultiDimensional = arrayType.IsMdArray ? 1 : 0 }; ClassTypeDescriptor classDescriptor = new ClassTypeDescriptor { IsStruct = 0, Name = _objectWriter.GetMangledName(type), BaseClassId = GetTypeIndex(arrayType.BaseType, false) }; uint typeIndex = _objectWriter.GetArrayTypeIndex(classDescriptor, arrayTypeDescriptor); _knownTypes[type] = typeIndex; _completeKnownTypes[type] = typeIndex; return(typeIndex); }
public override void StepOut(IContext context) { var vars = (Variables)context.Cache["vars"]; var typeSpec = this.ParentNode.ParentNode.ParseNode.ChildNodes.First(c => c.Term.Name.EndsWith("TypeSpecifier")); var currType = ((Node)typeSpec.ChildNodes.First().AstNode).NodeType; var currName = name; if (arroptpresent) { currType = new ArrayTypeDescriptor(currType); } vars.Add(currName, currType); var iltype = currType.IlType; context.Emit(opcode: ".locals init (" + iltype + ")", comment: "" + currType + " " + currName); if (arroptpresent && !initoptpres) { var newarrtype = ((ArrayTypeDescriptor)currType).NewArrType; context.Emit(opcode: "newarr " + newarrtype); var v = vars[currName]; context.Emit(opcode: "stloc " + v.IlNo, comment: "" + currName + "="); } if (initoptpres) { if (currType is ArrayTypeDescriptor && currType.PrimitiveType != VariableType.Char) { throw new Exception("Currently initialization of array other than char is not allowed"); } if (vars.ContainsKey(currName)) { var v = vars[currName]; context.Emit(opcode: "stloc " + v.IlNo, comment: "" + currName + "="); } else { throw new ArgumentOutOfRangeException("Unknown variable '" + currName + "'"); } } }
/// <summary> /// formats an array type /// </summary> /// <param name="arrayType"></param> /// <returns></returns> public override string FormatArrayType(ArrayTypeDescriptor arrayType) { return($"{arrayType.ElementType.FormatType(this)}[]"); }
uint ITypesDebugInfoWriter.GetArrayTypeIndex(ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor) { return(_dbgInfoWriter.GetArrayTypeIndex(classDescriptor, arrayTypeDescriptor, _nodeFactory.Target.PointerSize)); }
public uint GetArrayTypeIndex(ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor) { return(GetArrayTypeIndex(_nativeObjectWriter, classDescriptor, arrayTypeDescriptor)); }
private static extern uint GetArrayTypeIndex(IntPtr objWriter, ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor);
/// <summary> /// Formats an array type /// </summary> /// <param name="arrayType"></param> /// <returns></returns> public abstract string FormatArrayType(ArrayTypeDescriptor arrayType);