当前位置: 首页>>代码示例>>C#>>正文


C# TypeInfo.getTypeKind方法代码示例

本文整理汇总了C#中TypeInfo.getTypeKind方法的典型用法代码示例。如果您正苦于以下问题:C# TypeInfo.getTypeKind方法的具体用法?C# TypeInfo.getTypeKind怎么用?C# TypeInfo.getTypeKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeInfo的用法示例。


在下文中一共展示了TypeInfo.getTypeKind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getReturnOpcode

 static Opcode getReturnOpcode(TypeInfo type) {
     switch (type.getTypeKind()) {
     case Boolean:
     case Byte:
     case Char:
     case Short:
     case Int:
         return Opcode.Ireturn;
     case Double:
         return Opcode.Dreturn;
     case Float:
         return Opcode.Freturn;
     case Long:
         return Opcode.Lreturn;
     case Void:
         return Opcode.Return;
     default:
         return Opcode.Areturn;
     }
 }
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:20,代码来源:BytecodeHelper.stab.cs

示例2: sameTypes

		private static bool sameTypes(TypeInfo oldType, TypeInfo newType) {
			switch (oldType.TypeKind) {
			case Boolean:
			case Byte:
			case Char:
			case Double:
			case Float:
			case Int:
			case Long:
			case Short:
			case Void:
			case UnboundedWildcard:
				return oldType.TypeKind == newType.TypeKind;
				
			case Array:
				if (newType.TypeKind != TypeKind.Array) {
					return false;
				}
				return sameTypes(oldType.ElementType, newType.ElementType);
				
			case LowerBoundedWildcard:
			case UpperBoundedWildcard:
				if (newType.TypeKind != oldType.TypeKind) {
					return false;
				}
				return sameTypes(oldType.WildcardBound, newType.WildcardBound);
				
			case GenericParameter:
				if (newType.TypeKind != TypeKind.GenericParameter) {
					return false;
				}
				return oldType.FullName.equals(newType.FullName);
				
			case Reference:
				if (newType.TypeKind != TypeKind.Reference) {
					return false;
				}
				if (oldType.OriginalTypeDefinition.FullName.equals(newType.OriginalTypeDefinition.FullName)) {
					if (oldType.GenericArguments.count() == newType.GenericArguments.count()) {
						var it1 = oldType.GenericArguments.iterator();
						var it2 = newType.GenericArguments.iterator();
						while (it1.hasNext()) {
							if (!sameTypes(it1.next(), it2.next())) {
								return false;
							}
						}
						return true;
					}
				}
				return false;
				
			default:
				throw new RuntimeException("Internal error " + oldType.getTypeKind());
			}
		}
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:55,代码来源:JvmTypeSystemHelper.stab.cs

示例3: getType

		private static TypeInfo getType(Library typeSystem, TypeInfo type, Scope<String, TypeInfo> genericArgs) {
			switch (type.TypeKind) {
			case Boolean:
			case Byte:
			case Char:
			case Double:
			case Float:
			case Int:
			case Long:
			case Short:
			case Void:
				return typeSystem.getPrimitiveType(type.TypeKind);
				
			case Reference:
				TypeInfo result;
				if (type.DeclaringType == null) {
					result = typeSystem.getType(type.OriginalTypeDefinition.FullName);
				} else {
					result = getType(typeSystem, type.DeclaringType, genericArgs).getNestedType(type.Name);
				}
				if (type != type.OriginalTypeDefinition) {
					result = typeSystem.getGenericType(result, type.GenericArguments.select(p => getType(typeSystem, p, genericArgs)).toList());
				}
				if (result == null) {
					throw new IllegalStateException("Type not found in target file system: " + type.FullName);
				}
				return result;
				
			case UnboundedWildcard:
				return typeSystem.UnboundedWildcard;
				
			case LowerBoundedWildcard:
				return getType(typeSystem, type.WildcardBound, genericArgs).LowerBoundedWildcard;
				
			case UpperBoundedWildcard:
				return getType(typeSystem, type.WildcardBound, genericArgs).UpperBoundedWildcard;
				
			case Array:
				return getType(typeSystem, type.ElementType, genericArgs).ArrayType;
				
			case GenericParameter:
				return genericArgs.getBindingValue(type.FullName);
			default:
				throw new RuntimeException("Internal error " + type.getTypeKind());
			}
		}
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:46,代码来源:JvmTypeSystemHelper.stab.cs

示例4: declareLocal

 public LocalInfo declareLocal(TypeInfo type, String name, bool mark) {
     checkCreated();
     var currentScope = this.scopes[this.scopes.size() - 1];
     var result = new LocalInfo(type, name, currentScope.localIndex, null, currentScope.endLabel);
     switch (type.getTypeKind()) {
     case Long:
     case Double:
         currentScope.localIndex += 2;
         break;
     default:
         currentScope.localIndex++;
         break;
     }
     locals.add(result);
     currentScope.locals[name] = result;
 
     if (mark) {
         if (result.beginLabel == null) {
             if (instructions[instructions.size() - 1].Opcode == Opcode.LabelMarker) {
                 result.beginLabel = ((LabelMarker)instructions[instructions.size() - 1]).Label;
             } else {
                 result.beginLabel = new Label();
                 instructions.add(new LabelMarker(result.beginLabel));
             }
         }
     }
     return result;
 }
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:28,代码来源:CodeGenerator.stab.cs


注:本文中的TypeInfo.getTypeKind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。