Method | Description | |
---|---|---|
CurPos ( ) : int |
Returns the current position in the emitted code.
|
|
Emit ( int op ) : void |
Emits a zero-argument operation. Note that the emit functions all run in two modes: they can emit code, or they can just count the size of the code.
|
|
Emit ( int op, int opd1 ) : void |
Emits a one-argument operation.
|
|
Emit ( int op, int opd1, int opd2 ) : void |
Emits a two-argument operation.
|
|
EmitFragment ( int nodetype, |
The main RegexCode generator. It does a depth-first walk through the tree and calls EmitFragment to emits code before and after each child of an interior node, and at each leaf.
|
|
EmptyStack ( ) : bool |
|
|
MapCapnum ( int capnum ) : int |
When generating code on a regex that uses a sparse set of capture slots, we hash them to a dense set of indices for an array of capture slots. Instead of doing the hash at match time, it's done at compile time, here.
|
|
PatchJump ( int offset, int jumpDest ) : void |
Fixes up a jump instruction at the specified offset so that it jumps to the specified jumpDest.
|
|
PopInt ( ) : int |
This is the pop.
|
|
PushInt ( int i ) : void |
To avoid recursion, we use a simple integer stack. This is the push.
|
|
RegexCodeFromRegexTree ( |
The top level RegexCode generator. It does a depth-first walk through the tree and calls EmitFragment to emits code before and after each child of an interior node, and at each leaf. It runs two passes, first to count the size of the generated code, and second to generate the code. We should time it against the alternative, which is to just generate the code and grow the array as we go.
|
|
RegexWriter ( ) : System.Collections | ||
StringCode ( string str ) : int |
Returns an index in the string table for a string; uses a hashtable to eliminate duplicates.
|
|
Write ( |
This is the only function that should be called from outside. It takes a RegexTree and creates a corresponding RegexCode.
|