apple/swift - include/swift/AST コードリーディング(全体)
概要
swift/include/swift/AST at c309fb2620b030a722741171baee4dfec5017d58 · apple/swift · GitHub
- 概要
- AST.h
- ASTContext.h
- ASTMangler.h
- ASTNode.h
- ASTPrinter.h
- ASTScope.h
- ASTVisitor.h
- ASTWalker.h
- AccessScope.h
- AnyFunctionRef.h
- Attr.def
- Attr.h
- AttrKind.h
- Availability.h
- AvailabilitySpec.h
- Builtins.def
- Builtins.h
- CanTypeVisitor.h
- CaptureInfo.h
- ClangModuleLoader.h
- ClangNode.h
- Comment.h
- ConcreteDeclRef.h
- DebuggerClient.h
- Decl.h
- DeclContext.h
- DeclNameLoc.h
- DeclNodes.def
- DefaultArgumentKind.h
- DiagnosticEngine.h
- DiagnosticsAll.def
- DiagnosticsClangImporter.def
- DiagnosticsClangImporter.h
- DiagnosticsCommon.def
- DiagnosticsCommon.h
- DiagnosticsDriver.def
- DiagnosticsDriver.h
- DiagnosticsFrontend.def
- DiagnosticsFrontend.h
- DiagnosticsIRGen.def
- DiagnosticsIRGen.h
- DiagnosticsParse.def
- DiagnosticsParse.h
- DiagnosticsSIL.def
- DiagnosticsSIL.h
- DiagnosticsSema.def
- DiagnosticsSema.h
- Expr.h
- ExprNodes.def
- ForeignErrorConvention.h
- FunctionRefKind.h
- GenericEnvironment.h
- GenericParamKey.h
- GenericSignature.h
- GenericSignatureBuilder.h
- IRGenOptions.h
- Identifier.h
- Initializer.h
- KnownDecls.def
- KnownFoundationEntities.def
- KnownIdentifiers.def
- KnownProtocols.def
- KnownProtocols.h
- KnownStdlibTypes.def
- LayoutConstraint.h
- LazyResolver.h
- LinkLibrary.h
- LookupKinds.h
- Mangle.h
- Module.h
- ModuleLoader.h
- NameLookup.h
- Ownership.h
- ParameterList.h
- Pattern.h
- PatternNodes.def
- PlatformKind.h
- PlatformKinds.def
- PrettyStackTrace.h
- PrintOptions.h
- ProtocolConformance.h
- ProtocolConformanceRef.h
- RawComment.h
- ReferencedNameTracker.h
- Requirement.h
- ResilienceExpansion.h
- SILLayout.h
- SILOptions.h
- SearchPathOptions.h
- SourceEntityWalker.h
- Stmt.h
- StmtNodes.def
- Substitution.h
- SubstitutionList.h
- SubstitutionMap.h
- Type.h
- TypeAlignments.h
- TypeCheckerDebugConsumer.h
- TypeLoc.h
- TypeMatcher.h
- TypeMemberVisitor.h
- TypeNodes.def
- TypeRefinementContext.h
- TypeRepr.h
- TypeReprNodes.def
- TypeVisitor.h
- TypeWalker.h
- Types.h
- USRGeneration.h
- Witness.h
AST.h
FIXME: おそらくアンブレラヘッダー
#ifndef SWIFT_AST_H #define SWIFT_AST_H #include "swift/AST/ASTContext.h" #include "swift/AST/AvailabilitySpec.h" #include "swift/AST/Builtins.h" #include "swift/AST/Decl.h" #include "swift/AST/Expr.h" #include "swift/AST/Module.h" #include "swift/AST/ParameterList.h" #include "swift/AST/Pattern.h" #include "swift/AST/Stmt.h" #include "swift/AST/Types.h" #include "swift/AST/TypeRepr.h" #endif
ASTContext.h
AllocationArena
FIXME: C++のArena Allocationのことを指している?
definition | desc |
---|---|
Permanent | ASTContextのライフタイムに縛られている永続的なArena 全てのグローバル宣言と型をこのArenaに割り当てる必要がある。 現時点では型変数を含まない型の全てがこのArenaに割り当てられる |
ConstraintSolver | xxx 型変数を含む型は全てこのArenaに割り当てれる |
KnownFoundationEntity
KnownFoundationEntities.defを参照しマクロにより定義を展開
enum class KnownFoundationEntity { #define FOUNDATION_ENTITY(Name) Name, #include "swift/AST/KnownFoundationEntities.def" };
ASTContext
ASTContext(LangOptions &langOpts, SearchPathOptions &SearchPathOpts, SourceManager &SourceMgr, DiagnosticEngine &Diags)
ASTMangler.h
ASTNode.h
ASTPrinter.h
ASTScope.h
ASTVisitor.h
ASTWalker.h
AccessScope.h
AnyFunctionRef.h
Attr.def
Swiftで使えるattributeの一覧がマクロを駆使して定義されている
必須マクロ定義
#ifndef DECL_ATTR #define DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE) #endif #ifndef SIMPLE_DECL_ATTR #define SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) DECL_ATTR(X, CLASS, OPTIONS, CODE) #endif #ifndef DECL_ATTR_ALIAS #define DECL_ATTR_ALIAS(SPELLING, CLASS) #endif #ifndef TYPE_ATTR #define TYPE_ATTR(X) #endif
型attribute
attribute |
---|
autoclosure |
convention |
noreturn |
noescape |
escaping |
SIL特有の型attribute
attribute |
---|
block_storage |
box |
dynamic_self |
sil_unowned |
sil_unmanaged |
sil_weak |
error |
out |
in |
inout |
inout_aliasable |
in_guaranteed |
in_constant |
owned |
unowned_inner_pointer |
guaranteed |
autoreleased |
callee_owned |
callee_guaranteed |
objc_metatype |
opened |
pseudogeneric |
yields |
yield_once |
yield_many |
SILメタタイプの型attribute
attribute |
---|
thin |
thick |
DECL_ATTRスキーマ
DECL_ATTR
- SPELLING
- attribute名、この定義が実際にSwiftのコードで使える名前となる
- CLASS
- attributeに紐付くクラス名、クラス定義は
{クラス名}Attr
となる
- attributeに紐付くクラス名、クラス定義は
- OPTIONS
- attributeのオプション
- attributeが表示される宣言
- 重複が許されるかどうか
- attributeがdecl修飾子かどうか (@なし)
- attributeのオプション
- CODE
- シリアル化に使用される一意のattribute識別子
- これは決して変更できない
- SPELLING
Attr.h
AttrKind.h
Availability.h
AvailabilitySpec.h
Builtins.def
Builtins.h
CanTypeVisitor.h
CaptureInfo.h
ClangModuleLoader.h
ClangNode.h
Comment.h
ConcreteDeclRef.h
DebuggerClient.h
Decl.h
DeclContext.h
DeclNameLoc.h
DeclNodes.def
DefaultArgumentKind.h
DiagnosticEngine.h
DiagnosticsAll.def
DiagnosticsClangImporter.def
DiagnosticsClangImporter.h
DiagnosticsCommon.def
DiagnosticsCommon.h
DiagnosticsDriver.def
DiagnosticsDriver.h
DiagnosticsFrontend.def
DiagnosticsFrontend.h
DiagnosticsIRGen.def
DiagnosticsIRGen.h
DiagnosticsParse.def
DiagnosticsParse.h
DiagnosticsSIL.def
DiagnosticsSIL.h
DiagnosticsSema.def
DiagnosticsSema.h
Expr.h
ExprNodes.def
ForeignErrorConvention.h
FunctionRefKind.h
GenericEnvironment.h
GenericParamKey.h
GenericSignature.h
GenericSignatureBuilder.h
IRGenOptions.h
Identifier.h
Initializer.h
KnownDecls.def
KnownFoundationEntities.def
#ifndef FOUNDATION_ENTITY # error define FOUNDATION_ENTITY(Name) #endif FOUNDATION_ENTITY(NSArray) FOUNDATION_ENTITY(NSCopying) FOUNDATION_ENTITY(NSDictionary) FOUNDATION_ENTITY(NSError) FOUNDATION_ENTITY(NSErrorPointer) FOUNDATION_ENTITY(NSInteger) FOUNDATION_ENTITY(NSNumber) FOUNDATION_ENTITY(NSObject) FOUNDATION_ENTITY(NSRange) FOUNDATION_ENTITY(NSSet) FOUNDATION_ENTITY(NSString) FOUNDATION_ENTITY(NSUInteger) FOUNDATION_ENTITY(NSURL) FOUNDATION_ENTITY(NSValue) FOUNDATION_ENTITY(NSZone) #undef FOUNDATION_ENTITY
KnownIdentifiers.def
#ifndef IDENTIFIER_WITH_NAME # error Must define IDENTIFIER_WITH_NAME(Name, IdStr) before including this x-macro file #endif #define IDENTIFIER(name) IDENTIFIER_WITH_NAME(name, #name) #define IDENTIFIER_(name) IDENTIFIER_WITH_NAME(name, "_" #name) IDENTIFIER(alloc) IDENTIFIER(allocWithZone) IDENTIFIER(allZeros) IDENTIFIER(Any) IDENTIFIER(atIndexedSubscript) IDENTIFIER_(bridgeToObjectiveC) IDENTIFIER_WITH_NAME(code_, "_code") IDENTIFIER(CoreGraphics) IDENTIFIER(CoreMedia) IDENTIFIER(CGFloat) IDENTIFIER(CVarArg) IDENTIFIER(Darwin) IDENTIFIER(dealloc) IDENTIFIER(deinit) IDENTIFIER(Element) IDENTIFIER(error) IDENTIFIER(forKeyedSubscript) IDENTIFIER(Foundation) IDENTIFIER(fromRaw) IDENTIFIER(hashValue) IDENTIFIER(init) IDENTIFIER(initialize) IDENTIFIER(initStorage) IDENTIFIER(initialValue) IDENTIFIER(Key) IDENTIFIER(makeIterator) IDENTIFIER(Iterator) IDENTIFIER(load) IDENTIFIER(next) IDENTIFIER(none) IDENTIFIER_(nsErrorDomain) IDENTIFIER(objectAtIndexedSubscript) IDENTIFIER(objectForKeyedSubscript) IDENTIFIER(ObjectiveC) IDENTIFIER_(ObjectiveCType) IDENTIFIER_(OptionalNilComparisonType) IDENTIFIER(parameter) IDENTIFIER(Protocol) IDENTIFIER(rawValue) IDENTIFIER(RawValue) IDENTIFIER(Selector) IDENTIFIER(self) IDENTIFIER(Self) IDENTIFIER(setObject) IDENTIFIER(simd) IDENTIFIER(some) IDENTIFIER(storage) IDENTIFIER(subscript) IDENTIFIER(SwiftObject) IDENTIFIER(toRaw) IDENTIFIER(Type) IDENTIFIER(Value) IDENTIFIER(value) IDENTIFIER_WITH_NAME(value_, "_value") IDENTIFIER(with) // Kinds of layout constraints IDENTIFIER_WITH_NAME(UnknownLayout, "_UnknownLayout") IDENTIFIER_WITH_NAME(TrivialLayout, "_Trivial") IDENTIFIER_WITH_NAME(TrivialAtMostLayout, "_TrivialAtMost") IDENTIFIER_WITH_NAME(RefCountedObjectLayout, "_RefCountedObject") IDENTIFIER_WITH_NAME(NativeRefCountedObjectLayout, "_NativeRefCountedObject") // Operators IDENTIFIER_WITH_NAME(MatchOperator, "~=") IDENTIFIER_WITH_NAME(EqualsOperator, "==") // Precedence groups IDENTIFIER(AssignmentPrecedence) IDENTIFIER(CastingPrecedence) IDENTIFIER(DefaultPrecedence) IDENTIFIER(FunctionArrowPrecedence) IDENTIFIER(TernaryPrecedence) // Builtins and literals IDENTIFIER_(MaxBuiltinIntegerType) IDENTIFIER(IntegerLiteralType) IDENTIFIER(nilLiteral) IDENTIFIER(integerLiteral) IDENTIFIER_(builtinIntegerLiteral) IDENTIFIER_(MaxBuiltinFloatType) IDENTIFIER(FloatLiteralType) IDENTIFIER(floatLiteral) IDENTIFIER_(builtinFloatLiteral) IDENTIFIER(BooleanLiteralType) IDENTIFIER_(builtinBooleanLiteral) IDENTIFIER(booleanLiteral) IDENTIFIER(ExtendedGraphemeClusterLiteralType) IDENTIFIER_(builtinExtendedGraphemeClusterLiteral) IDENTIFIER(extendedGraphemeClusterLiteral) IDENTIFIER(UnicodeScalarLiteralType) IDENTIFIER_(builtinUnicodeScalarLiteral) IDENTIFIER(unicodeScalarLiteral) IDENTIFIER(stringLiteral) IDENTIFIER_(builtinUTF16StringLiteral) IDENTIFIER_(builtinStringLiteral) IDENTIFIER(StringLiteralType) IDENTIFIER(stringInterpolation) IDENTIFIER(stringInterpolationSegment) IDENTIFIER(arrayLiteral) IDENTIFIER(dictionaryLiteral) IDENTIFIER_(getBuiltinLogicValue) IDENTIFIER(className) IDENTIFIER_(ErrorType) IDENTIFIER(Code) IDENTIFIER_(nsError) #undef IDENTIFIER #undef IDENTIFIER_ #undef IDENTIFIER_WITH_NAME
KnownProtocols.def
KnownProtocols.h
KnownStdlibTypes.def
LayoutConstraint.h
LazyResolver.h
LinkLibrary.h
LookupKinds.h
Mangle.h
Module.h
ModuleLoader.h
NameLookup.h
Ownership.h
ParameterList.h
Pattern.h
PatternNodes.def
PlatformKind.h
PlatformKinds.def
PrettyStackTrace.h
PrintOptions.h
ProtocolConformance.h
ProtocolConformanceRef.h
RawComment.h
ReferencedNameTracker.h
Requirement.h
ResilienceExpansion.h
SILLayout.h
SILOptions.h
SearchPathOptions.h
SourceEntityWalker.h
Stmt.h
StmtNodes.def
Substitution.h
SubstitutionList.h
SubstitutionMap.h
Type.h
ForeignLanguage
definition | desc |
---|---|
C | C言語 |
ObjectiveC | Objective-C |
Swiftがブリッジされる可能性のある外部言語
ForeignRepresentableKind
definition | desc |
---|---|
None | このタイプは外部言語では表現できない |
Trivial | このタイプは外部言語で自明に表現可能である |
Object | このタイプは外部言語でオブジェクトとして表現できる |
Bridged | このタイプはbridgingを介して外部言語で表現することができる |
BridgedError | このタイプはエラーのbridgingを介して外部言語で表現できる |
StaticBridged | このタイプは静的なbridgingコードを介してのみ外部言語で表現できる(実行時には使用できない) |
特定のタイプを外部言語でどのように表現できるかを説明する
Type
これは型クラスへのポインタを含む単純な値オブジェクト。
This is potentially sugared.
コードベース全体でこれを生のTypeBase
代わりに使用して、同等性の比較を無効にする。
これは糖衣的な型では安全でない。
CanType
静的にカノニカルであることが知られているタイプ
これらのいずれかを取得するには、Type->getCanonicalType()
を使用する
すべてのCanTypeは 'Type'として使用することができる(単に糖衣を含まない)
Typeから派生している
TypeAlignments.h
TypeCheckerDebugConsumer.h
TypeLoc.h
TypeMatcher.h
TypeMemberVisitor.h
TypeNodes.def
TypeRefinementContext.h
TypeRepr.h
TypeReprNodes.def
TypeVisitor.h
TypeWalker.h
Types.h
TypeKind
メモ:TypeNodes.defをマクロ展開してる
RecursiveTypeProperties::Property
単一のプロパティ
Note that the property polarities should be chosen so that 0 is the correct default value and bitwise-or correctly merges things.
- プロパティの極性[?property polarities]
definition | desc |
---|---|
HasTypeVariable | TypeVariableTypeが含まれる |
HasArchetype | ArchetypeTypeが含まれる |
HasTypeParameter | GenericTypeParamTypeが含まれる |
HasUnresolvedType | UnresolvedTypeが含まれる |
HasUnboundGeneric | バインドされていない[?unbound]ジェネリクス型が含まれるかどうか |
IsLValue | This type expression contains an LValueType other than as a function input, and can be loaded to convert to an rvalue |
HasOpenedExistential | 開かれたexistentialなArchetypeTypeを含む |
HasDynamicSelf | DynamicSelf型が含まれる |
HasError | エラー型が含まれる |
HasDependentMember | DependentMemberTypeが含まれる |