C# Class Jurassic.Compiler.Scope

Represents an enclosing context where variables are uniquely defined.
ファイルを表示 Open project: paulbartrum/jurassic Class Usage Examples

Private Properties

Property Type Description
DeclareVariable DeclaredVariable
GenerateDeclarations void
GenerateScopeCreation void
GenerateScopeDestruction void
GetDeclaredVariable DeclaredVariable
HasDeclaredVariable bool
RemovedDeclaredVariable void

Public Methods

Method Description
Delete ( string variableName ) : bool

Deletes the variable from the scope.

GetValue ( string variableName ) : object

Returns the value of the given variable.

HasValue ( string variableName ) : bool

Returns true if the given variable exists in this scope.

SetValue ( string variableName, object value ) : void

Sets the value of the given variable.

Protected Methods

Method Description
Scope ( Scope parentScope ) : System

Creates a new Scope instance.

Scope ( Scope parentScope, int declaredVariableCount ) : System

Creates a new Scope instance.

Private Methods

Method Description
DeclareVariable ( string name, Jurassic.Compiler.Expression valueAtTopOfScope = null, bool writable = true, bool deletable = false ) : DeclaredVariable

Declares a variable or function in this scope. This will be initialized with the value of the given expression.

GenerateDeclarations ( ILGenerator generator, OptimizationInfo optimizationInfo ) : void

Generates code that initializes the variable and function declarations.

GenerateScopeCreation ( ILGenerator generator, OptimizationInfo optimizationInfo ) : void

Generates code that creates a new scope.

GenerateScopeDestruction ( ILGenerator generator, OptimizationInfo optimizationInfo ) : void

Generates code that restores the parent scope as the active scope.

GetDeclaredVariable ( string variableName ) : DeclaredVariable

Gets the index of the given variable.

HasDeclaredVariable ( string name ) : bool

Returns true if the given variable has been declared in this scope.

RemovedDeclaredVariable ( string name ) : void

Removes a declared variable from the scope.

Method Details

Delete() public abstract method

Deletes the variable from the scope.
public abstract Delete ( string variableName ) : bool
variableName string The name of the variable.
return bool

GetValue() public abstract method

Returns the value of the given variable.
public abstract GetValue ( string variableName ) : object
variableName string The name of the variable.
return object

HasValue() public abstract method

Returns true if the given variable exists in this scope.
public abstract HasValue ( string variableName ) : bool
variableName string The name of the variable to check.
return bool

Scope() protected method

Creates a new Scope instance.
protected Scope ( Scope parentScope ) : System
parentScope Scope A reference to the parent scope, or null if this is /// the global scope.
return System

Scope() protected method

Creates a new Scope instance.
protected Scope ( Scope parentScope, int declaredVariableCount ) : System
parentScope Scope A reference to the parent scope, or null if this is /// the global scope.
declaredVariableCount int The number of variables declared in this scope.
return System

SetValue() public abstract method

Sets the value of the given variable.
public abstract SetValue ( string variableName, object value ) : void
variableName string The name of the variable.
value object The new value of the variable.
return void