Module Expr Str Import alias Import alias Import alias identifier Import alias identifier Import alias identifier Assign NameStore Call AttributeLoad NameLoad attr Str ListLoad Str Str ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Return SetComp NameLoad comprehension TupleStore NameStore NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Return SetComp NameLoad comprehension TupleStore NameStore NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Return Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr orelse Return Call AttributeLoad Call AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Raise Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareNotEq AttributeLoad NameLoad attr Str body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return decorator_list FunctionDef arguments args NameParam NameParam defaults body If AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return decorator_list FunctionDef arguments args NameParam NameParam defaults body Raise Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr With Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Assign NameStore Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore AttributeStore NameLoad attr AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return TupleLoad Call AttributeLoad SubscriptLoad NameLoad Index Num attr Call NameLoad NameLoad Call NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Return BoolOpOr CompareIn NameLoad AttributeLoad NameLoad attr CompareIn NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body If NameLoad body Return AttributeLoad NameLoad attr orelse Return SetComp NameLoad comprehension TupleStore NameStore NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore AttributeLoad NameLoad attr If Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse If BoolOpAnd UnaryOpNot Call AttributeLoad NameLoad attr NameLoad Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword NameLoad keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr keyword NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body If NameLoad body Return AttributeLoad NameLoad attr orelse Return SetComp NameLoad comprehension TupleStore NameStore NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call NameLoad NameLoad If CompareIsNot NameLoad NameLoad body If CompareNotIn SubscriptLoad NameLoad Index Num AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword NameLoad keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr orelse Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore AttributeLoad NameLoad attr If Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse If BoolOpAnd UnaryOpNot Call AttributeLoad NameLoad attr NameLoad Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad keyword TupleLoad NameLoad keyword Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If BoolOpOr CompareIs AttributeLoad NameLoad attr NameLoad UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad If CompareEq Call NameLoad NameLoad Num body Return NameLoad Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body If Call NameLoad NameLoad AttributeLoad NameLoad attr body Return ListLoad AttributeLoad NameLoad attr If Call NameLoad NameLoad AttributeLoad NameLoad attr body Return Call NameLoad AttributeLoad NameLoad attr If Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Call NameLoad AttributeLoad NameLoad attr If CompareEq Call NameLoad NameLoad Num body Return ListLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return NameLoad Return ListLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list
N/A N/A Provide some basic analyses for Python code that we want to convert to Fora.

This module exports the following functions:
getFreeVariables(astNode, isClassContext = None):
    returns a set of strings listing the identifiers of the variables that
    are free in the subtree defined by `pyAstNode. Currently, only three
    types of ast nodes are supported: ast.Module, ast.FunctionDef, and
    ast.ClassDef. The second argument to the funtion (`isClassContext) is
    needed when we pass it an ast.FunctionDef because its enclosing context
    affects the results of the analysis.

getFreeVariableMemberAccessChains(astNode, isClassContext = None):
    like `getFreeVariables above but returns member-access-chains instead of
    simple names.

collectBoundValuesInScope(astNode):
    returns a set of strings with the names and variables that are bound in
    a scope, without recursively descending into nested scopes.

collectBoundVariablesInScope(astNode):
    same as `collectBoundValuesInScope, but only returns variables.

