本文整理汇总了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;
}
}
示例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());
}
}
示例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());
}
}
示例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;
}