本文整理汇总了C#中ArrayType类的典型用法代码示例。如果您正苦于以下问题:C# ArrayType类的具体用法?C# ArrayType怎么用?C# ArrayType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayType类属于命名空间,在下文中一共展示了ArrayType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:35,代码来源:Evaluation.PrimaryExpression.cs
示例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();
}
开发者ID:GeorgeHahn,项目名称:Anotar,代码行数:26,代码来源:ModuleWeaver.cs
示例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;
}
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:35,代码来源:Evaluation.PrimaryExpression.cs
示例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;
}
开发者ID:ymlai87416,项目名称:CppSharp,代码行数:26,代码来源:Types.cs
示例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());
}
开发者ID:nemerle,项目名称:reko,代码行数:8,代码来源:TypeFormatterTests.cs
示例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);
}
}
开发者ID:kia92798,项目名称:tinyasn1,代码行数:9,代码来源:ConstructedTypes.cs
示例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);
}
}
开发者ID:relaxar,项目名称:reko,代码行数:10,代码来源:TypedDataDumper.cs
示例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;
}
开发者ID:KalinovDmitri,项目名称:OpenCV,代码行数:14,代码来源:ScalarArray.cs
示例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);
}
}
开发者ID:relaxar,项目名称:reko,代码行数:12,代码来源:GlobalDataWorkItem.cs
示例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;
}
开发者ID:ttRevan,项目名称:cecil,代码行数:12,代码来源:TypeReferenceRocks.cs
示例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);
}
开发者ID:sandygk,项目名称:Tiger-Compiler,代码行数:13,代码来源:ArrayDecNode.cs
示例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());
}
开发者ID:gitter-badger,项目名称:reko,代码行数:14,代码来源:NestedComplexTypeExtractorTests.cs
示例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);
}
}
开发者ID:relaxar,项目名称:reko,代码行数:14,代码来源:NestedComplexTypeExtractor.cs
示例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());
}
开发者ID:nemerle,项目名称:reko,代码行数:17,代码来源:ComplexExpressionBuilderTests.cs
示例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());
}
开发者ID:relaxar,项目名称:reko,代码行数:18,代码来源:NestedComplexTypeExtractorTests.cs
示例16: Execute
public void Execute()
{
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 don't exist on interfaces
RemoveReference();
}
开发者ID:vlaci,项目名称:Anotar,代码行数:20,代码来源:ModuleWeaver.cs
示例17: PrintCInitialize
public static void PrintCInitialize(ArrayType pThis, PEREffectiveConstraint cns,
Asn1Value defauleVal, StreamWriterLevel c, string typeName, string varName, int lev, int arrayDepth)
{
long min = pThis.minItems(cns);
long max = pThis.maxItems(cns);
string i = "i" + arrayDepth.ToString();
string prefix = "";
bool topLevel = !varName.Contains("->");
if (topLevel)
prefix = varName + "->";
else
{
prefix = varName + ".";
}
ArrayValue arVal = defauleVal as ArrayValue;
if (arVal == null)
{
c.P(lev);
c.WriteLine("{0}nCount = 0;", prefix);
c.P(lev); c.WriteLine("for({0}=0;{0}<{1};{0}++)", i, pThis.maxItems(cns));
c.P(lev); c.WriteLine("{");
((ISCCType)pThis.m_type).PrintCInitialize(pThis.m_type.PEREffectiveConstraint, pThis.m_type.GetOneValidValue(), c,
typeName + "_arr", prefix + "arr[" + i + "]", lev + 1, arrayDepth + 1);
c.P(lev); c.WriteLine("}");
}
else
{
c.P(lev);
c.WriteLine("{0}nCount = {1};", prefix, arVal.m_children.Count);
for (int k = 0; k < arVal.m_children.Count; k++)
{
c.P(lev); c.WriteLine("{");
((ISCCType)pThis.m_type).PrintCInitialize(pThis.m_type.PEREffectiveConstraint, arVal.m_children[k], c,
typeName + "_arr", prefix + "arr[" + k.ToString() + "]", lev + 1, arrayDepth + 1);
c.P(lev); c.WriteLine("}");
}
}
}
开发者ID:kia92798,项目名称:tinyasn1,代码行数:40,代码来源:SCCArray.cs
示例18: TestIsValue
public void TestIsValue()
{
object[][] values = new object[][]
{
new object[] {new int[4], true, "int[4]" },
new object[] {new bool[4], false , "bool[4]"},
new object[] {new int[2,2] {{1, 2},{3,4}}, false, "int[2,2] {{1, 2},{3,4}}"},
new object[] {new int[][] {new int[] {1,2},new int[] {3,4}}, false, "int[] {1,2},new int[] {3,4}}"},
new object[] {new object[] {1,2}, true, "object[] {1,2}"},
new object[] {new object[] {1,true}, false, "object[] {1,true}"},
new object[] {new object[] {1,null}, true, "object[] {1,null}"},
new object[] {new object[,] {{1,2},{3,4}}, false, "object[,] {{1,2},{3,4}}"},
};
ArrayType type = new ArrayType(1, SimpleType.Integer);
for (int i = 0; i < values.Length; i++)
{
object value = values[i][0];
bool result = (bool)values[i][1];
string descr = (string) values[i][2];
Assert.AreEqual(result, type.IsValue(value), descr);
}
}
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:22,代码来源:ArrayTypeTests.cs
示例19: LoadSystemTypes
public void LoadSystemTypes()
{
var mscorlib = AssemblyResolver.Resolve("mscorlib");
var typeType = mscorlib.MainModule.Types.FirstOrDefault(x => x.Name == "Type");
if (typeType == null)
{
var runtime = AssemblyResolver.Resolve("System.Runtime");
typeType = runtime.MainModule.Types.First(x => x.Name == "Type");
}
var funcDefinition = typeType.Module.Types.First(x => x.Name == "Func`1");
var genericInstanceType = new GenericInstanceType(funcDefinition);
genericInstanceType.GenericArguments.Add(ModuleDefinition.TypeSystem.String);
GenericFunc = ModuleDefinition.ImportReference(genericInstanceType);
var methodReference = new MethodReference("Invoke", funcDefinition.FindMethod("Invoke").ReturnType, genericInstanceType) { HasThis = true };
FuncInvokeMethod = ModuleDefinition.ImportReference(methodReference);
GetTypeFromHandle = typeType.Methods
.First(x => x.Name == "GetTypeFromHandle" &&
x.Parameters.Count == 1 &&
x.Parameters[0].ParameterType.Name == "RuntimeTypeHandle");
GetTypeFromHandle = ModuleDefinition.ImportReference(GetTypeFromHandle);
var stringType = ModuleDefinition.TypeSystem.String.Resolve();
ConcatMethod = ModuleDefinition.ImportReference(stringType.FindMethod("Concat", "String", "String"));
FormatMethod = ModuleDefinition.ImportReference(stringType.FindMethod("Format", "String", "Object[]"));
ObjectArray = new ArrayType(ModuleDefinition.TypeSystem.Object);
var exceptionType = mscorlib.MainModule.Types.FirstOrDefault(x => x.Name == "Exception");
if (exceptionType == null)
{
var runtime = AssemblyResolver.Resolve("System.Runtime");
exceptionType = runtime.MainModule.Types.First(x => x.Name == "Exception");
}
ExceptionType = ModuleDefinition.ImportReference(exceptionType);
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:38,代码来源:SystemTypesResolver.cs
示例20: VisitArrayType
public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
{
if (!VisitType(array, quals))
return false;
switch (array.SizeType)
{
case ArrayType.ArraySize.Constant:
var supportBefore = Context.SupportBefore;
supportBefore.WriteLine("if ({0} != nullptr)", Context.ArgName);
supportBefore.WriteStartBraceIndent();
supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size);
supportBefore.WriteLineIndent("{0}[i] = {1}[i]{2};",
Context.ReturnVarName, Context.ArgName,
array.Type.IsPointerToPrimitiveType(PrimitiveType.Void) ? ".ToPointer()" : string.Empty);
supportBefore.WriteCloseBraceIndent();
break;
default:
Context.Return.Write("null");
break;
}
return true;
}
开发者ID:corefan,项目名称:CppSharp,代码行数:23,代码来源:CLIMarshal.cs
注:本文中的ArrayType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论