Gorgon Game Engine
Scope Class Reference

A new scope is created automatically when a new input source or a function like construct is created. More...

Public Member Functions

 Scope (InputProvider &provider, const std::string &name, bool terminal=false)
 Constructor requires an input provider and a name to define this input source. More...
 
 Scope (Scope &parent, const std::string &name, bool terminal=false)
 This constructor allows a scope without an input provider. More...
 
std::string GetName () const
 Returns the name of this scope. More...
 
ScopeGetParent () const
 
long GetPhysicalLine (unsigned long line)
 Current physical line. More...
 
VariableGetVariable (const std::string &name)
 
bool HasInstance () const
 
bool HasParent () const
 
std::shared_ptr< ScopeInstanceInstantiate ()
 
std::shared_ptr< ScopeInstanceInstantiate (ScopeInstance &current)
 
bool IsInteractive () const
 Returns if this scope is interactive (i.e. code is entered by user) More...
 
bool IsTerminal () const
 Returns if this scope is terminal scope. More...
 
ScopeInstanceLastInstance () const
 
const InstructionReadInstruction (unsigned long line)
 Reads the instruction in the given line. More...
 
unsigned ReadyInstructionCount () const
 Current number of instructions that are prepared. More...
 
void SaveInstruction (Instruction inst, long pline)
 Saves an instruction to the scope. More...
 
void SaveInstructions (const std::vector< Instruction > &insts)
 Saves a list of instructions to this scope. More...
 
void SetName (const std::string &name)
 In rare cases where scope name cannot be determined at the construction, this function can be used to set its name. More...
 
void SetVariable (const std::string &name, const Data &data)
 
void Unload ()
 Unloads an input source by erasing all current data. More...
 
bool UnsetVariable (const std::string &name)
 

Detailed Description

A new scope is created automatically when a new input source or a function like construct is created.

Scopes can be linked to each other. There are two methods to supply codes to a scope: from an InputProvider and directly registering instructions to it.

Constructor & Destructor Documentation

◆ Scope() [1/2]

Scope ( InputProvider provider,
const std::string &  name,
bool  terminal = false 
)

Constructor requires an input provider and a name to define this input source.

References Gorgon::Utils::ASSERT_FALSE(), InputProvider::GetDialect(), InputProvider::Intermediate, and InputProvider::Programming.

◆ Scope() [2/2]

Scope ( Scope parent,
const std::string &  name,
bool  terminal = false 
)

This constructor allows a scope without an input provider.

This allows function like constructs to have their own scopes with designated source code supplied from external sources

Member Function Documentation

◆ GetName()

std::string GetName ( ) const

Returns the name of this scope.

◆ GetParent()

Scope& GetParent ( ) const

◆ GetPhysicalLine()

long GetPhysicalLine ( unsigned long  line)

Current physical line.

References Scope::ReadInstruction().

◆ GetVariable()

Variable* GetVariable ( const std::string &  name)

◆ HasInstance()

bool HasInstance ( ) const

◆ HasParent()

bool HasParent ( ) const

◆ Instantiate() [1/2]

std::shared_ptr< ScopeInstance > Instantiate ( )

References Scope::ScopeInstance.

◆ Instantiate() [2/2]

std::shared_ptr< ScopeInstance > Instantiate ( ScopeInstance current)

References Scope::Instantiate().

◆ IsInteractive()

bool IsInteractive ( ) const

Returns if this scope is interactive (i.e. code is entered by user)

References InputProvider::IsInteractive().

◆ IsTerminal()

bool IsTerminal ( ) const

Returns if this scope is terminal scope.

If a scope is terminal, variable lookup to the parent scopes terminates at this scope

◆ LastInstance()

ScopeInstance& LastInstance ( ) const

References ASSERT.

◆ ReadInstruction()

◆ ReadyInstructionCount()

unsigned ReadyInstructionCount ( ) const

Current number of instructions that are prepared.

◆ SaveInstruction()

void SaveInstruction ( Instruction  inst,
long  pline 
)

Saves an instruction to the scope.

◆ SaveInstructions()

void SaveInstructions ( const std::vector< Instruction > &  insts)

Saves a list of instructions to this scope.

◆ SetName()

void SetName ( const std::string &  name)

In rare cases where scope name cannot be determined at the construction, this function can be used to set its name.

◆ SetVariable()

void SetVariable ( const std::string &  name,
const Data data 
)

◆ Unload()

void Unload ( )

Unloads an input source by erasing all current data.

Unload should only be called when no more callbacks can be performed and no more lines are left.

References InputProvider::Reset(), and Gorgon::swap().

◆ UnsetVariable()

bool UnsetVariable ( const std::string &  name)

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