collectBoundNamesInScope(astNode)
    same as `collectBoundValuesInScope, but only returns names (i.e.,
    function or class declarations) .
 N/A ast N/A collections N/A pyfora.pyAst.NodeVisitorBases NodeVisitorBases N/A pyfora.Exceptions Exceptions N/A pyfora.pyAst.PyAstUtil PyAstUtil N/A VarWithPosition N/A N/A collections namedtuple VarWithPosition N/A var pos _CollectBoundValuesInScopeVisitor N/A N/A NodeVisitorBases GenericInScopeVisitor N/A N/A 
    Collect the variables and names that are bound in the current scope.

    This visitor does not recursively descend into nested scopes.
    It separately keeps track of Names (i.e., function and class declarations) and Variables.
     __init__ N/A N/A self node N/A N/A N/A N/A N/A N/A super _CollectBoundValuesInScopeVisitor self __init__ node N/A N/A self _boundVarsWithPos N/A set N/A N/A self _boundNamesWithPos N/A set N/A getBoundNames N/A N/A self N/A N/A N/A N/A N/A self _cachedCompute N/A N/A var N/A N/A var _ N/A self _boundNamesWithPos N/A getBoundVariables N/A N/A self N/A N/A N/A N/A N/A self _cachedCompute N/A N/A var N/A N/A var _ N/A self _boundVarsWithPos N/A getBoundValues N/A N/A self getPositions N/A False N/A N/A N/A N/A self _cachedCompute N/A N/A getPositions True N/A N/A N/A N/A N/A self _boundVarsWithPos union N/A self _boundNamesWithPos N/A N/A N/A N/A N/A N/A self getBoundVariables union N/A N/A self getBoundNames N/A visit_Module N/A N/A self _ N/A N/A N/A N/A N/A Exceptions InternalError N/A Unexpected call of 'visit_Module' in '%s' N/A N/A self __class__ __name__ N/A visit_FunctionDef N/A N/A self node N/A N/A N/A N/A N/A node name N/A N/A N/A N/A N/A self _boundNamesWithPos add N/A VarWithPosition var N/A node name pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A visit_ClassDef N/A N/A self node N/A N/A N/A N/A N/A N/A self _boundNamesWithPos add N/A VarWithPosition var N/A node name pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A visit_Lambda N/A N/A self _ N/A N/A N/A N/A visit_Name N/A N/A self node N/A N/A N/A N/A self _isInDefinition N/A N/A N/A N/A N/A self _boundVarsWithPos add N/A VarWithPosition var N/A node id pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A visit_Attribute N/A N/A self _ N/A N/A N/A N/A visit_Global N/A N/A self node N/A N/A N/A N/A N/A Exceptions PythonToForaConversionError N/A 'global' statement not supported in Python to Fora translation (line %s). N/A node lineno N/A visit_arguments N/A N/A self node N/A N/A N/A N/A N/A self visit N/A node defaults N/A N/A N/A self _isInDefinitionMgr True N/A N/A N/A N/A self visit N/A node args N/A N/A N/A node vararg None N/A N/A N/A N/A N/A self _boundVarsWithPos add N/A VarWithPosition var N/A node vararg pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A N/A N/A node kwarg None N/A N/A N/A N/A N/A self _boundVarsWithPos add N/A VarWithPosition var N/A node kwarg pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A N/A collectBoundValuesInScope N/A N/A pyAstNode getPositions N/A False N/A N/A vis N/A _CollectBoundValuesInScopeVisitor pyAstNode N/A N/A N/A vis getBoundValues getPositions N/A collectBoundVariablesInScope N/A N/A pyAstNode N/A N/A N/A vis N/A _CollectBoundValuesInScopeVisitor pyAstNode N/A N/A N/A vis getBoundVariables N/A collectBoundNamesInScope N/A N/A pyAstNode N/A N/A N/A vis N/A _CollectBoundValuesInScopeVisitor pyAstNode N/A N/A N/A vis getBoundNames N/A GenericBoundValuesScopedVisitor N/A N/A NodeVisitorBases GenericScopedVisitor N/A N/A Extending GenericScopedVisitor by specializing the context manager to track bound values. __init__ N/A N/A self N/A N/A N/A scopeMgr N/A N/A NodeVisitorBases ScopedSaveRestoreComputedValue N/A self getBoundValues N/A self _setBoundValues N/A GenericBoundValuesScopedVisitor _computeScopeBoundValues N/A N/A N/A N/A super GenericBoundValuesScopedVisitor self __init__ scopeMgr N/A N/A self _boundValues N/A set N/A N/A self _boundInScopeSoFar N/A set N/A getBoundValues N/A N/A self N/A N/A N/A N/A N/A self _boundValues N/A self _boundInScopeSoFar N/A _setBoundValues N/A N/A self valueSets N/A N/A N/A N/A N/A self _boundValues N/A self _boundInScopeSoFar valueSets N/A _computeScopeBoundValues N/A N/A node oldValueSets N/A N/A N/A N/A N/A N/A N/A oldValueSets N/A 0 union N/A collectBoundValuesInScope node N/A set N/A staticmethod isBoundSoFar N/A N/A self name N/A N/A N/A N/A N/A name N/A self _boundValues N/A name N/A self _boundInScopeSoFar N/A visit_ClassDef N/A N/A self node N/A N/A N/A N/A N/A N/A self _boundValues add N/A node name N/A N/A N/A N/A NodeVisitorBases GenericScopedVisitor visit_ClassDef self node N/A N/A _FreeVarsVisitor N/A GenericBoundValuesScopedVisitor N/A N/A Collect the free variables in a block of code. __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super _FreeVarsVisitor self __init__ N/A N/A self _freeVarsWithPos N/A set N/A getFreeVars N/A N/A self getPositions N/A False N/A N/A getPositions N/A N/A N/A self _freeVarsWithPos N/A N/A N/A var N/A N/A var _ N/A self _freeVarsWithPos N/A visit_Name N/A N/A self node N/A N/A N/A identifier N/A node id N/A N/A isinstance N/A node ctx N/A ast Store N/A N/A N/A N/A N/A self _boundInScopeSoFar add identifier N/A N/A N/A N/A N/A N/A self isBoundSoFar identifier N/A isinstance N/A node ctx N/A ast Load N/A N/A N/A N/A N/A self _freeVarsWithPos add N/A VarWithPosition var identifier pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A N/A getFreeVariables N/A N/A pyAstNode isClassContext getPositions N/A None False N/A N/A pyAstNode N/A N/A PyAstUtil getRootInContext pyAstNode isClassContext N/A freeVarsVisitor N/A _FreeVarsVisitor N/A N/A N/A freeVarsVisitor visit pyAstNode N/A N/A N/A freeVarsVisitor getFreeVars getPositions getPositions N/A _FreeVariableMemberAccessChainsVisitor N/A GenericBoundValuesScopedVisitor N/A N/A Collect the free variable member access chains in a block of code. __init__ N/A N/A self exclude_predicate N/A None N/A N/A N/A N/A N/A super _FreeVariableMemberAccessChainsVisitor self __init__ N/A N/A self _freeVariableMemberAccessChainsWithPos N/A set N/A N/A self exclude_predicate exclude_predicate N/A getFreeVariablesMemeberAccessChains N/A N/A self getPositions N/A False N/A N/A getPositions N/A N/A N/A self _freeVariableMemberAccessChainsWithPos N/A N/A N/A chain N/A N/A chain _ N/A self _freeVariableMemberAccessChainsWithPos N/A visit_Attribute N/A N/A self node N/A N/A N/A chainOrNone N/A _memberAccessChainOrNone node N/A N/A chainOrNone None N/A N/A N/A N/A chainOrNone N/A 0 N/A self _boundValues N/A N/A N/A N/A N/A self _freeVariableMemberAccessChainsWithPos add N/A VarWithPosition var chainOrNone pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A N/A N/A N/A self generic_visit N/A node value N/A visit_Name N/A N/A self node N/A N/A N/A identifier N/A node id N/A N/A isinstance N/A node ctx N/A ast Store N/A N/A N/A N/A N/A self _boundInScopeSoFar add identifier N/A N/A N/A N/A N/A N/A self isBoundSoFar identifier N/A isinstance N/A node ctx N/A ast Load N/A N/A N/A N/A N/A self _freeVariableMemberAccessChainsWithPos add N/A VarWithPosition var N/A identifier pos N/A N/A NodeVisitorBases PositionInFile lineno N/A node lineno col_offset N/A node col_offset N/A generic_visit N/A N/A self node N/A N/A N/A N/A N/A N/A self exclude_predicate None N/A N/A N/A self exclude_predicate node N/A N/A N/A N/A N/A super _FreeVariableMemberAccessChainsVisitor self generic_visit node N/A N/A _memberAccessChainOrNone N/A N/A pyAstNode N/A N/A N/A res N/A _memberAccessChainOrNoneImpl pyAstNode N/A N/A N/A len res 0 N/A N/A None N/A N/A tuple res N/A _memberAccessChainOrNoneImpl N/A N/A pyAstNode N/A N/A N/A N/A isinstance pyAstNode N/A ast Name N/A N/A N/A N/A pyAstNode id N/A N/A isinstance pyAstNode N/A ast Expr N/A N/A N/A _memberAccessChainOrNoneImpl N/A pyAstNode value N/A N/A isinstance pyAstNode N/A ast Attribute N/A N/A prefix N/A _memberAccessChainOrNoneImpl N/A pyAstNode value N/A N/A N/A len prefix 0 N/A N/A N/A N/A N/A N/A prefix append N/A pyAstNode attr N/A prefix N/A N/A N/A getFreeVariableMemberAccessChains N/A N/A pyAstNode isClassContext getPositions exclude_predicate N/A None False None N/A N/A pyAstNode N/A N/A PyAstUtil getRootInContext pyAstNode isClassContext N/A vis N/A _FreeVariableMemberAccessChainsVisitor exclude_predicate N/A N/A N/A vis visit pyAstNode N/A N/A N/A vis getFreeVariablesMemeberAccessChains getPositions N/A