Ast Playground 1. visualization
This commit is contained in:
@@ -201,14 +201,14 @@ uses
|
||||
System.Classes;
|
||||
|
||||
type
|
||||
// Private interface to encapsulate a string value for reference counting.
|
||||
IAstTextValue = interface(IInterface)
|
||||
// Private interface to encapsulate a non scalar value for reference counting.
|
||||
IAstValue<T> = interface
|
||||
function GetValue: string;
|
||||
property Value: string read GetValue;
|
||||
end;
|
||||
|
||||
// Implementation of the text value interface.
|
||||
TAstTextValue = class(TInterfacedObject, IAstTextValue)
|
||||
TAstValue<T> = class(TInterfacedObject, IAstValue<T>)
|
||||
private
|
||||
FValue: string;
|
||||
function GetValue: string;
|
||||
@@ -216,15 +216,15 @@ type
|
||||
constructor Create(const AValue: string);
|
||||
end;
|
||||
|
||||
{ TAstTextValue }
|
||||
{ TAstValue }
|
||||
|
||||
constructor TAstTextValue.Create(const AValue: string);
|
||||
constructor TAstValue<T>.Create(const AValue: string);
|
||||
begin
|
||||
inherited Create;
|
||||
FValue := AValue;
|
||||
end;
|
||||
|
||||
function TAstTextValue.GetValue: string;
|
||||
function TAstValue<T>.GetValue: string;
|
||||
begin
|
||||
Result := FValue;
|
||||
end;
|
||||
@@ -255,7 +255,7 @@ function TAstValue.AsText: String;
|
||||
begin
|
||||
if (FKind <> avkText) then
|
||||
raise EInvalidCast.Create('Cannot read value as Text.');
|
||||
Result := IAstTextValue(FInterface).Value;
|
||||
Result := IAstValue<String>(FInterface).Value;
|
||||
end;
|
||||
|
||||
class function TAstValue.FromClosure(const AValue: IEvaluatorClosure): TAstValue;
|
||||
@@ -275,7 +275,7 @@ end;
|
||||
class function TAstValue.FromText(const AValue: String): TAstValue;
|
||||
begin
|
||||
Result.FKind := avkText;
|
||||
Result.FInterface := TAstTextValue.Create(AValue);
|
||||
Result.FInterface := TAstValue<String>.Create(AValue);
|
||||
Result.FScalar := Default(TScalar);
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user