Major refactoring, split Bound Ast from source Ast
This commit is contained in:
@@ -9,7 +9,7 @@ uses
|
||||
Myc.Data.Series;
|
||||
|
||||
type
|
||||
TDataValueKind = (vkVoid, vkScalar, vkText, vkSeries, vkRecordSeries, vkRecord, vkManagedObject, vkMethod, vkGeneric);
|
||||
TDataValueKind = (vkVoid, vkScalar, vkText, vkSeries, vkRecordSeries, vkRecord, vkManagedObject, vkMethod, vkInterface, vkGeneric);
|
||||
|
||||
TDataValue = record
|
||||
type
|
||||
@@ -58,6 +58,9 @@ type
|
||||
class operator Implicit(const AValue: TDataValue.TFunc): TDataValue; overload; inline;
|
||||
class operator Implicit(const AValue: TObject): TDataValue; overload; inline;
|
||||
|
||||
class function FromIntf<T: IInterface>(const AValue: T): TDataValue; static;
|
||||
function AsIntf<T: IInterface>: T; inline;
|
||||
|
||||
class function FromGeneric<T>(const [ref] AValue: T): TDataValue; static; inline;
|
||||
function AsGeneric<T>: T; inline;
|
||||
|
||||
@@ -222,6 +225,15 @@ begin
|
||||
Result := TVal<T>(FInterface).Value;
|
||||
end;
|
||||
|
||||
function TDataValue.AsIntf<T>: T;
|
||||
begin
|
||||
if FKind = Ord(vkLazy) then
|
||||
exit(AsLazy.Value.AsGeneric<T>);
|
||||
if FKind <> Ord(vkInterface) then
|
||||
raise EInvalidCast.Create('Cannot read value as interface.');
|
||||
Result := T(FInterface);
|
||||
end;
|
||||
|
||||
function TDataValue.AsObject: TObject;
|
||||
begin
|
||||
if FKind = Ord(vkLazy) then
|
||||
@@ -296,6 +308,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TDataValue.FromIntf<T>(const AValue: T): TDataValue;
|
||||
begin
|
||||
Result.FKind := Ord(vkInterface);
|
||||
Result.FInterface := IInterface(AValue);
|
||||
end;
|
||||
|
||||
class function TDataValue.FromGeneric<T>(const [ref] AValue: T): TDataValue;
|
||||
begin
|
||||
Result.FKind := Ord(vkGeneric);
|
||||
|
||||
Reference in New Issue
Block a user