@@ -380,6 +380,38 @@ SwiftInt SILType_isEnum(BridgedType type) {
380380 return castToSILType (type).getEnumOrBoundGenericEnum () ? 1 : 0 ;
381381}
382382
383+ SwiftInt SILType_getNumTupleElements (BridgedType type) {
384+ TupleType *tupleTy = castToSILType (type).castTo <TupleType>();
385+ return tupleTy->getNumElements ();
386+ }
387+
388+ BridgedType SILType_getTupleElementType (BridgedType type, SwiftInt elementIdx) {
389+ SILType ty = castToSILType (type);
390+ SILType elmtTy = ty.getTupleElementType ((unsigned )elementIdx);
391+ return {elmtTy.getOpaqueValue ()};
392+ }
393+
394+ SwiftInt SILType_getNumNominalFields (BridgedType type) {
395+ SILType silType = castToSILType (type);
396+ auto *nominal = silType.getNominalOrBoundGenericNominal ();
397+ assert (nominal && " expected nominal type" );
398+ return getNumFieldsInNominal (nominal);
399+ }
400+
401+ BridgedType SILType_getNominalFieldType (BridgedType type, SwiftInt index,
402+ BridgedFunction function) {
403+ SILType silType = castToSILType (type);
404+ SILFunction *silFunction = castToFunction (function);
405+
406+ NominalTypeDecl *decl = silType.getNominalOrBoundGenericNominal ();
407+ VarDecl *field = getIndexedField (decl, (unsigned )index);
408+
409+ SILType fieldType = silType.getFieldType (
410+ field, silFunction->getModule (), silFunction->getTypeExpansionContext ());
411+
412+ return {fieldType.getOpaqueValue ()};
413+ }
414+
383415SwiftInt SILType_getFieldIdxOfNominalType (BridgedType type,
384416 BridgedStringRef fieldName) {
385417 SILType ty = castToSILType (type);
@@ -408,38 +440,6 @@ SwiftInt SILType_getFieldIdxOfNominalType(BridgedType type,
408440 return -1 ;
409441}
410442
411- SwiftInt SILType_getNumTupleElements (BridgedType type) {
412- TupleType *tupleTy = castToSILType (type).castTo <TupleType>();
413- return tupleTy->getNumElements ();
414- }
415-
416- BridgedType SILType_getTupleElementType (BridgedType type, SwiftInt elementIdx) {
417- SILType ty = castToSILType (type);
418- SILType elmtTy = ty.getTupleElementType ((unsigned )elementIdx);
419- return {elmtTy.getOpaqueValue ()};
420- }
421-
422- SwiftInt SILType_getNumStructFields (BridgedType type) {
423- SILType silType = castToSILType (type);
424- StructDecl *decl =
425- cast<StructDecl>(silType.getNominalOrBoundGenericNominal ());
426- return decl->getStoredProperties ().size ();
427- }
428-
429- BridgedType SILType_getStructFieldType (BridgedType type, SwiftInt index,
430- BridgedFunction function) {
431- SILType silType = castToSILType (type);
432- SILFunction *silFunction = castToFunction (function);
433-
434- StructDecl *decl = cast<StructDecl>(silType.getNominalOrBoundGenericNominal ());
435- VarDecl *property = decl->getStoredProperties ()[index];
436-
437- SILType propertyType = silType.getFieldType (
438- property, silFunction->getModule (), TypeExpansionContext (*silFunction));
439-
440- return {propertyType.getOpaqueValue ()};
441- }
442-
443443// ===----------------------------------------------------------------------===//
444444// SILGlobalVariable
445445// ===----------------------------------------------------------------------===//
0 commit comments