summaryrefslogtreecommitdiff
path: root/source/slang/slang-syntax.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-05-28 14:01:51 -0400
committerGitHub <noreply@github.com>2020-05-28 14:01:51 -0400
commitc2d31347ea06c768045e7c503ef0188e0e5356de (patch)
tree1a4ee67aafca0a709ae691104023431bb6829825 /source/slang/slang-syntax.h
parente5d0f3360f44a4cdd2390e7817db17bb3cc0dd04 (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-syntax.h')
-rw-r--r--source/slang/slang-syntax.h91
1 files changed, 33 insertions, 58 deletions
diff --git a/source/slang/slang-syntax.h b/source/slang/slang-syntax.h
index d1e626f25..266f27599 100644
--- a/source/slang/slang-syntax.h
+++ b/source/slang/slang-syntax.h
@@ -1,45 +1,21 @@
#ifndef SLANG_SYNTAX_H
#define SLANG_SYNTAX_H
-#include "slang-ast-support-types.h"
-
-#include "slang-ast-all.h"
+#include "slang-ast-builder.h"
namespace Slang
{
- inline RefPtr<Type> GetSub(DeclRef<GenericTypeConstraintDecl> const& declRef)
+ inline RefPtr<Type> GetSub(ASTBuilder* astBuilder, DeclRef<GenericTypeConstraintDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->sub.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->sub.Ptr());
}
- inline RefPtr<Type> GetSup(DeclRef<TypeConstraintDecl> const& declRef)
+ inline RefPtr<Type> GetSup(ASTBuilder* astBuilder, DeclRef<TypeConstraintDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->getSup().type);
+ return declRef.substitute(astBuilder, declRef.getDecl()->getSup().type);
}
- // Note(tfoley): These logically belong to `Type`,
- // but order-of-declaration stuff makes that tricky
- //
- // TODO(tfoley): These should really belong to the compilation context!
- //
- void registerBuiltinDecl(
- Session* session,
- RefPtr<Decl> decl,
- RefPtr<BuiltinTypeModifier> modifier);
- void registerMagicDecl(
- Session* session,
- RefPtr<Decl> decl,
- RefPtr<MagicTypeModifier> modifier);
-
- // Look up a magic declaration by its name
- RefPtr<Decl> findMagicDecl(
- Session* session,
- String const& name);
-
- // Create an instance of a syntax class by name
- SyntaxNodeBase* createInstanceOfSyntaxClassByName(
- String const& name);
// `Val`
@@ -119,29 +95,29 @@ namespace Slang
///
Name* getReflectionName(VarDeclBase* varDecl);
- inline RefPtr<Type> GetType(DeclRef<VarDeclBase> const& declRef)
+ inline RefPtr<Type> GetType(ASTBuilder* astBuilder, DeclRef<VarDeclBase> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->type.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->type.Ptr());
}
- inline RefPtr<Expr> getInitExpr(DeclRef<VarDeclBase> const& declRef)
+ inline RefPtr<Expr> getInitExpr(ASTBuilder* astBuilder, DeclRef<VarDeclBase> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->initExpr);
+ return declRef.substitute(astBuilder, declRef.getDecl()->initExpr);
}
- inline RefPtr<Type> getType(DeclRef<EnumCaseDecl> const& declRef)
+ inline RefPtr<Type> getType(ASTBuilder* astBuilder, DeclRef<EnumCaseDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->type.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->type.Ptr());
}
- inline RefPtr<Expr> getTagExpr(DeclRef<EnumCaseDecl> const& declRef)
+ inline RefPtr<Expr> getTagExpr(ASTBuilder* astBuilder, DeclRef<EnumCaseDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->tagExpr);
+ return declRef.substitute(astBuilder, declRef.getDecl()->tagExpr);
}
- inline RefPtr<Type> GetTargetType(DeclRef<ExtensionDecl> const& declRef)
+ inline RefPtr<Type> GetTargetType(ASTBuilder* astBuilder, DeclRef<ExtensionDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->targetType.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->targetType.Ptr());
}
inline FilteredMemberRefList<VarDecl> GetFields(DeclRef<StructDecl> const& declRef, MemberFilterStyle filterStyle)
@@ -151,19 +127,19 @@ namespace Slang
- inline RefPtr<Type> getBaseType(DeclRef<InheritanceDecl> const& declRef)
+ inline RefPtr<Type> getBaseType(ASTBuilder* astBuilder, DeclRef<InheritanceDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->base.type);
+ return declRef.substitute(astBuilder, declRef.getDecl()->base.type);
}
- inline RefPtr<Type> GetType(DeclRef<TypeDefDecl> const& declRef)
+ inline RefPtr<Type> GetType(ASTBuilder* astBuilder, DeclRef<TypeDefDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->type.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->type.Ptr());
}
- inline RefPtr<Type> GetResultType(DeclRef<CallableDecl> const& declRef)
+ inline RefPtr<Type> GetResultType(ASTBuilder* astBuilder, DeclRef<CallableDecl> const& declRef)
{
- return declRef.Substitute(declRef.getDecl()->returnType.type.Ptr());
+ return declRef.substitute(astBuilder, declRef.getDecl()->returnType.type.Ptr());
}
inline FilteredMemberRefList<ParamDecl> GetParameters(DeclRef<CallableDecl> const& declRef)
@@ -182,33 +158,32 @@ namespace Slang
//
RefPtr<ArrayExpressionType> getArrayType(
+ ASTBuilder* astBuilder,
Type* elementType,
IntVal* elementCount);
RefPtr<ArrayExpressionType> getArrayType(
+ ASTBuilder* astBuilder,
Type* elementType);
RefPtr<NamedExpressionType> getNamedType(
- Session* session,
+ ASTBuilder* astBuilder,
DeclRef<TypeDefDecl> const& declRef);
- RefPtr<TypeType> getTypeType(
- Type* type);
-
RefPtr<FuncType> getFuncType(
- Session* session,
+ ASTBuilder* astBuilder,
DeclRef<CallableDecl> const& declRef);
RefPtr<GenericDeclRefType> getGenericDeclRefType(
- Session* session,
+ ASTBuilder* astBuilder,
DeclRef<GenericDecl> const& declRef);
RefPtr<NamespaceType> getNamespaceType(
- Session* session,
+ ASTBuilder* astBuilder,
DeclRef<NamespaceDeclBase> const& declRef);
RefPtr<SamplerStateType> getSamplerStateType(
- Session* session);
+ ASTBuilder* astBuilder);
// Definitions that can't come earlier despite
@@ -237,20 +212,20 @@ namespace Slang
// TODO: where should this live?
SubstitutionSet createDefaultSubstitutions(
- Session* session,
+ ASTBuilder* astBuilder,
Decl* decl,
SubstitutionSet parentSubst);
SubstitutionSet createDefaultSubstitutions(
- Session* session,
+ ASTBuilder* astBuilder,
Decl* decl);
DeclRef<Decl> createDefaultSubstitutionsIfNeeded(
- Session* session,
+ ASTBuilder* astBuilder,
DeclRef<Decl> declRef);
- RefPtr<GenericSubstitution> createDefaultSubsitutionsForGeneric(
- Session* session,
+ RefPtr<GenericSubstitution> createDefaultSubstitutionsForGeneric(
+ ASTBuilder* astBuilder,
GenericDecl* genericDecl,
RefPtr<Substitutions> outerSubst);