daily update on 20250210 by nitload youmu
This commit is contained in:
@@ -38,28 +38,24 @@ namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpConstantCollectionSource : IExpImmutableElement
|
||||
{
|
||||
private IScriptSourceProvider _sourceProvider;
|
||||
|
||||
private Dictionary<string, ExpElementInstanceBase> _constants;
|
||||
private IScriptSourceProvider _sourceProvider;
|
||||
|
||||
public ExpConstantCollectionSource(
|
||||
IScriptSourceProvider sourceProvider )
|
||||
{
|
||||
_sourceProvider = sourceProvider;
|
||||
_constants = new Dictionary<string, ExpElementInstanceBase>(
|
||||
ExpCompile.Multiplexer);
|
||||
ExpCompile.Multiplexer );
|
||||
}
|
||||
|
||||
internal void AddConstant(string name, ExpElementInstanceBase value)
|
||||
{
|
||||
_constants.Add(name, value);
|
||||
}
|
||||
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => ExpCompile.BuiltinConst;
|
||||
|
||||
public ExpElementType ElementType => ExpElementType.Const;
|
||||
|
||||
public IScriptSourceProvider SourceProvider => _sourceProvider;
|
||||
|
||||
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => ExpCompile.BuiltinConst;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => ExpCompile.KeyWord.Constant;
|
||||
@@ -70,26 +66,32 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ExpToken MakeReference(params object[] options)
|
||||
public ExpToken MakeReference( params object[] options )
|
||||
{
|
||||
if (options.Length == 0 || options[0] is not string str)
|
||||
{
|
||||
if( options.Length == 0 || options[ 0 ] is not string str ) {
|
||||
return null!;
|
||||
}
|
||||
if (_constants.Count == 0)
|
||||
{
|
||||
if( _constants.Count == 0 ) {
|
||||
return null!;
|
||||
}
|
||||
if (_constants.TryGetValue(str, out var token))
|
||||
{
|
||||
if( _constants.TryGetValue( str,
|
||||
out ExpElementInstanceBase? token ) ) {
|
||||
return token;
|
||||
}
|
||||
return null!;
|
||||
}
|
||||
|
||||
public bool TryGetConstant(string name, out ExpElementInstanceBase instance)
|
||||
public bool TryGetConstant(
|
||||
string name,
|
||||
out ExpElementInstanceBase instance )
|
||||
{
|
||||
return _constants.TryGetValue(name, out instance);
|
||||
return _constants.TryGetValue( name, out instance );
|
||||
}
|
||||
|
||||
internal void AddConstant( string name, ExpElementInstanceBase value )
|
||||
{
|
||||
_constants.Add( name, value );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user