Class FunctionScope
java.lang.Object
me.topchetoeu.j2s.compilation.scope.FunctionScope
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final VariableList
protected final VariableList
final FunctionScope
final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]
int
String[]
int
defineCatch
(String name) Creates a catch variable and returns itdefineCatch
(String name, Variable var) Creates a catch variable, using a specific variable instance Used in the second passGets the index supplier of the given variable name, or null if it is a globalIf the variable given is contained in this function, just returns the variable itself.int[]
boolean
Checks if the given variable name is accessibleString[]
locals()
int
void
Removes the last catch variable.
-
Field Details
-
locals
-
capturables
-
parent
-
passthrough
public final boolean passthrough
-
-
Constructor Details
-
FunctionScope
-
FunctionScope
public FunctionScope(boolean passthrough)
-
-
Method Details
-
define
- Returns:
- If a variable with the same name exists, the old variable. Otherwise, the given variable
-
define
- Returns:
- A variable with the given name, or null if a global variable
-
defineCatch
Creates a catch variable and returns it -
defineCatch
Creates a catch variable, using a specific variable instance Used in the second pass -
undefineCatch
public void undefineCatch()Removes the last catch variable. NOTE: the variable is still in the internal list. It just won't be findable by its name -
get
Gets the index supplier of the given variable name, or null if it is a global- Parameters:
capture
- If true, the variable is being captured by a function
-
get
If the variable given is contained in this function, just returns the variable itself. However, this function is important to handle cases in which you might want to access a captured variable. In such cases, this function will return a capture to the given variable.- Parameters:
capture
- Whether or not to execute this capturing logic
-
has
Checks if the given variable name is accessible- Parameters:
capture
- If true, will check beyond this function's scope
-
localsCount
public int localsCount() -
capturesCount
public int capturesCount() -
capturablesCount
public int capturablesCount() -
getCaptureIndices
public int[] getCaptureIndices() -
capturables
-
locals
-
captureNames
-
localNames
-
capturableNames
-