daily update on 20240203 by nitload youmu, ExpComment[D[D[D[D[D[D[D [C[C[C[C[C[C[D[D[D[D[D[DComment Splitter ok, case code(* comment[D[D[D[D[D[D[D[D[D[D[C[C[[C[Dcomment*)code--comment and comment*)code--comment not added, may use span optimize all programme
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ExpInit.cs"
|
||||
// file="ExpCompile.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -41,13 +41,25 @@ namespace StgSharp.Script.Express
|
||||
{
|
||||
public static partial class ExpCompile
|
||||
{
|
||||
|
||||
private static ConcurrentStringHashMultiplexer _multiplexer;
|
||||
private static Dictionary<string, ExpConstantCollectionSource> _builtinConst;
|
||||
private static Dictionary<string, ExpElementInstanceBase> _builtinConst;
|
||||
private static Dictionary<string, ExpTypeSource> _builtinType;
|
||||
private static StringPool _compileStringCache;
|
||||
|
||||
public static Dictionary<string, ExpConstantCollectionSource> BuiltinConst => _builtinConst;
|
||||
|
||||
|
||||
public static Dictionary<string, ExpElementInstanceBase> BuiltinConst => _builtinConst;
|
||||
|
||||
internal static ConcurrentStringHashMultiplexer Multiplexer
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _multiplexer == null ) {
|
||||
throw new ExpCompileNotInitializedException();
|
||||
}
|
||||
return _multiplexer;
|
||||
}
|
||||
}
|
||||
|
||||
public static string AddOrGetString( string str )
|
||||
{
|
||||
@@ -59,63 +71,65 @@ namespace StgSharp.Script.Express
|
||||
_compileStringCache.Reset();
|
||||
}
|
||||
|
||||
public static bool TryGetBuiltinType(string typename, out ExpTypeSource typeSource)
|
||||
public static void SkipComment(IScriptSourceProvider source)
|
||||
{
|
||||
return _builtinType.TryGetValue( typename, out typeSource );
|
||||
}
|
||||
|
||||
public static bool TryGetBuiltinConst(string constName, out ExpConstantCollectionSource source)
|
||||
{
|
||||
return _builtinConst.TryGetValue(constName, out source);
|
||||
}
|
||||
|
||||
internal static ConcurrentStringHashMultiplexer Multiplexer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_multiplexer == null)
|
||||
{
|
||||
throw new ExpCompileNotInitializedException();
|
||||
}
|
||||
return _multiplexer;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitCompile()
|
||||
{
|
||||
_compileStringCache = new StringPool();
|
||||
_multiplexer = new ConcurrentStringHashMultiplexer();
|
||||
_builtinConst = new Dictionary<string, ExpConstantCollectionSource>(_multiplexer){
|
||||
{ AddOrGetString( "PI" ), new ExpBuiltinConst<float>(
|
||||
|
||||
_builtinType = new Dictionary<string, ExpTypeSource>( _multiplexer ) {
|
||||
{ AddOrGetString( KeyWord.Int ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Int ),typeof( int ) ) },
|
||||
{ AddOrGetString( KeyWord.Real ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Real ), typeof( float ) ) },
|
||||
{ AddOrGetString(KeyWord.Bool ), new ExpBuiltinType(
|
||||
AddOrGetString(KeyWord.Bool ), typeof( bool ) ) },
|
||||
{ AddOrGetString(KeyWord.Binary ), new ExpBuiltinType(
|
||||
AddOrGetString(KeyWord.Binary ),typeof( bool ) ) },
|
||||
{ AddOrGetString(KeyWord.String ), new ExpBuiltinType(
|
||||
AddOrGetString(KeyWord.String ),typeof( string ) ) },
|
||||
{ AddOrGetString(KeyWord.Logic ), new ExpBuiltinType(
|
||||
AddOrGetString(KeyWord.Logic ), typeof( Logic ) ) } };
|
||||
|
||||
_builtinConst = new Dictionary<string, ExpElementInstanceBase>(
|
||||
_multiplexer ) {
|
||||
{ AddOrGetString( "PI" ), new ExpBuiltinConstant<float>(
|
||||
AddOrGetString( "PI" ), MathF.PI ) },
|
||||
{ AddOrGetString( "E" ), new ExpBuiltinConst<float>(
|
||||
{ AddOrGetString( "E" ), new ExpBuiltinConstant<float>(
|
||||
AddOrGetString( "E" ), MathF.E ) },
|
||||
};
|
||||
//TODO keep on here
|
||||
_builtinType = new Dictionary<string, ExpTypeSource>(_multiplexer){
|
||||
{ AddOrGetString( KeyWord.Int ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Int ), typeof( int ) ) },
|
||||
{ AddOrGetString( KeyWord.Real ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Real ), typeof( float ) ) },
|
||||
{ AddOrGetString( KeyWord.Bool ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Bool ), typeof( bool ) ) },
|
||||
{ AddOrGetString( KeyWord.Binary ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.Binary ), typeof( bool ) ) },
|
||||
{ AddOrGetString( KeyWord.String ), new ExpBuiltinType(
|
||||
AddOrGetString( KeyWord.String ), typeof( string ) ) },
|
||||
{ AddOrGetString(KeyWord.Logic),new ExpBuiltinType(
|
||||
AddOrGetString(KeyWord.Logic), typeof(Logic)) }
|
||||
};
|
||||
}
|
||||
|
||||
public static bool TryGetBuiltinConst(
|
||||
string constName,
|
||||
out ExpElementInstanceBase source )
|
||||
{
|
||||
return _builtinConst.TryGetValue( constName, out source );
|
||||
}
|
||||
|
||||
public static bool TryGetBuiltinType(
|
||||
string typename,
|
||||
out ExpTypeSource typeSource )
|
||||
{
|
||||
return _builtinType.TryGetValue( typename, out typeSource );
|
||||
}
|
||||
|
||||
public static class KeyWord
|
||||
{
|
||||
|
||||
public const string Int = "INTAGER",
|
||||
Real = "REAL",
|
||||
Bool = "BOOLEAN",
|
||||
String = "STRING",
|
||||
Logic = "LOGIC",
|
||||
Binary = "BINARY";
|
||||
Binary = "BINARY",
|
||||
Constant = "CONSTANT";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user