diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-05-28 14:01:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-28 14:01:51 -0400 |
| commit | c2d31347ea06c768045e7c503ef0188e0e5356de (patch) | |
| tree | 1a4ee67aafca0a709ae691104023431bb6829825 /source/slang/slang-check-modifier.cpp | |
| parent | e5d0f3360f44a4cdd2390e7817db17bb3cc0dd04 (diff) | |
WIP: ASTBuilder (#1358)
* Compiles.
* Small tidy up around session/ASTBuilder.
* Tests are now passing.
* Fix Visual Studio project.
* Fix using new X to use builder when protectedness of Ctor is not enough.
Substitute->substitute
* Add some missing ast nodes created outside of ASTBuilder.
* Compile time check that ASTBuilder is making an AST type.
* Moced findClasInfo and findSyntaxClass (essentially the same thing) to SharedASTBuilder from Session.
Diffstat (limited to 'source/slang/slang-check-modifier.cpp')
| -rw-r--r-- | source/slang/slang-check-modifier.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index b8b3846dc..42a9735af 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -80,15 +80,13 @@ namespace Slang AttributeDecl* SemanticsVisitor::lookUpAttributeDecl(Name* attributeName, Scope* scope) { - auto session = getSession(); - // We start by looking for an existing attribute matching // the name `attributeName`. // { // Look up the name and see what attributes we find. // - auto lookupResult = lookUp(session, this, attributeName, scope, LookupMask::Attribute); + auto lookupResult = lookUp(m_astBuilder, this, attributeName, scope, LookupMask::Attribute); // If the result was overloaded, then that means there // are multiple attributes matching the name, and we @@ -118,7 +116,7 @@ namespace Slang // If the attribute was `[Something(...)]` then we will // look for a `struct` named `SomethingAttribute`. // - LookupResult lookupResult = lookUp(session, this, session->getNameObj(attributeName->text + "Attribute"), scope, LookupMask::type); + LookupResult lookupResult = lookUp(m_astBuilder, this, m_astBuilder->getGlobalSession()->getNameObj(attributeName->text + "Attribute"), scope, LookupMask::type); // // If we didn't find a matching type name, then we give up. // @@ -140,12 +138,12 @@ namespace Slang // We will now synthesize a new `AttributeDecl` to mirror // what was declared on the `struct` type. // - RefPtr<AttributeDecl> attrDecl = new AttributeDecl(); + RefPtr<AttributeDecl> attrDecl = m_astBuilder->create<AttributeDecl>(); attrDecl->nameAndLoc.name = attributeName; attrDecl->nameAndLoc.loc = structDecl->nameAndLoc.loc; attrDecl->loc = structDecl->loc; - RefPtr<AttributeTargetModifier> targetModifier = new AttributeTargetModifier(); + RefPtr<AttributeTargetModifier> targetModifier = m_astBuilder->create<AttributeTargetModifier>(); targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; targetModifier->loc = attrUsageAttr->loc; addModifier(attrDecl, targetModifier); @@ -155,8 +153,8 @@ namespace Slang // // User-defined attributes create instances of // `UserDefinedAttribute`. - // - attrDecl->syntaxClass = session->findSyntaxClass(session->getNameObj("UserDefinedAttribute")); + // + attrDecl->syntaxClass = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("UserDefinedAttribute")); // The fields of the user-defined `struct` type become // the parameters of the new attribute. @@ -169,7 +167,7 @@ namespace Slang { ensureDecl(varMember, DeclCheckState::CanUseTypeOfValueDecl); - RefPtr<ParamDecl> paramDecl = new ParamDecl(); + RefPtr<ParamDecl> paramDecl = m_astBuilder->create<ParamDecl>(); paramDecl->nameAndLoc = member->nameAndLoc; paramDecl->type = varMember->type; paramDecl->loc = member->loc; @@ -236,17 +234,17 @@ namespace Slang { if (typeFlags == (int)UserDefinedAttributeTargets::Struct) { - cls = getSession()->findSyntaxClass(getSession()->getNameObj("StructDecl")); + cls = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("StructDecl")); return true; } if (typeFlags == (int)UserDefinedAttributeTargets::Var) { - cls = getSession()->findSyntaxClass(getSession()->getNameObj("VarDecl")); + cls = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("VarDecl")); return true; } if (typeFlags == (int)UserDefinedAttributeTargets::Function) { - cls = getSession()->findSyntaxClass(getSession()->getNameObj("FuncDecl")); + cls = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("FuncDecl")); return true; } return false; |
