로딩중...
검색중...
일치하는것 없음
by::verifier 클래스 참조

AST verifier for semantic analysis 더 자세히 ...

#include <verifier.hpp>

by::verifier에 대한 상속 다이어그램 :
by::visitor by::tworker< void, node >

Public 멤버 함수

void onLeave (const visitInfo &i, node &me, nbool) override
 
void onLeave (const visitInfo &i, asExpr &me, nbool) override
 
void onLeave (const visitInfo &i, isExpr &me, nbool) override
 
void onLeave (const visitInfo &i, assignExpr &me, nbool) override
 
nbool onVisit (const visitInfo &i, blockExpr &me, nbool) override
 
void onLeave (const visitInfo &i, blockExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defVarExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defPropExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defAssignExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defSeqExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defArrayExpr &me, nbool) override
 
void onLeave (const visitInfo &i, defNestedFuncExpr &me, nbool) override
 
void onLeave (const visitInfo &i, FBOExpr &me, nbool) override
 
void onLeave (const visitInfo &i, FUOExpr &me, nbool) override
 
void onLeave (const visitInfo &i, getExpr &me, nbool) override
 
void onLeave (const visitInfo &i, retExpr &me, nbool) override
 
void onLeave (const visitInfo &i, evalExpr &me, nbool) override
 
void onTraverse (evalExpr &me, node &subject) override
 
nbool onVisit (const visitInfo &i, func &me, nbool) override
 
void onLeave (const visitInfo &i, func &me, nbool) override
 
nbool onVisit (const visitInfo &i, closure &me, nbool) override
 
void onLeave (const visitInfo &i, closure &me, nbool) override
 
nbool onVisit (const visitInfo &i, ctor &me, nbool) override
 
void onLeave (const visitInfo &i, ctor &me, nbool) override
 
nbool onVisit (const visitInfo &i, baseObj &me, nbool) override
 
void onLeave (const visitInfo &i, baseObj &me, nbool) override
 
nbool onVisit (const visitInfo &i, genericOrigin &me, nbool) override
 
void onLeave (const visitInfo &i, genericOrigin &me, nbool) override
 
nbool onVisit (const visitInfo &i, forExpr &me, nbool) override
 
void onLeave (const visitInfo &i, forExpr &me, nbool) override
 
nbool onVisit (const visitInfo &i, whileExpr &me, nbool) override
 
void onLeave (const visitInfo &i, breakExpr &me, nbool) override
 
void onLeave (const visitInfo &i, nextExpr &me, nbool) override
 
nbool onVisit (const visitInfo &i, ifExpr &me, nbool) override
 
void onLeave (const visitInfo &i, ifExpr &me, nbool) override
 
- by::visitor(으)로부터 상속된 Public 멤버 함수
 visitor (nbool isReturnable)
 
void setReturnable (nbool isReturnable)
 
nbool isReturnable () const
 
virtual void visit (const visitInfo &i, node &me)
 
virtual nbool onVisit (const visitInfo &i, node &me, nbool alreadyVisited)
 
virtual void onTraverse (const visitInfo &i, node &me)
 
virtual void onTraverse (const visitInfo &i, asExpr &a)
 
virtual void onTraverse (const visitInfo &i, assignExpr &a)
 
virtual void onTraverse (const visitInfo &i, blockExpr &b)
 
virtual void onTraverse (const visitInfo &i, defVarExpr &d)
 
virtual void onTraverse (const visitInfo &i, FBOExpr &f)
 
virtual void onTraverse (const visitInfo &i, getExpr &e)
 
virtual void onTraverse (const visitInfo &i, retExpr &b)
 
virtual void onTraverse (const visitInfo &i, evalExpr &e)
 
virtual void onTraverse (const visitInfo &i, func &f)
 
virtual void onTraverse (const visitInfo &i, frame &f)
 
virtual void onTraverse (const visitInfo &i, forExpr &f)
 
virtual void onTraverse (const visitInfo &i, retStateExpr &r)
 
virtual void onTraverse (const visitInfo &i, ifExpr &f)
 
virtual void onTraverse (const visitInfo &i, whileExpr &w)
 
virtual void onTraverse (const visitInfo &i, defArrayExpr &d)
 
virtual void onTraverse (const visitInfo &i, defNestedFuncExpr &e)
 
virtual void onTraverse (const visitInfo &i, genericOrigin &g)
 
virtual void onTraverse (const visitInfo &i, obj &o)
 
- by::tworker< void, node >(으)로부터 상속된 Public 멤버 함수
 tworker (const errReport &rpt)
 
errReportgetReport ()
 
const errReportgetReport () const BY_CONST_FUNC(getReport()) me &setReport(errReport &rpt)
 
me & setFlag (nint newFlag)
 
me & addFlag (nint flag)
 
me & delFlag (nint clear)
 
nbool isFlag (nint flag) const
 
nint getFlag () const
 
me & setTask (const node &root)
 
