Daily update on 20250325-164701 by Nitload Youmu. Additional Message : Lineaar line and multi-linear line compile full function. String literal parsing improve.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -41,20 +41,19 @@ namespace StgSharp.Script.Express
|
||||
public class ExpInstanceMemberNode : ExpNode
|
||||
{
|
||||
|
||||
private ExpElementInstanceBase _instance;
|
||||
private ExpElementInstance _instance;
|
||||
private ExpElementMemberNameNode _memberName;
|
||||
private ExpNode _member;
|
||||
|
||||
public ExpInstanceMemberNode(
|
||||
Token source,
|
||||
ExpElementInstanceBase instance,
|
||||
ExpElementMemberNameNode memberName )
|
||||
Token source,
|
||||
ExpElementInstance instance,
|
||||
ExpElementMemberNameNode memberName )
|
||||
: base( source )
|
||||
{
|
||||
_instance = instance;
|
||||
_memberName = memberName;
|
||||
_instance.TryGetMember(
|
||||
memberName.CodeConvertTemplate, out _member );
|
||||
_instance.TryGetMember( memberName.CodeConvertTemplate, out _member );
|
||||
}
|
||||
|
||||
public override ExpNode Left => _instance;
|
||||
|
||||
@@ -40,13 +40,14 @@ namespace StgSharp.Script.Express
|
||||
public class ExpInstanceReferenceNode : ExpNode
|
||||
{
|
||||
|
||||
private ExpElementInstanceBase _instance;
|
||||
private ExpElementInstance _instance;
|
||||
|
||||
internal ExpInstanceReferenceNode( Token source, ExpElementInstanceBase instance )
|
||||
internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance )
|
||||
: base( source )
|
||||
{
|
||||
_instance = instance;
|
||||
_nodeFlag = ( _instance._nodeFlag | ( ExpNodeFlag.Name_Any | ExpNodeFlag.Collection_Any ) );
|
||||
CodeConvertTemplate = source.Value;
|
||||
}
|
||||
|
||||
internal ExpInstanceReferenceNode( Token source, ExpInstanceReferenceNode reference )
|
||||
@@ -64,11 +65,15 @@ namespace StgSharp.Script.Express
|
||||
public override IExpElementSource EqualityTypeConvert => _instance.EqualityTypeConvert;
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpInstanceReferenceNode Create(
|
||||
public static ExpInstanceReferenceNode MakeReferenceFrom(
|
||||
Token source,
|
||||
ExpElementInstanceBase instance )
|
||||
ExpElementInstance instance )
|
||||
{
|
||||
/*
|
||||
/**/
|
||||
if( instance.IsLiteral )
|
||||
{
|
||||
throw new ExpCompileException( source, "Cannot make reference to a literal." );
|
||||
}
|
||||
if( instance.CodeConvertTemplate != source.Value ) {
|
||||
throw new ExpCompileException( source, "Token point at a wrong instance" );
|
||||
}
|
||||
|
||||
@@ -34,26 +34,28 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpIntNode : ExpElementInstanceBase
|
||||
public class ExpIntNode : ExpElementInstance
|
||||
{
|
||||
|
||||
private int _value;
|
||||
|
||||
public ExpIntNode( Token source, int value )
|
||||
public ExpIntNode( Token source, int value, bool isLiteral )
|
||||
: base( source )
|
||||
{
|
||||
this.IsLiteral = isLiteral;
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Type;
|
||||
CodeConvertTemplate = IsLiteral ? value.ToString() : source.Value;
|
||||
}
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpressCompile.Keyword.Integer,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
get => ExpressCompile.ExpInt;
|
||||
}
|
||||
|
||||
public int Value => _value;
|
||||
|
||||
@@ -61,23 +63,24 @@ namespace StgSharp.Script.Express
|
||||
|
||||
}
|
||||
|
||||
public class ExpStringNode : ExpElementInstanceBase
|
||||
public class ExpStringNode : ExpElementInstance
|
||||
{
|
||||
|
||||
private readonly string _value;
|
||||
|
||||
public ExpStringNode( Token source, string value )
|
||||
public ExpStringNode( Token source, string value, bool isLiteral )
|
||||
: base( source )
|
||||
{
|
||||
this.IsLiteral = IsLiteral;
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_String | ExpNodeFlag.Element_Type;
|
||||
CodeConvertTemplate = IsLiteral ? $"\"{value}\"" : source.Value;
|
||||
}
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpressCompile.Keyword.String,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
get => ExpressCompile.ExpString;
|
||||
}
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
@@ -85,73 +88,81 @@ namespace StgSharp.Script.Express
|
||||
|
||||
}
|
||||
|
||||
public class ExpBoolNode : ExpElementInstanceBase
|
||||
public class ExpBoolNode : ExpElementInstance
|
||||
{
|
||||
|
||||
private readonly bool _value;
|
||||
|
||||
public ExpBoolNode( Token source, bool value )
|
||||
public ExpBoolNode( Token source, bool value, bool isLiteral )
|
||||
: base( source )
|
||||
{
|
||||
this.IsLiteral = isLiteral;
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Element_Type;
|
||||
CodeConvertTemplate = IsLiteral ? value.ToString() : source.Value;
|
||||
}
|
||||
|
||||
public bool Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpressCompile.Keyword.Boolean,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
get => ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpressCompile.Keyword.Boolean, out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
}
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
}
|
||||
|
||||
public class ExpRealNumberNode : ExpElementInstanceBase
|
||||
public class ExpRealNumberNode : ExpElementInstance
|
||||
{
|
||||
|
||||
private readonly float _value;
|
||||
|
||||
public ExpRealNumberNode( Token source, float value )
|
||||
public ExpRealNumberNode( Token source, float value, bool isLiteral )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Real | ExpNodeFlag.Element_Type;
|
||||
CodeConvertTemplate = isLiteral ? $"{value:F8}f" : source.Value;
|
||||
}
|
||||
|
||||
public float Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpressCompile.Keyword.String,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
get => ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpressCompile.Keyword.String, out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
}
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
}
|
||||
|
||||
public class ExpLogicValueNode : ExpElementInstanceBase
|
||||
public class ExpLogicValueNode : ExpElementInstance
|
||||
{
|
||||
|
||||
private readonly ExpLogic _value;
|
||||
|
||||
public ExpLogicValueNode( Token source, ExpLogic value )
|
||||
public ExpLogicValueNode( Token source, ExpLogic value, bool isLiteral )
|
||||
: base( source )
|
||||
{
|
||||
this.IsLiteral = isLiteral;
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.Element_Type;
|
||||
CodeConvertTemplate = isLiteral ? value.ToString() : source.Value;
|
||||
}
|
||||
|
||||
public ExpLogic Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpressCompile.Keyword.Logical,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
get => ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpressCompile.Keyword.Logical, out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
}
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
|
||||
@@ -41,43 +41,44 @@ namespace StgSharp.Script.Express
|
||||
|
||||
//TODO: Current code cannot represent full functionality defined in ISO10303, need rewrite.
|
||||
|
||||
private ExpElementInstanceBase _variable, _begin, _end, _increment;
|
||||
private ExpElementInstance _variable, _begin, _end, _increment;
|
||||
|
||||
private ExpNode _operationBegin;
|
||||
|
||||
public ExpRepeatNode(
|
||||
Token source,
|
||||
ExpNode operationBegin,
|
||||
ExpElementInstanceBase variable,
|
||||
ExpElementInstanceBase begin,
|
||||
ExpElementInstanceBase end,
|
||||
ExpElementInstanceBase increment )
|
||||
Token source,
|
||||
ExpNode operationBegin,
|
||||
ExpElementInstance variable,
|
||||
ExpElementInstance begin,
|
||||
ExpElementInstance end,
|
||||
ExpElementInstance increment )
|
||||
: base( source )
|
||||
{
|
||||
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag !=
|
||||
end.NodeFlag || ( increment != null && end.NodeFlag !=
|
||||
increment.NodeFlag ) ) {
|
||||
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag != end.NodeFlag || ( increment !=
|
||||
null && end.NodeFlag !=
|
||||
increment.NodeFlag ) ) {
|
||||
throw new InvalidCastException();
|
||||
}
|
||||
if( increment == null ) {
|
||||
switch( ( ExpNodeFlag )variable.NodeFlag | ExpNodeFlag.BuiltinType_Any ) {
|
||||
if( increment == null )
|
||||
{
|
||||
switch( ( ExpNodeFlag )variable.NodeFlag | ExpNodeFlag.BuiltinType_Any )
|
||||
{
|
||||
case ExpNodeFlag.BuiltinType_Real:
|
||||
increment = new ExpRealNumberNode(
|
||||
new Token(
|
||||
ExpressCompile.PoolString( "1.0f" ), source.Line,
|
||||
-1, TokenFlag.Number ),
|
||||
1.0f );
|
||||
ExpressCompile.PoolString( "1.0f" ), source.Line, -1,
|
||||
TokenFlag.Number ),
|
||||
1.0f, isLiteral: true );
|
||||
break;
|
||||
case ExpNodeFlag.BuiltinType_Int:
|
||||
increment = new ExpIntNode(
|
||||
new Token(
|
||||
ExpressCompile.PoolString( "1" ), source.Line, -1,
|
||||
TokenFlag.Number ),
|
||||
1 );
|
||||
1, isLiteral: true );
|
||||
break;
|
||||
default:
|
||||
throw new ExpInvalidTypeException(
|
||||
"Int or Real", "otherwise" );
|
||||
throw new ExpInvalidTypeException( "Int or Real", "otherwise" );
|
||||
}
|
||||
}
|
||||
_begin = begin;
|
||||
|
||||
Reference in New Issue
Block a user