Class NamingStrategies
The default naming strategies.
Inheritance
Inherited Members
Namespace: Loretta.CodeAnalysis.Lua.Experimental.Minifying
Assembly: cs.temp.dll.dll
Syntax
public static class NamingStrategies
Methods
Alphabetical(Int32, IEnumerable<IScope>)
The alphabet naming strategy. This is similar to Sequential(Char, ImmutableArray<String>) with:
prefix as _
and alphabet as abcdefghijklmnopqrstuvwxyz.
Declaration
public static string Alphabetical(int slot, IEnumerable<IScope> scopes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | slot | |
| IEnumerable<IScope> | scopes |
Returns
| Type | Description |
|---|---|
| System.String |
Numerical(Int32, IEnumerable<IScope>)
The alphabet naming strategy. This is similar to Sequential(Char, ImmutableArray<String>) with:
prefix as _
and alphabet as 0123456789.
Declaration
public static string Numerical(int slot, IEnumerable<IScope> scopes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | slot | |
| IEnumerable<IScope> | scopes |
Returns
| Type | Description |
|---|---|
| System.String |
Sequential(Char, ImmutableArray<String>)
The sequential naming strategy factory method.
It'll create a NamingStrategy delegate using
the provided prefix and alphabet.
Declaration
public static NamingStrategy Sequential(char prefix, ImmutableArray<string> alphabet)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | prefix | The prefix to use when a variable of the same name is found. |
| ImmutableArray<System.String> | alphabet | The alphabet to use. Each character will be a single item. |
Returns
| Type | Description |
|---|---|
| NamingStrategy |
Remarks
To provide an example of how this strategy works, let's assume the following:
prefixis'_'alphabetis"a", "b" and "c"- The provided IScope has two variables in scope named 'a' and 'b'.
- Slot 0:
_a(asais already in scope) - Slot 1:
_b(asbis already in scope) - Slot 2:
c(as there is nocalready in scope) - Slot 3:
aa - Slot 13:
aaa - Slot 40:
aaaa
ZeroWidth(Int32, IEnumerable<IScope>)
The non-printable characters naming strategy. ONLY WORKS WHEN TARGETTING LUAJIT.
This works like Sequential(Char, ImmutableArray<String>).
With prefix as _ and alphabet as zero width unicode characters.
It is more optimized than Sequential(Char, ImmutableArray<String>) so use this
instead of it whenever possible.
Declaration
public static string ZeroWidth(int slot, IEnumerable<IScope> scopes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | slot | |
| IEnumerable<IScope> | scopes |
Returns
| Type | Description |
|---|---|
| System.String |