本文整理汇总了C#中ArrayType类的典型用法代码示例。如果您正苦于以下问题:C# ArrayType类的具体用法?C# ArrayType怎么用?C# ArrayType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayType类属于命名空间,在下文中一共展示了ArrayType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringType
public static ArrayType GetStringType(ResolutionContext ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
{
ArrayType _t = null;
if (ctxt != null && ctxt.ScopedBlock != null)
{
var obj = ctxt.ParseCache.LookupModuleName(ctxt.ScopedBlock.NodeRoot as DModule, "object").FirstOrDefault();
if (obj != null)
{
string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
fmt == LiteralSubformat.Utf16 ? "wstring" :
"string";
var strNode = obj[strType];
if (strNode != null)
foreach (var n in strNode) {
_t = TypeDeclarationResolver.HandleNodeMatch(n, ctxt) as ArrayType;
if (_t != null)
break;
}
}
}
if (_t == null)
{
var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;
_t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable));
}
return _t;
}
示例2: Execute
public void Execute()
{
var assemblyContainsAttribute = ModuleDefinition.Assembly.CustomAttributes.ContainsAttribute("LogMinimalMessageAttribute");
var moduleContainsAttribute = ModuleDefinition.CustomAttributes.ContainsAttribute("LogMinimalMessageAttribute");
if (assemblyContainsAttribute || moduleContainsAttribute)
{
LogMinimalMessage = true;
}
FindReference();
Init();
var stringType = ModuleDefinition.TypeSystem.String.Resolve();
ConcatMethod = ModuleDefinition.Import(stringType.FindMethod("Concat", "String", "String"));
FormatMethod = ModuleDefinition.Import(stringType.FindMethod("Format", "String", "Object[]"));
ObjectArray = new ArrayType(ModuleDefinition.TypeSystem.Object);
FindExceptionType();
foreach (var type in ModuleDefinition
.GetTypes()
.Where(x => (x.BaseType != null) && !x.IsEnum && !x.IsInterface))
{
ProcessType(type);
}
//TODO: ensure attributes dont exist on interfaces
RemoveReference();
}
示例3: GetStringType
public static ArrayType GetStringType(ResolverContextStack ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
{
ArrayType _t = null;
if (ctxt != null)
{
var obj = ctxt.ParseCache.LookupModuleName("object").First();
string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
fmt == LiteralSubformat.Utf16 ? "wstring" :
"string";
var strNode = obj[strType];
if(strNode!=null && strNode.Count != 0)
_t = DResolver.StripAliasSymbol(TypeDeclarationResolver.HandleNodeMatch(strNode[0], ctxt)) as ArrayType;
}
if (_t == null)
{
var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;
_t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable),
new ArrayDecl
{
ValueType = new MemberFunctionAttributeDecl(DTokens.Immutable)
{
InnerType = new DTokenDeclaration(ch)
}
});
}
return _t;
}
示例4: VisitArrayType
public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
{
TypeMap typeMap;
if (TypeMapDatabase.FindTypeMap(array, out typeMap) && typeMap.IsIgnored)
{
Ignore();
return false;
}
if (array.SizeType != ArrayType.ArraySize.Constant)
return true;
var arrayElemType = array.Type.Desugar();
Class @class;
if (arrayElemType.TryGetClass(out @class) && @class.IsRefType)
return true;
PrimitiveType primitive;
if ((arrayElemType.IsPrimitiveType(out primitive) && primitive != PrimitiveType.LongDouble) ||
arrayElemType.IsPointerToPrimitiveType())
return true;
Ignore();
return false;
}
示例5: TyfoArray
public void TyfoArray()
{
ArrayType arr = new ArrayType(PrimitiveType.Int32, 10);
tyreffo.WriteDeclaration(arr, "a");
string sExp = "int32 a[10]";
Assert.AreEqual(sExp, sw.ToString());
}
示例6: Tabularize
public static void Tabularize(ArrayType a, string tasName)
{
((ICDType)a.m_type).Tabularize(tasName);
if (a.m_type.Constructed)
{
TypeAssigment newTas = ((ICDModule)a.m_module).CreateNewTypeAssigment(tasName, a.m_type, new List<string>());
a.m_type = ReferenceType.CreateByName(newTas);
}
}
示例7: VisitArray
public void VisitArray(ArrayType at)
{
var addrEnd = rdr.Address + cbSize;
for (int i = 0; at.IsUnbounded || i < at.Length; ++i)
{
if (!rdr.IsValid || addrEnd <= rdr.Address)
return;
at.ElementType.Accept(this);
}
}
示例8: ScalarArray
/// <summary>
/// Инициализирует новый экземпляр класса <see cref="ScalarArray"/> с указанием его типа
/// </summary>
/// <param name="arrayType">Значение перечисления <see cref="ArrayType"/>, определяющая тип скалярного массива</param>
private ScalarArray(ArrayType arrayType)
: base(true)
{
if (arrayType < ArrayType.Scalar || arrayType > ArrayType.Double)
{
throw new ArgumentOutOfRangeException("arrayType");
}
Type = arrayType;
}
示例9: VisitArray
public void VisitArray(ArrayType at)
{
if (at.Length == 0)
{
scanner.Warn(Address, "User-specified arrays must have a non-zero size.");
return;
}
for (int i = 0; i < at.Length; ++i)
{
at.ElementType.Accept(this);
}
}
示例10: MakeArrayType
public static ArrayType MakeArrayType(this TypeReference self, int rank)
{
if (rank == 0)
throw new ArgumentOutOfRangeException ("rank");
var array = new ArrayType (self);
for (int i = 1; i < rank; i++)
array.Dimensions.Add (new ArrayDimension ());
return array;
}
示例11: CheckSemantic
public override void CheckSemantic(Scope scope, List<Error> errors)
{
//es añadido al scope en el CheckSemantic del TypeDeclarationSecuence si no esta redefinido incorrectamente
TigerType elementsType = scope.GetType(ElementsTypeName);
if (elementsType == null)
{
errors.Add(new Error(GetChild(1), "El tipo '{0}' no está definido en el ámbito actual", ElementsTypeName));
HasError = true;
RelatedType = new ArrayType(UndefinedType.UndefinedInstance, ElementsTypeName);
}
else
RelatedType = new ArrayType(elementsType, ElementsTypeName);
}
示例12: StructureContainingArray
public void StructureContainingArray()
{
ArrayType a = new ArrayType(PrimitiveType.Int32, 4);
StructureType s = new StructureType(null, 0) { Fields = { { 8, a } } };
TypeVariable tv = store.CreateTypeVariable(factory);
tv.Class.DataType = s;
Assert.AreEqual(1, store.UsedEquivalenceClasses.Count);
DataType dt = tv.Class.DataType.Accept(nct);
Assert.AreEqual(1, store.UsedEquivalenceClasses.Count);
Assert.AreEqual("(struct (8 (arr int32 4) a0008))", store.UsedEquivalenceClasses[0].DataType.ToString());
}
示例13: VisitArray
public override DataType VisitArray(ArrayType at)
{
if (insideComplexType)
{
var nctr = new NestedComplexTypeExtractor(factory, store);
at.Accept(nctr);
return at;
}
else
{
insideComplexType = true;
return base.VisitArray(at);
}
}
示例14: CEB_BuildByteArrayFetch
public void CEB_BuildByteArrayFetch()
{
var i = new Identifier("i", PrimitiveType.Word32, null);
DataType arrayOfBytes = new ArrayType(PrimitiveType.Byte, 0);
StructureType str = Struct(
Fld(0x01000, arrayOfBytes));
CreateTv(globals, Ptr32(str), Ptr32(PrimitiveType.Byte));
CreateTv(i, PrimitiveType.Int32, PrimitiveType.Word32);
var ceb = new ComplexExpressionBuilder(
PrimitiveType.Byte,
globals.TypeVariable.DataType,
globals.TypeVariable.OriginalDataType,
null,
globals, i, 0x1000);
ceb.Dereferenced = true;
Assert.AreEqual("globals->a1000[i]", ceb.BuildComplex().ToString());
}
示例15: ArrayOfStructures
public void ArrayOfStructures()
{
StructureType s = new StructureType();
s.Fields.Add(0, PrimitiveType.Word32);
s.Fields.Add(4, PrimitiveType.Real64);
ArrayType a = new ArrayType(s, 0);
TypeVariable tv = store.CreateTypeVariable(factory);
tv.Class.DataType = a;
Assert.AreEqual(1, store.UsedEquivalenceClasses.Count);
tv.Class.DataType.Accept(nct);
Assert.AreEqual(2, store.UsedEquivalenceClasses.Count);
Assert.AreEqual("(arr Eq_2)", store.UsedEquivalenceClasses[0].DataType.ToString());
Assert.AreEqual("(struct (0 word32 dw0000) (4 real64 r0004))", store.UsedEquivalenceClasses[1].DataType.ToString());
}