Pipes and test scripts
This commit is contained in:
@@ -3,7 +3,7 @@ unit Myc.Ast.RTL.Core;
|
||||
interface
|
||||
|
||||
uses
|
||||
system.sysutils,
|
||||
System.SysUtils,
|
||||
Myc.Utils,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Value,
|
||||
@@ -16,233 +16,233 @@ type
|
||||
// (* --- Dynamic Fallbacks (Interpreter) --- *)
|
||||
|
||||
// Arithmetic
|
||||
[TRtlExport('+')]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add(const Args: TArray<TDataValue>): TDataValue; overload; static;
|
||||
[TRtlExport('-')]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Subtract(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('*')]
|
||||
[TRtlExport('*', Pure)]
|
||||
class function Multiply(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('/')]
|
||||
[TRtlExport('/', Pure)]
|
||||
class function Divide(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
[TRtlExport('div')]
|
||||
[TRtlExport('div', Pure)]
|
||||
class function IntDivide(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('mod')]
|
||||
[TRtlExport('mod', Pure)]
|
||||
class function Modulus(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
// Comparison
|
||||
[TRtlExport('=')]
|
||||
[TRtlExport('=', Impure)]
|
||||
class function Equal(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('<>')]
|
||||
[TRtlExport('<>', Impure)]
|
||||
class function NotEqual(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('<')]
|
||||
[TRtlExport('<', Impure)]
|
||||
class function LessThan(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('<=')]
|
||||
[TRtlExport('<=', Impure)]
|
||||
class function LessThanOrEqual(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('>')]
|
||||
[TRtlExport('>', Impure)]
|
||||
class function GreaterThan(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('>=')]
|
||||
[TRtlExport('>=', Impure)]
|
||||
class function GreaterThanOrEqual(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
// Logic / Bitwise
|
||||
[TRtlExport('not')]
|
||||
[TRtlExport('not', Impure)]
|
||||
class function LogicalNot(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('and')]
|
||||
[TRtlExport('and', Impure)]
|
||||
class function BitwiseAnd(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('or')]
|
||||
[TRtlExport('or', Impure)]
|
||||
class function BitwiseOr(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('xor')]
|
||||
[TRtlExport('xor', Impure)]
|
||||
class function BitwiseXor(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('shl')]
|
||||
[TRtlExport('shl', Impure)]
|
||||
class function LeftShift(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('shr')]
|
||||
[TRtlExport('shr', Impure)]
|
||||
class function RightShift(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
// (* Dynamic fallbacks for TScalar input *)
|
||||
[TRtlExport('Abs')]
|
||||
[TRtlExport('Abs', Impure)]
|
||||
class function Abs(const Arg: TScalar): TScalar; static;
|
||||
[TRtlExport('Round')]
|
||||
[TRtlExport('Round', Impure)]
|
||||
class function Round(const Arg: TScalar): TScalar; static;
|
||||
[TRtlExport('Trunc')]
|
||||
[TRtlExport('Trunc', Impure)]
|
||||
class function Trunc(const Arg: TScalar): TScalar; static;
|
||||
[TRtlExport('Ceil')]
|
||||
[TRtlExport('Ceil', Impure)]
|
||||
class function Ceil(const Arg: TScalar): TScalar; static;
|
||||
[TRtlExport('Floor')]
|
||||
[TRtlExport('Floor', Impure)]
|
||||
class function Floor(const Arg: TScalar): TScalar; static;
|
||||
[TRtlExport('Sign')]
|
||||
[TRtlExport('Sign', Impure)]
|
||||
class function Sign(const Arg: TScalar): TScalar; static;
|
||||
|
||||
// (* DateTime Constructors *)
|
||||
[TRtlExport('Now', False)]
|
||||
[TRtlExport('Now', Impure)]
|
||||
class function Now(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('Date')]
|
||||
[TRtlExport('Date', Impure)]
|
||||
class function Date(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
// (* Other dynamic functions *)
|
||||
[TRtlExport('Memoize')]
|
||||
[TRtlExport('Memoize', Impure)]
|
||||
class function Memoize(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('Map')]
|
||||
[TRtlExport('Map', Impure)]
|
||||
class function Map(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('Reduce')]
|
||||
[TRtlExport('Reduce', Impure)]
|
||||
class function Reduce(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('Where')]
|
||||
[TRtlExport('Where', Impure)]
|
||||
class function Where(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
[TRtlExport('Any')]
|
||||
[TRtlExport('Any', Impure)]
|
||||
class function Any(const Args: TArray<TDataValue>): TDataValue; static;
|
||||
|
||||
// (* --- Static Specializations (Monomorphization Targets) --- *)
|
||||
|
||||
// Add
|
||||
[TRtlExport('+', True)]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('+', True)]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add_Float_Float_Float(A, B: Double): Double; static;
|
||||
[TRtlExport('+', True)]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add_Ordinal_Float_Float(A: Int64; B: Double): Double; static;
|
||||
[TRtlExport('+', True)]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add_Float_Ordinal_Float(A: Double; B: Int64): Double; static;
|
||||
[TRtlExport('+', True)]
|
||||
[TRtlExport('+', Pure)]
|
||||
class function Add_Text_Text_Text(const A: String; const B: String): String; static;
|
||||
|
||||
// Subtract
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Subtract_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Subtract_Float_Float_Float(A, B: Double): Double; static;
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Subtract_Ordinal_Float_Float(A: Int64; B: Double): Double; static;
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Subtract_Float_Ordinal_Float(A: Double; B: Int64): Double; static;
|
||||
|
||||
// Multiply
|
||||
[TRtlExport('*', True)]
|
||||
[TRtlExport('*', Pure)]
|
||||
class function Multiply_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('*', True)]
|
||||
[TRtlExport('*', Pure)]
|
||||
class function Multiply_Float_Float_Float(A, B: Double): Double; static;
|
||||
[TRtlExport('*', True)]
|
||||
[TRtlExport('*', Pure)]
|
||||
class function Multiply_Ordinal_Float_Float(A: Int64; B: Double): Double; static;
|
||||
[TRtlExport('*', True)]
|
||||
[TRtlExport('*', Pure)]
|
||||
class function Multiply_Float_Ordinal_Float(A: Double; B: Int64): Double; static;
|
||||
|
||||
// Divide (Impure due to EDivByZero potential)
|
||||
[TRtlExport('/')]
|
||||
[TRtlExport('/', Impure)]
|
||||
class function Divide_Ordinal_Ordinal_Float(A, B: Int64): Double; static;
|
||||
[TRtlExport('/')]
|
||||
[TRtlExport('/', Impure)]
|
||||
class function Divide_Float_Float_Float(A, B: Double): Double; static;
|
||||
[TRtlExport('/')]
|
||||
[TRtlExport('/', Impure)]
|
||||
class function Divide_Ordinal_Float_Float(A: Int64; B: Double): Double; static;
|
||||
[TRtlExport('/')]
|
||||
[TRtlExport('/', Impure)]
|
||||
class function Divide_Float_Ordinal_Float(A: Double; B: Int64): Double; static;
|
||||
|
||||
// Integer Math (Impure due to EDivByZero)
|
||||
[TRtlExport('div')]
|
||||
[TRtlExport('div', Impure)]
|
||||
class function Div_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('mod')]
|
||||
[TRtlExport('mod', Impure)]
|
||||
class function Mod_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
|
||||
// Comparisons
|
||||
[TRtlExport('=', True)]
|
||||
[TRtlExport('=', Pure)]
|
||||
class function Equal_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('=', True)]
|
||||
[TRtlExport('=', Pure)]
|
||||
class function Equal_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('=', True)]
|
||||
[TRtlExport('=', Pure)]
|
||||
class function Equal_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('=', True)]
|
||||
[TRtlExport('=', Pure)]
|
||||
class function Equal_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
[TRtlExport('=', True)]
|
||||
[TRtlExport('=', Pure)]
|
||||
class function Equal_Keyword_Keyword_Ordinal(A, B: Int64): Int64; static;
|
||||
|
||||
[TRtlExport('<>', True)]
|
||||
[TRtlExport('<>', Pure)]
|
||||
class function NotEqual_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('<>', True)]
|
||||
[TRtlExport('<>', Pure)]
|
||||
class function NotEqual_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('<>', True)]
|
||||
[TRtlExport('<>', Pure)]
|
||||
class function NotEqual_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('<>', True)]
|
||||
[TRtlExport('<>', Pure)]
|
||||
class function NotEqual_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
[TRtlExport('<>', True)]
|
||||
[TRtlExport('<>', Pure)]
|
||||
class function NotEqual_Keyword_Keyword_Ordinal(A, B: Int64): Int64; static;
|
||||
|
||||
[TRtlExport('<', True)]
|
||||
[TRtlExport('<', Pure)]
|
||||
class function Less_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('<', True)]
|
||||
[TRtlExport('<', Pure)]
|
||||
class function Less_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('<', True)]
|
||||
[TRtlExport('<', Pure)]
|
||||
class function Less_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('<', True)]
|
||||
[TRtlExport('<', Pure)]
|
||||
class function Less_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
|
||||
[TRtlExport('<=', True)]
|
||||
[TRtlExport('<=', Pure)]
|
||||
class function LessOrEqual_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('<=', True)]
|
||||
[TRtlExport('<=', Pure)]
|
||||
class function LessOrEqual_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('<=', True)]
|
||||
[TRtlExport('<=', Pure)]
|
||||
class function LessOrEqual_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('<=', True)]
|
||||
[TRtlExport('<=', Pure)]
|
||||
class function LessOrEqual_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
|
||||
[TRtlExport('>', True)]
|
||||
[TRtlExport('>', Pure)]
|
||||
class function Greater_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('>', True)]
|
||||
[TRtlExport('>', Pure)]
|
||||
class function Greater_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('>', True)]
|
||||
[TRtlExport('>', Pure)]
|
||||
class function Greater_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('>', True)]
|
||||
[TRtlExport('>', Pure)]
|
||||
class function Greater_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
|
||||
[TRtlExport('>=', True)]
|
||||
[TRtlExport('>=', Pure)]
|
||||
class function GreaterOrEqual_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('>=', True)]
|
||||
[TRtlExport('>=', Pure)]
|
||||
class function GreaterOrEqual_Float_Float_Ordinal(A, B: Double): Int64; static;
|
||||
[TRtlExport('>=', True)]
|
||||
[TRtlExport('>=', Pure)]
|
||||
class function GreaterOrEqual_Ordinal_Float_Ordinal(A: Int64; B: Double): Int64; static;
|
||||
[TRtlExport('>=', True)]
|
||||
[TRtlExport('>=', Pure)]
|
||||
class function GreaterOrEqual_Float_Ordinal_Ordinal(A: Double; B: Int64): Int64; static;
|
||||
|
||||
// Bitwise Static
|
||||
[TRtlExport('and', True)]
|
||||
[TRtlExport('and', Pure)]
|
||||
class function And_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('or', True)]
|
||||
[TRtlExport('or', Pure)]
|
||||
class function Or_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('xor', True)]
|
||||
[TRtlExport('xor', Pure)]
|
||||
class function Xor_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('shl', True)]
|
||||
[TRtlExport('shl', Pure)]
|
||||
class function Shl_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
[TRtlExport('shr', True)]
|
||||
[TRtlExport('shr', Pure)]
|
||||
class function Shr_Ordinal_Ordinal_Ordinal(A, B: Int64): Int64; static;
|
||||
|
||||
// Unary
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Negate_Ordinal_Ordinal(A: Int64): Int64; static;
|
||||
[TRtlExport('-', True)]
|
||||
[TRtlExport('-', Pure)]
|
||||
class function Negate_Float_Float(A: Double): Double; static;
|
||||
|
||||
[TRtlExport('not', True)]
|
||||
[TRtlExport('not', Pure)]
|
||||
class function Not_Ordinal_Ordinal(A: Int64): Int64; static;
|
||||
|
||||
// Standard functions
|
||||
[TRtlExport('Abs', True)]
|
||||
[TRtlExport('Abs', Pure)]
|
||||
class function Abs_Ordinal_Ordinal(A: Int64): Int64; static;
|
||||
[TRtlExport('Abs', True)]
|
||||
[TRtlExport('Abs', Pure)]
|
||||
class function Abs_Float_Float(A: Double): Double; static;
|
||||
|
||||
[TRtlExport('Round', True)]
|
||||
[TRtlExport('Round', Pure)]
|
||||
class function Round_Ordinal_Ordinal(A: Int64): Int64; static;
|
||||
[TRtlExport('Round', True)]
|
||||
[TRtlExport('Round', Pure)]
|
||||
class function Round_Float_Ordinal(A: Double): Int64; static;
|
||||
|
||||
[TRtlExport('Trunc', True)]
|
||||
[TRtlExport('Trunc', Pure)]
|
||||
class function Trunc_Ordinal_Ordinal(A: Int64): Int64; static;
|
||||
[TRtlExport('Trunc', True)]
|
||||
[TRtlExport('Trunc', Pure)]
|
||||
class function Trunc_Float_Ordinal(A: Double): Int64; static;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
system.generics.collections,
|
||||
system.math,
|
||||
system.dateutils,
|
||||
System.Generics.Collections,
|
||||
System.Math,
|
||||
System.Dateutils,
|
||||
Myc.Data.Decimal;
|
||||
|
||||
{ TRtlFunctions - Operator Implementations }
|
||||
|
||||
Reference in New Issue
Block a user