C# Class IronPython.Runtime.FunctionCode

Inheritance: IExpressionSerializable
Afficher le fichier Open project: jschementi/iron Class Usage Examples

Private Properties

Свойство Type Description
AddRecursionCheck System.Delegate
CalculateArgumentCount int
Call object
CleanFunctionCodes void
CodeCleanup void
CompileLambda System.Delegate
CompileLambda System.Delegate
ExpandArgsTuple void
FromSourceUnit FunctionCode
FunctionCode System.Linq.Expressions
FunctionCode System.Linq.Expressions
GetAllCode IEnumerable
GetGeneratorOrNormalLambda LightLambdaExpression
GetGeneratorOrNormalLambdaTracing System.Linq.Expressions.LambdaExpression
GetRootCodeNoUpdating CodeList
IExpressionSerializable System.Linq.Expressions.Expression
LazyCompileFirstTarget void
LightThrowCompile void
RegisterFunctionCode void
SetDebugTarget void
SetTarget void
StringArrayToTuple PythonTuple
SymbolListToTuple PythonTuple
TupleToStringArray System.Linq.Expressions.Expression
UpdateAllCode void
UpdateDelegate void
operator IronPython.Runtime.Types.NotImplementedType

Méthodes publiques

Méthode Description
Equals ( object obj ) : bool
GetHashCode ( ) : int
__cmp__ ( CodeContext context, [ other ) : int

Private Methods

Méthode Description
AddRecursionCheck ( IronPython.Runtime.PythonContext context, Delegate finalTarget ) : Delegate
CalculateArgumentCount ( ) : int
Call ( CodeContext context ) : object
CleanFunctionCodes ( IronPython.Runtime.PythonContext context, bool synchronous ) : void
CodeCleanup ( object state ) : void
CompileLambda ( LambdaExpression code, EventHandler handler ) : Delegate
CompileLambda ( LightLambdaExpression code, EventHandler handler ) : Delegate
ExpandArgsTuple ( List names, PythonTuple toExpand ) : void
FromSourceUnit ( SourceUnit sourceUnit, IronPython.Compiler.PythonCompilerOptions options, bool register ) : FunctionCode

Creates a FunctionCode object for exec/eval/execfile'd/compile'd code. The code is then executed in a specific CodeContext by calling the .Call method. If the code is being used for compile (vs. exec/eval/execfile) then it needs to be registered incase our tracing mode changes.

FunctionCode ( IronPython.Runtime.PythonContext context, Delegate initialDelegate, Compiler scope, string documentation, bool tracing, bool register ) : System.Linq.Expressions

Constructor to create a FunctionCode at runtime. Code constructed this way supports both being interpreted and debugged. When necessary the code will be re-compiled or re-interpreted for that specific purpose. Function codes created this way do support recursion enforcement and are therefore registered in the global function code registry. the initial delegate provided here should NOT be the actual code. It should always be a delegate which updates our Target lazily.

FunctionCode ( IronPython.Runtime.PythonContext context, Delegate code, Compiler scope, string documentation, int localCount ) : System.Linq.Expressions

Constructor used to create a FunctionCode for code that's been serialized to disk. Code constructed this way cannot be interpreted or debugged using sys.settrace/sys.setprofile. Function codes created this way do support recursion enforcement and are therefore registered in the global function code registry.

GetAllCode ( IronPython.Runtime.PythonContext context ) : IEnumerable

Enumerates all function codes for updating the current type of targets we generate. While enumerating we hold a lock so that users cannot change sys.settrace/sys.setprofile until the lock is released.

GetGeneratorOrNormalLambda ( ) : LightLambdaExpression

Gets the correct final LambdaExpression for this piece of code. This is either just _lambda or _lambda re-written to be a generator expression.

GetGeneratorOrNormalLambdaTracing ( IronPython.Runtime.PythonContext context ) : LambdaExpression

Gets the LambdaExpression for tracing. If this is a generator function code then the lambda gets tranformed into the correct generator code.

GetRootCodeNoUpdating ( IronPython.Runtime.PythonContext context ) : CodeList
IExpressionSerializable ( ) : Expression
LazyCompileFirstTarget ( PythonFunction function ) : void

Called the 1st time a function is invoked by our OriginalCallTarget* methods over in PythonCallTargets. This computes the real delegate which needs to be created for the function. Usually this means starting off interpretering. It also involves adding the wrapper function for recursion enforcement. Because this can race against sys.settrace/setprofile we need to take our _ThreadIsEnumeratingAndAccountingLock to ensure no one is actively changing all of the live functions.

LightThrowCompile ( CodeContext context ) : void
RegisterFunctionCode ( IronPython.Runtime.PythonContext context ) : void

Registers the current function code in our global weak list of all function codes. The weak list can be enumerated with GetAllCode(). Ultimately there are 3 types of threads we care about races with: 1. Other threads which are registering function codes 2. Threads calling sys.settrace which require the world to stop and get updated 3. Threads running cleanup (thread pool thread, or call to gc.collect). The 1st two must have perfect synchronization. We cannot have a thread registering a new function which another thread is trying to update all of the functions in the world. Doing so would mean we could miss adding tracing to a thread. But the cleanup thread can run in parallel to either registrying or sys.settrace. The only thing it needs to take a lock for is updating our accounting information about the number of code objects are alive.

SetDebugTarget ( IronPython.Runtime.PythonContext context, Delegate target ) : void

Called to set the initial target delegate when the user has passed -X:Debug to enable .NET style debugging.

SetTarget ( Delegate target ) : void
StringArrayToTuple ( string closureVars ) : PythonTuple
SymbolListToTuple ( IList vars ) : PythonTuple
TupleToStringArray ( PythonTuple tuple ) : Expression
UpdateAllCode ( IronPython.Runtime.PythonContext context ) : void
UpdateDelegate ( IronPython.Runtime.PythonContext context, bool forceCreation ) : void

Updates the delegate based upon current Python context settings for recursion enforcement and for tracing.

operator ( ) : IronPython.Runtime.Types.NotImplementedType

Method Details

Equals() public méthode

public Equals ( object obj ) : bool
obj object
Résultat bool

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int

__cmp__() public méthode

public __cmp__ ( CodeContext context, [ other ) : int
context CodeContext
other [
Résultat int