me & setTask (const node *it) BY_SIDE_FUNC(it
 
nodegetTask ()
 
const nodegetTask () const BY_CONST_FUNC(getTask()) virtual void rel()
 
void work ()
 
const areagetArea () const BY_CONST_FUNC(_getArea()) nbool isOk() const
 

Protected 멤버 함수

void _prepare () override
 Protected virtual method for preparation before starting the work.
 
void _onEndWork () override
 Protected virtual method called after the work is completed.
 
- by::visitor(으)로부터 상속된 Protected 멤버 함수
void _onWork () override
 
void _prepare () override
 Protected virtual method for preparation before starting the work.
 
- by::tworker< void, node >(으)로부터 상속된 Protected 멤버 함수
void _report (baseErr *e)
 
area_getArea ()
 
void _onEndErrReport (const errReport &rpt) const
 

Friends

struct ::verifierTest
 

추가로 상속된 멤버들

- by::tworker< void, node >(으)로부터 상속된 Public 타입
enum  logFlag
 
- by::tworker< void, node >(으)로부터 상속된 Public 속성
me setTask it
 
me setTask * this
 

상세한 설명

AST verifier for semantic analysis

Handles code verification based on visitor. Although the byeol language has an interpreter structure, the language itself uses strong typing and produces errors in advance as if executing compilation. verifier implements the core of that functionality. It checks for errors before executing the final AST created by parser and expander.

Understanding Difficulty

verifier is an advanced class even within the core module that uses various modules, so you need to know about several classes beforehand. It's probably one of the classes that will only be understood at the very last stage in this project. You need to know not only node and visitor but also expr and WHEN macros to understand it easily.

Visitor Based

Since onTraverse is filled in by visitor, verifier only defines what should be done during onVisit and onLeave.

eval and infer

Program execution ultimately consists of each node's eval(), but verifier is not interested in executed runtime values. It's only interested in type matching such as whether execution is possible and whether the result of a specified expression is implicitly convertible with the defined property's type. node's infer() performs type inference functionality, returning the result type as an origin object without knowing the value when executed. It's faster than eval() because it doesn't compute values. Now you might sense it, but verifier focuses on using infer() rather than eval().

void me::onLeave(const visitInfo& i, assignExpr& me, nbool) {
....
str left = me.getLeft().infer() OR.myExErr(me, LHS_IS_NUL).ret();
....
str right = me.getRight().infer() OR.myExErr(me, RHS_IS_NUL).ret();
....
}
Assignment expression
Definition assignExpr.hpp:19
Definition tnarr.hpp:9
Visitor context information
Definition visitInfo.hpp:11

As in the above example, infer() is mainly used instead of eval().

Many Lines of Code File

verifier is one of the files with the most LOC. At this time, the code is largely classified into 3 types.

  • Preliminary work for verification
  • Actual verification logic using WHEN macros
  • Detailed logging for each stage

Detailed Stage Logging

visitor can only have 1 onVisit() function per type. However, verifier usually has 2 or more verification cases that need to be checked when given one type. So if not careful, one onVisit() function becomes mixed with multiple verification logics making it difficult to distinguish. Detailed stage logging helps with this, playing the role of leaving logs about what verification logic will be performed on the object being verified. For example, the _STEP macro automatically counts which stage within that function it is and shows the log.

Verification Using WHEN Macros

verifier is a class with many verification codes like if (!check) return res;. So verifier inevitably has numerous WHEN macros.

verifier vs starter

starter directly executes the program. verifier only performs verification. The biggest difference between them is that when starter executes expressions with eval(), verifier only gets type information with infer(). However, there are some tasks that verifier must perform identically to starter.

  • First, using frameInteract. To find out if a type exists and is currently accessible, the obj scope or func scope must actually be registered in the frame. Usually if inFrame() is called for a specific object in onVisit(), outFrame() will be called for the same object in onLeave().
  • Actually define properties. Although the value is empty, the property itself must be defined to check whether the property is duplicate or if a non-existent property is being accessed.
  • Actually create generic classes. Only then can generic class verification be possible.

멤버 함수 문서화

◆ _onEndWork()

void by::verifier::_onEndWork ( )
overrideprotectedvirtual

Protected virtual method called after the work is completed.

This hook allows derived classes to perform any necessary cleanup or finalization after _onWork() has finished.

by::tworker< void, node >(으)로부터 재구현되었습니다.

◆ _prepare()

void by::verifier::_prepare ( )
overrideprotectedvirtual

Protected virtual method for preparation before starting the work.

This hook allows derived classes to perform any necessary setup or initialization before _onWork() is invoked.

by::tworker< void, node >(으)로부터 재구현되었습니다.

◆ onLeave()

void by::verifier::onLeave ( const visitInfo & i,
node & me,
nbool  )
overridevirtual

by::visitor(으)로부터 재구현되었습니다.

◆ onTraverse()

void by::verifier::onTraverse ( evalExpr & me,
node & subject )
overridevirtual

by::visitor(으)로부터 재구현되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.:
to Top