C# Class NGettext.PluralCompile.Compiler.PluralRuleCompiler

Compiler that compiles a plural rule abstract syntax tree into a managed dynamic method delegate using an IL code generator.
Mostra file Open project: neris/NGettext Class Usage Examples

Public Methods

Method Description
CompileToDynamicMethod ( Token astRoot, Type outputDelegateType ) : Delegate

Compiles a plural rule abstract syntax tree into managed dynamic method delegate using an IL code generator.

Protected Methods

Method Description
CompileFinish ( ILGenerator il ) : void

Emits instructions required for compilation stop procedure.

CompileNode ( ILGenerator il, Token node ) : void

Recursively compiles an AST node to the IL instructions.

CompileStart ( ILGenerator il ) : void

Emits instructions required for compilation start procedure.

CreateDynamicMethod ( Type outputDelegateType ) : DynamicMethod

Creates a new DynamicMethod instance with signature of given delegate type.

EmitConditionalBranch ( ILGenerator il, OpCode conditionOpCode, Token trueNode, Token falseNode ) : void

Emits instructions required for conditional branch using given OpCode to check condition and given nodes for positive and negative branches.

EmitConditionalValue ( ILGenerator il, OpCode conditionOpCode, long trueValue = 1, long falseValue ) : void

Emits instructions required for creating a value on the stack based on specified condition operation result.

We can not use simplified OpCodes.Clt, OpCodes.Cgt and similar instructions because we use an Int64 as an argument value.

Method Details

CompileFinish() protected method

Emits instructions required for compilation stop procedure.
protected CompileFinish ( ILGenerator il ) : void
il System.Reflection.Emit.ILGenerator IL generator instance.
return void

CompileNode() protected method

Recursively compiles an AST node to the IL instructions.
protected CompileNode ( ILGenerator il, Token node ) : void
il System.Reflection.Emit.ILGenerator IL generator instance.
node NGettext.Plural.Ast.Token AST node.
return void

CompileStart() protected method

Emits instructions required for compilation start procedure.
protected CompileStart ( ILGenerator il ) : void
il System.Reflection.Emit.ILGenerator IL generator instance.
return void

CompileToDynamicMethod() public method

Compiles a plural rule abstract syntax tree into managed dynamic method delegate using an IL code generator.
public CompileToDynamicMethod ( Token astRoot, Type outputDelegateType ) : Delegate
astRoot NGettext.Plural.Ast.Token abstract syntax tree root node.
outputDelegateType System.Type Type of output delegate.
return System.Delegate

CreateDynamicMethod() protected method

Creates a new DynamicMethod instance with signature of given delegate type.
protected CreateDynamicMethod ( Type outputDelegateType ) : DynamicMethod
outputDelegateType System.Type
return System.Reflection.Emit.DynamicMethod

EmitConditionalBranch() protected method

Emits instructions required for conditional branch using given OpCode to check condition and given nodes for positive and negative branches.
protected EmitConditionalBranch ( ILGenerator il, OpCode conditionOpCode, Token trueNode, Token falseNode ) : void
il System.Reflection.Emit.ILGenerator IL generator instance.
conditionOpCode System.Reflection.Emit.OpCode OpCode of the condition check operation.
trueNode NGettext.Plural.Ast.Token AST node that will be executed when condition returns positive result.
falseNode NGettext.Plural.Ast.Token AST node that will be executed when condition returns negative result.
return void

EmitConditionalValue() protected method

Emits instructions required for creating a value on the stack based on specified condition operation result.
We can not use simplified OpCodes.Clt, OpCodes.Cgt and similar instructions because we use an Int64 as an argument value.
protected EmitConditionalValue ( ILGenerator il, OpCode conditionOpCode, long trueValue = 1, long falseValue ) : void
il System.Reflection.Emit.ILGenerator IL generator instance.
conditionOpCode System.Reflection.Emit.OpCode OpCode of the condition check operation.
trueValue long A value that will be put on stack when condition returns positive result.
falseValue long A value that will be put on stack when condition returns negative result.
return void