|
6 | 6 | #include "swift/AST/Expr.h" |
7 | 7 | #include "swift/AST/GenericParamList.h" |
8 | 8 | #include "swift/AST/Identifier.h" |
| 9 | +#include "swift/AST/Pattern.h" |
9 | 10 | #include "swift/AST/ParameterList.h" |
10 | 11 | #include "swift/AST/Stmt.h" |
11 | 12 | #include "swift/AST/TypeRepr.h" |
@@ -139,12 +140,19 @@ void *SwiftBooleanLiteralExpr_create(void *ctx, bool value, void *TokenLoc) { |
139 | 140 | } |
140 | 141 |
|
141 | 142 | void *SwiftVarDecl_create(void *ctx, BridgedIdentifier _Nullable nameId, |
| 143 | + void *initExpr, |
142 | 144 | void *loc, bool isStatic, bool isLet, void *dc) { |
143 | 145 | ASTContext &Context = *static_cast<ASTContext *>(ctx); |
144 | 146 | auto name = (UnresolvedDeclRefExpr *)nameId; |
145 | | - return new (Context) VarDecl( |
| 147 | + auto sourceLoc = getSourceLocFromPointer(loc); |
| 148 | + auto varDecl = new (Context) VarDecl( |
146 | 149 | isStatic, isLet ? VarDecl::Introducer::Let : VarDecl::Introducer::Var, |
147 | | - getSourceLocFromPointer(loc), name->getName().getBaseIdentifier(), |
| 150 | + sourceLoc, name->getName().getBaseIdentifier(), |
| 151 | + reinterpret_cast<DeclContext *>(dc)); |
| 152 | + auto pattern = NamedPattern::createImplicit(Context, varDecl); |
| 153 | + return PatternBindingDecl::create(Context, sourceLoc, |
| 154 | + isStatic ? StaticSpellingKind::KeywordStatic : StaticSpellingKind::None, |
| 155 | + sourceLoc, pattern, sourceLoc, (Expr *)initExpr, |
148 | 156 | reinterpret_cast<DeclContext *>(dc)); |
149 | 157 | } |
150 | 158 |
|
|
0 commit comments