C# Class kompiler.Symbols

Exibir arquivo Open project: jakl/hacks Class Usage Examples

Public Methods

Method Description
GetSymbols ( ) : Symbols
ToString ( ) : string

Dump all the variables in all the scopes into a human readable string for debugging

add ( string name ) : void

Cache a variable's name, until the type is known, at which point call commit

add ( string name, int value ) : void

Cache a constant until a commit call to commit all cached constants

addType ( string name, int startIndex, int endIndex ) : void

Add an array type to the current scope, to be used as a possible type of future variables. Note: Not that great of an idea. This needs to be subclassed and organized so variables can have more dynamic types

commit ( ) : void

When finished declaring variable or constant integers, add them to the current scope Clear the cached variables afterwards

commitTypedVar ( AttrType type ) : void

When a type is declared after any number of variables have been added, set all cached variables to that type and add them to the current scope. The type is always an array. Clear the cached variables afterwards

get ( string name ) : Attribute

Get a non-var attribute, by name, in the nearest scope possible If no variable is named such, return null

getOffset ( string name ) : int

Get the Attribute for a variable, by name, in the nearest scope possible. If no variable is named such, return null. It may be nested, in which case the nestedOffset will have the proper offset to add to the normal variable's own offset within its own scope

init ( ) : void

Initialize symbol system for fresh use

nest ( ) : void

Create a new scope

setVal ( string name, int value ) : void

Set a variable's value, using the variable, by name, in the closest scope If no such named variable exists, nothing is changed

unnest ( ) : void

Destroy the latest scope

Private Methods

Method Description
Symbols ( ) : System

Method Details

GetSymbols() public static method

public static GetSymbols ( ) : Symbols
return Symbols

ToString() public method

Dump all the variables in all the scopes into a human readable string for debugging
public ToString ( ) : string
return string

add() public method

Cache a variable's name, until the type is known, at which point call commit
public add ( string name ) : void
name string
return void

add() public method

Cache a constant until a commit call to commit all cached constants
public add ( string name, int value ) : void
name string
value int
return void

addType() public method

Add an array type to the current scope, to be used as a possible type of future variables. Note: Not that great of an idea. This needs to be subclassed and organized so variables can have more dynamic types
public addType ( string name, int startIndex, int endIndex ) : void
name string
startIndex int
endIndex int
return void

commit() public method

When finished declaring variable or constant integers, add them to the current scope Clear the cached variables afterwards
public commit ( ) : void
return void

commitTypedVar() public method

When a type is declared after any number of variables have been added, set all cached variables to that type and add them to the current scope. The type is always an array. Clear the cached variables afterwards
public commitTypedVar ( AttrType type ) : void
type AttrType
return void

get() public method

Get a non-var attribute, by name, in the nearest scope possible If no variable is named such, return null
public get ( string name ) : Attribute
name string
return Attribute

getOffset() public method

Get the Attribute for a variable, by name, in the nearest scope possible. If no variable is named such, return null. It may be nested, in which case the nestedOffset will have the proper offset to add to the normal variable's own offset within its own scope
public getOffset ( string name ) : int
name string
return int

init() public method

Initialize symbol system for fresh use
public init ( ) : void
return void

nest() public method

Create a new scope
public nest ( ) : void
return void

setVal() public method

Set a variable's value, using the variable, by name, in the closest scope If no such named variable exists, nothing is changed
public setVal ( string name, int value ) : void
name string
value int
return void

unnest() public method

Destroy the latest scope
public unnest ( ) : void
return void