Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Gyoji::frontend::lowering::Scope Class Reference

Represents variable declarations, labels, and goto inside a lexical scope. More...

#include <function-scope.hpp>

Public Member Functions

 Scope ()
 
 Scope (bool _is_loop, size_t _loop_break_blockid, size_t _loop_continue_blockid)
 
 ~Scope ()
 Move along, nothing to see here.
 
const LocalVariable * get_variable (std::string name) const
 

Detailed Description

Represents variable declarations, labels, and goto inside a lexical scope.

This class represents a highly simplified representation of operations inside a lexical scope. The only operations that happen here are sub-scopes, labels, goto statements, and variable declarations. The order of the operations is important because it's important to reason about whether initialization has happened before labels in the context of a 'goto' to a different scope.

In addition, if the scope is a 'loop' (i.e. a while or for loop), this tracks the Block ID of where a 'continue' or 'break' statment should branch to.

Constructor & Destructor Documentation

◆ Scope() [1/2]

Scope::Scope ( )

This is an anonymous scope that is NOT a loop (i.e. break and continue are not permitted here).

◆ Scope() [2/2]

Scope::Scope ( bool  _is_loop,
size_t  _loop_break_blockid,
size_t  _loop_continue_blockid 
)

This is a scope that is associated with some loop like a 'for' or 'while'. The block ID for where to jump to in case of break or continue are provided so that they can be known if they are needed.

◆ ~Scope()

Scope::~Scope ( )

Move along, nothing to see here.

Move along, nothing to see here.

Member Function Documentation

◆ get_variable()

const LocalVariable * Scope::get_variable ( std::string  name) const

If the given variable is defined in this scope, return the type of it. If no such variable is defined, returns nullptr.


The documentation for this class was generated from the following files: