Class NamingStrategies
The default naming strategies.
Inheritance
Inherited Members
Namespace: Loretta.CodeAnalysis.Lua.Experimental.Minifying
Assembly: Loretta.CodeAnalysis.Lua.Experimental.dll
Syntax
public static class NamingStrategies
Methods
| Improve this Doc View SourceAlphabetical(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:
prefix
is'_'
alphabet
is"a", "b" and "c"
- The provided IScope has two variables in scope named 'a' and 'b'.
- Slot 0:
_a
(asa
is already in scope) - Slot 1:
_b
(asb
is already in scope) - Slot 2:
c
(as there is noc
already 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 |