本文整理汇总了C#中TypeNode.GetArrayType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.GetArrayType方法的具体用法?C# TypeNode.GetArrayType怎么用?C# TypeNode.GetArrayType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeNode
的用法示例。
在下文中一共展示了TypeNode.GetArrayType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PType
//.........这里部分代码省略.........
Get();
c = SystemTypes.Int32;
break;
}
case 14: {
Get();
c = SystemTypes.Int64;
break;
}
case 15: {
Get();
c = SystemTypes.UInt8;
break;
}
case 16: {
Get();
c = SystemTypes.UInt16;
break;
}
case 17: {
Get();
c = SystemTypes.UInt32;
break;
}
case 18: {
Get();
c = SystemTypes.UInt64;
break;
}
case 19: {
Get();
c = SystemTypes.Single;
break;
}
case 20: {
Get();
c = SystemTypes.Double;
break;
}
case 21: {
Get();
Expect(22);
PType(out modifier);
Expect(23);
PType(out modified);
Expect(24);
c = OptionalModifier.For(modifier,modified);
break;
}
case 25: {
Get();
Expect(22);
string id;
Ident(out id);
Expect(24);
c = LookupTypeParameter(id);
break;
}
case 26: {
Get();
Expect(22);
string id;
Ident(out id);
Expect(24);
c = LookupMethodTypeParameter(id);
break;
}
case 1: case 28: case 35: {
PTypeRef(out c);
break;
}
default: SynErr(109); break;
}
if (StartOf(1)) {
if (la.kind == 27) {
Get();
c = c.GetReferenceType();
} else if (la.kind == 28) {
Get();
Expect(29);
c = c.GetArrayType(1);
while (la.kind == 28) {
Get();
Expect(29);
c = c.GetArrayType(1);
}
} else if (la.kind == 22) {
Get();
PType(out c);
while (la.kind == 23) {
Get();
PType(out c);
}
Expect(24);
} else {
Get();
c = c.GetPointerType();
}
}
}
示例2: ParseArrayOrGenericType
private TypeNode/*!*/ ParseArrayOrGenericType(string typeName, TypeNode/*!*/ rootType)
{
if (typeName == null || rootType == null) { Debug.Assert(false); return rootType; }
//Get here after "rootType[" has been parsed. What follows is either an array type specifier or some generic type arguments.
if (typeName.Length == 0)
throw new InvalidMetadataException(ExceptionStrings.BadSerializedTypeName); //Something ought to follow the [
if (typeName[0] == ']')
{ //Single dimensional array with zero lower bound
if (typeName.Length == 1) return rootType.GetArrayType(1);
if (typeName[1] == '[' && typeName.Length > 2)
return this.ParseArrayOrGenericType(typeName.Substring(2), rootType.GetArrayType(1));
throw new InvalidMetadataException(ExceptionStrings.BadSerializedTypeName);
}
if (typeName[0] == '*')
{ //Single dimensional array with unknown lower bound
if (typeName.Length > 1 && typeName[1] == ']')
{
if (typeName.Length == 2) return rootType.GetArrayType(1, true);
if (typeName[2] == '[' && typeName.Length > 3)
return this.ParseArrayOrGenericType(typeName.Substring(3), rootType.GetArrayType(1, true));
}
throw new InvalidMetadataException(ExceptionStrings.BadSerializedTypeName);
}
if (typeName[0] == ',')
{ //Muti dimensional array
int rank = 1;
while (rank < typeName.Length && typeName[rank] == ',') rank++;
if (rank < typeName.Length && typeName[rank] == ']')
{
if (typeName.Length == rank + 1) return rootType.GetArrayType(rank + 1);
if (typeName[rank + 1] == '[' && typeName.Length > rank + 2)
return this.ParseArrayOrGenericType(typeName.Substring(rank + 2), rootType.GetArrayType(rank));
}
throw new InvalidMetadataException(ExceptionStrings.BadSerializedTypeName);
}
//Generic type instance
int offset = 0;
if (typeName[0] == '[') offset = 1; //Assembly qualified type name forming part of a generic parameter list
TypeNodeList arguments = new TypeNodeList();
int commaPos = FindFirstCommaOutsideBrackets(typeName);
while (commaPos > 1)
{
arguments.Add(this.GetTypeFromSerializedName(typeName.Substring(offset, commaPos - offset)));
typeName = typeName.Substring(commaPos + 1);
offset = typeName[0] == '[' ? 1 : 0;
commaPos = FindFirstCommaOutsideBrackets(typeName);
}
//Find the position of the first unbalanced ].
int lastCharPos = offset;
for (int leftBracketCount = 0; lastCharPos < typeName.Length; lastCharPos++)
{
char ch = typeName[lastCharPos];
if (ch == '[') leftBracketCount++;
else if (ch == ']')
{
leftBracketCount--;
if (leftBracketCount < 0) break;
}
}
arguments.Add(this.GetTypeFromSerializedName(typeName.Substring(offset, lastCharPos - offset)));
TypeNode retVal = rootType.GetGenericTemplateInstance(this.module, arguments);
if (lastCharPos + 1 < typeName.Length && typeName[lastCharPos + 1] == ']')
lastCharPos++;
if (lastCharPos + 1 < typeName.Length)
{
//The generic type is complete, but there is yet more to the type
char ch = typeName[lastCharPos + 1];
if (ch == '+') retVal = this.GetTypeFromSerializedName(typeName.Substring(lastCharPos + 2), retVal);
if (ch == '&') retVal = retVal.GetReferenceType();
if (ch == '*') retVal = retVal.GetPointerType();
if (ch == '[') retVal = this.ParseArrayOrGenericType(typeName.Substring(lastCharPos + 2, typeName.Length - 1 - lastCharPos - 1), retVal);
}
return retVal;
}
示例3: Setup
public void Setup(AssemblyNode mscorlib, AssemblyNode jsTypes, AssemblyNode rewriteAssembly)
{
NumWarnings = 0;
NumErrors = 0;
MsCorLib = mscorlib;
AssemblyDelaySignAttributeType = GetType(mscorlib, "System.Reflection", "AssemblyDelaySignAttribute");
VoidType = GetType(mscorlib, "System", "Void");
ObjectType = GetType(mscorlib, "System", "Object");
StringType = GetType(mscorlib, "System", "String");
IntType = GetType(mscorlib, "System", "Int32");
BooleanType = GetType(mscorlib, "System", "Boolean");
MethodBaseType = GetType(mscorlib, "System.Reflection", "MethodBase");
RuntimeTypeHandleType = GetType(mscorlib, "System", "RuntimeTypeHandle");
NullableTypeConstructor = GetType(mscorlib, "System", "Nullable`1");
CompilerGeneratedAttributeType = GetType
(mscorlib, "System.Runtime.CompilerServices", "CompilerGeneratedAttribute");
DllImportAttributeType = GetType(mscorlib, "System.Runtime.InteropServices", "DllImportAttribute");
TypeType = GetType(mscorlib, "System", "Type");
Type_GetMethodMethod = GetMethod(TypeType, "GetMethod", StringType, TypeType.GetArrayType(1));
Type_GetMemberMethod = GetMethod(TypeType, "GetMember", StringType);
Type_GetConstructorMethod = GetMethod(TypeType, "GetConstructor", TypeType.GetArrayType(1));
Type_GetTypeFromHandleMethod = GetMethod(TypeType, "GetTypeFromHandle", RuntimeTypeHandleType);
Type_GetGenericArgumentsMethod = GetMethod(TypeType, "GetGenericArguments");
Type_MakeArrayTypeMethod = GetMethod(TypeType, "MakeArrayType");
Type_MakeGenericTypeMethod = GetMethod(TypeType, "MakeGenericType", TypeType.GetArrayType(1));
InteropTypes = new InteropTypes(this);
InteropManager = new InteropManager(this);
IgnoreAttributeType = GetType(jsTypes, Constants.JSTypesIL2JSNS, "IgnoreAttribute");
InteropAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "InteropAttribute");
NamingAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "NamingAttribute");
ImportAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "ImportAttribute");
ImportKeyAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "ImportKeyAttribute");
ExportAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "ExportAttribute");
NotExportedAttributeType = GetType(jsTypes, Constants.JSTypesInteropNS, "NotExportedAttribute");
InteropGeneratedAttributeType = GetType(jsTypes, Constants.JSTypesIL2JSNS, "InteropGeneratedAttribute");
JSTypes = jsTypes;
JSContextType = GetType(jsTypes, Constants.JSTypesInteropNS, "JSContext");
InteropContextManagerType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "InteropContextManager");
InteropContextManager_GetDatabaseMethod = GetMethod(InteropContextManagerType, "get_Database");
InteropContextManager_GetCurrentRuntimeMethod = GetMethod(InteropContextManagerType, "get_CurrentRuntime");
InteropContextManager_GetRuntimeForObjectMethod = GetMethod
(InteropContextManagerType, "GetRuntimeForObject", ObjectType);
InteropDatabaseType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "InteropDatabase");
InteropDatabase_RegisterRootExpression = GetMethod(InteropDatabaseType, "RegisterRootExpression", StringType);
InteropDatabase_RegisterDelegateShimMethod = GetMethod
(InteropDatabaseType, "RegisterDelegateShim", TypeType);
InteropDatabase_RegisterTypeMethod = GetMethod
(InteropDatabaseType,
"RegisterType",
TypeType,
IntType,
StringType,
StringType,
IntType,
BooleanType,
BooleanType,
BooleanType);
InteropDatabase_RegisterExportMethod = GetMethod
(InteropDatabaseType, "RegisterExport", MethodBaseType, BooleanType, StringType);
SimpleMethodBaseType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "SimpleMethodBase");
SimpleMethodInfoType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "SimpleMethodInfo");
SimpleMethodInfo_Ctor = GetConstructor
(SimpleMethodInfoType, BooleanType, StringType, TypeType, TypeType.GetArrayType(1), TypeType);
SimpleConstructorInfoType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "SimpleConstructorInfo");
SimpleConstructorInfo_Ctor = GetConstructor(SimpleConstructorInfoType, TypeType, TypeType.GetArrayType(1));
RuntimeType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "Runtime");
Runtime_CompleteConstructionMethod = GetMethod
(RuntimeType, "CompleteConstruction", SimpleMethodBaseType, ObjectType, JSContextType);
Runtime_CallImportedMethodMethod = GetMethod
(RuntimeType, "CallImportedMethod", SimpleMethodBaseType, StringType, ObjectType.GetArrayType(1));
UniversalDelegateType = GetType(jsTypes, Constants.JSTypesManagedInteropNS, "UniversalDelegate");
UniversalDelegate_InvokeMethod = GetUniqueMethod(UniversalDelegateType, "Invoke");
MethodBase_GetGenericArgumentsMethod = GetMethod(MethodBaseType, "GetGenericArguments");
ModuleType = GetType(rewriteAssembly, "", "<Module>");
foreach (var member in ModuleType.Members)
{
var cctor = member as StaticInitializer;
if (cctor != null)
ModuleCCtorMethod = cctor;
}
}
示例4: ArrayExpression
public Expression ArrayExpression(ExpressionList expressions, TypeNode arrayElementType)
{
var clrElementType = arrayElementType;
var enumElementType = clrElementType as EnumNode;
if (enumElementType != null)
clrElementType = enumElementType.UnderlyingType;
if (expressions == null)
// null;
return new Literal(null, arrayElementType.GetArrayType(1));
else
{
// newarr <expressions.length>;
var statements = new StatementList();
statements.Add
(new ExpressionStatement
(new ConstructArray
(arrayElementType, new ExpressionList(new Literal(expressions.Count)), null)));
var arrayType = arrayElementType.GetArrayType(1);
for (var i = 0; i < expressions.Count; i++)
{
// dup;
// <i>;
// <expressions[i]>;
// stelem;
statements.Add
(new AssignmentStatement
(new Indexer
(new Expression(NodeType.Dup, arrayType),
new ExpressionList(new Literal(i)),
clrElementType),
expressions[i]));
}
// leave array on stack
return new BlockExpression(new Block(statements));
}
}