2019-08-23 11:56:54 -07:00
|
|
|
#include "BeefySysLib/Common.h"
|
|
|
|
#include "BfAst.h"
|
|
|
|
#include "BfSystem.h"
|
|
|
|
|
|
|
|
NS_BF_BEGIN
|
|
|
|
|
|
|
|
// This is the first pass through our ASTs, builds up Def structures in BfSystem
|
|
|
|
// so when we go to compile we'll be able to resolve references
|
|
|
|
|
|
|
|
class BfResolvePassData;
|
|
|
|
|
|
|
|
class BfDefBuilder : public BfStructuralVisitor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BfSource* mCurSource;
|
|
|
|
BfSystem* mSystem;
|
|
|
|
BfPassInstance* mPassInstance;
|
|
|
|
BfTypeDef* mCurTypeDef;
|
2021-11-22 17:11:16 -08:00
|
|
|
BfTypeDef* mCurDeclaringTypeDef;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfTypeDef* mCurActualTypeDef;
|
|
|
|
bool mFullRefresh;
|
2021-01-11 09:41:43 -08:00
|
|
|
bool mIsComptime;
|
2019-08-23 11:56:54 -07:00
|
|
|
BfResolvePassData* mResolvePassData;
|
|
|
|
BfAtomComposite mNamespace;
|
|
|
|
Array<BfAtomComposite> mNamespaceSearch;
|
|
|
|
Array<BfTypeReference*> mStaticSearch;
|
2020-10-14 11:33:41 -07:00
|
|
|
Array<BfTypeReference*> mInternalAccessSet;
|
2019-08-23 11:56:54 -07:00
|
|
|
HashContext* mFullHashCtx;
|
|
|
|
HashContext* mSignatureHashCtx;
|
|
|
|
|
|
|
|
public:
|
2020-09-12 09:24:01 -07:00
|
|
|
void ParseGenericParams(BfGenericParamsDeclaration* genericParamsDecl, BfGenericConstraintsDeclaration* genericConstraints, Array<BfGenericParamDef*>& genericParams, Array<BfExternalConstraintDef>* externConstraintDefs, int outerGenericSize, bool isInGeneric);
|
2020-12-07 07:53:12 -08:00
|
|
|
BfProtection GetProtection(BfAstNode* protectionNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
bool WantsNode(BfAstNode* wholeNode, BfAstNode* startNode = NULL, int addLen = 0);
|
|
|
|
//static BfNamedTypeReference* AllocTypeReference(BfSource* bfSource, const StringImpl& typeName);
|
|
|
|
//static BfResolvedTypeReference* AllocTypeReference(BfSource* bfSource, BfType* type);
|
|
|
|
static BfFieldDef* AddField(BfTypeDef* typeDef, BfTypeReference* typeRef, const StringImpl& name);
|
2021-01-11 09:41:43 -08:00
|
|
|
static BfMethodDef* AddMethod(BfTypeDef* typeDef, BfMethodType methodType, BfProtection protection, bool isStatic, const StringImpl& name, bool addedAfterEmit = false);
|
2019-08-23 11:56:54 -07:00
|
|
|
static BfMethodDef* AddDtor(BfTypeDef* typeDef);
|
|
|
|
static void AddDynamicCastMethods(BfTypeDef* typeDef);
|
|
|
|
void AddParam(BfMethodDef* methodDef, BfTypeReference* typeRef, const StringImpl& paramName);
|
2020-12-31 09:56:51 -08:00
|
|
|
BfTypeDef* ComparePrevTypeDef(BfTypeDef* prevTypeDef, BfTypeDef* checkTypeDef);
|
2019-08-23 11:56:54 -07:00
|
|
|
void FinishTypeDef(bool wantsToString);
|
|
|
|
void ParseAttributes(BfAttributeDirective* attributes, BfMethodDef* methodDef);
|
|
|
|
void ParseAttributes(BfAttributeDirective* attributes, BfTypeDef* typeDef);
|
|
|
|
BfMethodDef* CreateMethodDef(BfMethodDeclaration* methodDecl, BfMethodDef* outerMethodDef = NULL);
|
2020-01-06 13:49:35 -08:00
|
|
|
BfError* Fail(const StringImpl& errorStr, BfAstNode* refNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
BfDefBuilder(BfSystem* bfSystem);
|
|
|
|
~BfDefBuilder();
|
|
|
|
|
|
|
|
void Process(BfPassInstance* passInstance, BfSource* bfSource, bool fullRefresh);
|
|
|
|
void RemoveDefsFrom(BfSource* bfSource);
|
|
|
|
|
|
|
|
virtual void Visit(BfIdentifierNode* identifier) override;
|
|
|
|
virtual void Visit(BfMethodDeclaration* methodDeclaration) override;
|
|
|
|
virtual void Visit(BfConstructorDeclaration* ctorDeclaration) override;
|
|
|
|
virtual void Visit(BfPropertyDeclaration* propertyDeclaration) override;
|
|
|
|
virtual void Visit(BfFieldDeclaration* fieldDeclaration) override;
|
|
|
|
virtual void Visit(BfEnumCaseDeclaration* enumCaseDeclaration) override;
|
|
|
|
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
|
|
|
virtual void Visit(BfUsingDirective* usingDirective) override;
|
2020-10-14 11:33:41 -07:00
|
|
|
virtual void Visit(BfUsingModDirective* usingDirective) override;
|
2019-08-23 11:56:54 -07:00
|
|
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
|
|
|
virtual void Visit(BfBlock* block) override;
|
|
|
|
virtual void Visit(BfRootNode* rootNode) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_BF_END
|